on xenial help sign in
Call updateDelegateCreationRange when it's needed
0c88c2fAlbert 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
@@ -336,6 +342,21 @@ Item {
336 tryCompare(category2, "filtered", true);
342 tryCompare(category2, "filtered", true);
337 tryCompare(category2FilterGrid, "filter", true);
343 tryCompare(category2FilterGrid, "filter", true);
338 }
344 }
345+
346+ function test_narrow_delegate_ranges_expand() {
347+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
348+ var category = findChild(genericScopeView, "dashCategory0")
349+
350+ shell.width = units.gu(20)
351+ var categoryListView = findChild(genericScopeView, "categoryListView");
352+ categoryListView.contentY = units.gu(20);
353+ var header0 = findChild(genericScopeView, "dashSectionHeader0")
354+ mouseClick(header0, header0.width / 2, header0.height / 2);
355+ tryCompare(category, "filtered", false);
356+ tryCompare(category.item, "delegateCreationEnd", category.item.delegateCreationBegin + genericScopeView.height);
357+ mouseClick(header0, header0.width / 2, header0.height / 2);
358+ tryCompare(category, "filtered", true);
359+ }
339 }
360 }
340 }
361 }
341}
362}