on xenial help sign in
Look up for expandable template dash category flag

Approved by: Albert Astals Cid, Unity8 CI Bot

commit57e5448f5adf17e7a9df25511531b4e25213a357 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 29 Nov 2016, 09:37 (10 years ago) parentb4413c67004232
3 files changed+33−1
qml/Dash/GenericScopeView.qml+3−1 tests/mocks/Unity/fake_categories.cpp+4 tests/qmltests/Dash/tst_GenericScopeView.qml+26
qml/Dash/GenericScopeView.qml+3−1
@@ -243,8 +243,10 @@ FocusScope {
243243
244244 property Item seeAllButton: seeAll
245245
246+ readonly property bool forceNotExpandable: cardTool.template && cardTool.template["expandable"] === false
246247 readonly property bool expandable: {
247248 if (categoryView.model.count === 1) return false;
249+ if (forceNotExpandable) return false;
248250 if (cardTool.template && cardTool.template["collapsed-rows"] === 0) return false;
249251 if (item && item.expandedHeight > item.collapsedHeight) return true;
250252 return false;
@@ -317,7 +319,7 @@ FocusScope {
317319 }
318320 }
319321
320− readonly property bool expanded: baseItem.expanded || !baseItem.expandable
322+ readonly property bool expanded: !baseItem.forceNotExpandable && (baseItem.expanded || !baseItem.expandable)
321323 height: expanded ? item.expandedHeight : item.collapsedHeight
322324
323325 source: {
tests/mocks/Unity/fake_categories.cpp+4
@@ -69,6 +69,10 @@ Categories::data(const QModelIndex& index, int role) const
6969 } else {
7070 map["category-layout"] = "carousel";
7171 }
72+ if (index.row() == 16) {
73+ map["expandable"] = false;
74+ map["collapsed-rows"] = 1;
75+ }
7276 if (index.row() == 18) {
7377 map["category-layout"] = "horizontal-list";
7478 }
tests/qmltests/Dash/tst_GenericScopeView.qml+26
@@ -168,6 +168,32 @@ Item {
168168 tryCompare(genericScopeView.scope, "searchQuery", "test")
169169 }
170170
171+ function test_forceNotExpandable() {
172+ // wait for the item to be there
173+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader14", 0 /* timeout */) != null; }, true);
174+
175+ var category14 = findChild(genericScopeView, "dashCategory14")
176+ var seeAll14 = findChild(category14, "seeAll")
177+
178+ compare(category14.forceNotExpandable, false);
179+ waitForRendering(seeAll14);
180+ verify(category14.expandable);
181+ verify(!category14.expanded);
182+ compare(seeAll14.visible, true);
183+
184+ // wait for the item to be there
185+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader16", 0 /* timeout */) != null; }, true);
186+
187+ var category16 = findChild(genericScopeView, "dashCategory16")
188+ var seeAll16 = findChild(category16, "seeAll")
189+
190+ compare(category16.forceNotExpandable, true);
191+ waitForRendering(seeAll16);
192+ verify(!category16.expandable);
193+ verify(!category16.expanded);
194+ compare(seeAll16.visible, false);
195+ }
196+
171197 function test_expand_collapse() {
172198 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0", 0 /* timeout */) != null; }, true);
173199