on xenial help sign in
Look up for expandable template dash category flag
57e5448Andrea Cimitan
qml/Dash/GenericScopeView.qml+3−1
@@ -243,8 +243,10 @@ FocusScope {
243
243
244 property Item seeAllButton: seeAll
244 property Item seeAllButton: seeAll
245
245
246+ readonly property bool forceNotExpandable: cardTool.template && cardTool.template["expandable"] === false
246 readonly property bool expandable: {
247 readonly property bool expandable: {
247 if (categoryView.model.count === 1) return false;
248 if (categoryView.model.count === 1) return false;
249+ if (forceNotExpandable) return false;
248 if (cardTool.template && cardTool.template["collapsed-rows"] === 0) return false;
250 if (cardTool.template && cardTool.template["collapsed-rows"] === 0) return false;
249 if (item && item.expandedHeight > item.collapsedHeight) return true;
251 if (item && item.expandedHeight > item.collapsedHeight) return true;
250 return false;
252 return false;
@@ -317,7 +319,7 @@ FocusScope {
317 }
319 }
318 }
320 }
319
321
320− readonly property bool expanded: baseItem.expanded || !baseItem.expandable
322+ readonly property bool expanded: !baseItem.forceNotExpandable && (baseItem.expanded || !baseItem.expandable)
321 height: expanded ? item.expandedHeight : item.collapsedHeight
323 height: expanded ? item.expandedHeight : item.collapsedHeight
322
324
323 source: {
325 source: {
tests/mocks/Unity/fake_categories.cpp+4
@@ -69,6 +69,10 @@ Categories::data(const QModelIndex& index, int role) const
69 } else {
69 } else {
70 map["category-layout"] = "carousel";
70 map["category-layout"] = "carousel";
71 }
71 }
72+ if (index.row() == 16) {
73+ map["expandable"] = false;
74+ map["collapsed-rows"] = 1;
75+ }
72 if (index.row() == 18) {
76 if (index.row() == 18) {
73 map["category-layout"] = "horizontal-list";
77 map["category-layout"] = "horizontal-list";
74 }
78 }
tests/qmltests/Dash/tst_GenericScopeView.qml+26
@@ -168,6 +168,32 @@ Item {
168 tryCompare(genericScopeView.scope, "searchQuery", "test")
168 tryCompare(genericScopeView.scope, "searchQuery", "test")
169 }
169 }
170
170
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+
171 function test_expand_collapse() {
197 function test_expand_collapse() {
172 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0", 0 /* timeout */) != null; }, true);
198 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0", 0 /* timeout */) != null; }, true);
173
199