on xenial help sign in
Call updateDelegateCreationRange when it's needed
e065d70Albert Astals
qml/Dash/GenericScopeView.qml+7−1
@@ -141,6 +141,7 @@ FocusScope {
141 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
141 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
142 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
142 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
143 readonly property string category: categoryId
143 readonly property string category: categoryId
144+ readonly property var item: rendererLoader.item
144
145
145 Loader {
146 Loader {
146 id: rendererLoader
147 id: rendererLoader
@@ -248,8 +249,10 @@ FocusScope {
248 }
249 }
249 }
250 }
250 }
251 }
252+ onOriginYChanged: rendererLoader.updateDelegateCreationRange();
251 onContentYChanged: rendererLoader.updateDelegateCreationRange();
253 onContentYChanged: rendererLoader.updateDelegateCreationRange();
252 onHeightChanged: rendererLoader.updateDelegateCreationRange();
254 onHeightChanged: rendererLoader.updateDelegateCreationRange();
255+ onContentHeightChanged: rendererLoader.updateDelegateCreationRange();
253 }
256 }
254
257
255 function updateDelegateCreationRange() {
258 function updateDelegateCreationRange() {
@@ -261,7 +264,7 @@ FocusScope {
261 return;
264 return;
262 }
265 }
263
266
264− if (item.hasOwnProperty("delegateCreationBegin")) {
267+ if (item && item.hasOwnProperty("delegateCreationBegin")) {
265 if (baseItem.y + baseItem.height <= 0) {
268 if (baseItem.y + baseItem.height <= 0) {
266 // Not visible (item at top of the list)
269 // Not visible (item at top of the list)
267 item.delegateCreationBegin = baseItem.height
270 item.delegateCreationBegin = baseItem.height
@@ -277,6 +280,9 @@ FocusScope {
277 }
280 }
278 }
281 }
279 }
282 }
283+
284+ onHeightChanged: rendererLoader.updateDelegateCreationRange();
285+ onYChanged: rendererLoader.updateDelegateCreationRange();
280 }
286 }
281
287
282 sectionProperty: "name"
288 sectionProperty: "name"
tests/qmltests/Dash/tst_GenericScopeView.qml+22−1
@@ -71,7 +71,13 @@ Item {
71 name: "GenericScopeView"
71 name: "GenericScopeView"
72 when: scopes.loaded
72 when: scopes.loaded
73
73
74+ function init() {
75+ shell.width = units.gu(120)
76+ genericScopeView.categoryView.positionAtBeginning();
77+ tryCompare(genericScopeView.categoryView.contentY, 0)
78+ }
79+
74− function test_isCurrent() {
80+ function test_isCurrent() {
75 genericScopeView.isCurrent = true
81 genericScopeView.isCurrent = true
76 pageHeader.searchQuery = "test"
82 pageHeader.searchQuery = "test"
77 previewListView.open = true
83 previewListView.open = true
@@ -351,6 +357,21 @@ Item {
351 tryCompare(category2, "filtered", true);
357 tryCompare(category2, "filtered", true);
352 tryCompare(category2FilterGrid, "filter", true);
358 tryCompare(category2FilterGrid, "filter", true);
353 }
359 }
360+
361+ function test_narrow_delegate_ranges_expand() {
362+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
363+ var category = findChild(genericScopeView, "dashCategory0")
364+
365+ shell.width = units.gu(20)
366+ var categoryListView = findChild(genericScopeView, "categoryListView");
367+ categoryListView.contentY = units.gu(20);
368+ var header0 = findChild(genericScopeView, "dashSectionHeader0")
369+ mouseClick(header0, header0.width / 2, header0.height / 2);
370+ tryCompare(category, "filtered", false);
371+ tryCompare(category.item, "delegateCreationEnd", category.item.delegateCreationBegin + genericScopeView.height);
372+ mouseClick(header0, header0.width / 2, header0.height / 2);
373+ tryCompare(category, "filtered", true);
374+ }
354 }
375 }
355 }
376 }
356}
377}