on xenial help sign in
Call updateDelegateCreationRange when it's needed

It depends on other variables than the ones we were using to call it, so need to call it if these change too Device manual test, go to apps scope, scroll down so that only part of the installed apps collapsed category is shown, expand it, see how previously some icons were not painted and now they are

commite065d70e9463c9ccce40c2dda4f05e114fa425fb authorAlbert Astals <albert.astals@canonical.com> dateWed 29 Jan 2014, 16:10 (13 years ago) parentfcb543b0c88c2f
2 files changed+29−2
qml/Dash/GenericScopeView.qml+7−1 tests/qmltests/Dash/tst_GenericScopeView.qml+22−1
qml/Dash/GenericScopeView.qml+7−1
@@ -141,6 +141,7 @@ FocusScope {
141141 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
142142 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
143143 readonly property string category: categoryId
144+ readonly property var item: rendererLoader.item
144145
145146 Loader {
146147 id: rendererLoader
@@ -248,8 +249,10 @@ FocusScope {
248249 }
249250 }
250251 }
252+ onOriginYChanged: rendererLoader.updateDelegateCreationRange();
251253 onContentYChanged: rendererLoader.updateDelegateCreationRange();
252254 onHeightChanged: rendererLoader.updateDelegateCreationRange();
255+ onContentHeightChanged: rendererLoader.updateDelegateCreationRange();
253256 }
254257
255258 function updateDelegateCreationRange() {
@@ -261,7 +264,7 @@ FocusScope {
261264 return;
262265 }
263266
264− if (item.hasOwnProperty("delegateCreationBegin")) {
267+ if (item && item.hasOwnProperty("delegateCreationBegin")) {
265268 if (baseItem.y + baseItem.height <= 0) {
266269 // Not visible (item at top of the list)
267270 item.delegateCreationBegin = baseItem.height
@@ -277,6 +280,9 @@ FocusScope {
277280 }
278281 }
279282 }
283+
284+ onHeightChanged: rendererLoader.updateDelegateCreationRange();
285+ onYChanged: rendererLoader.updateDelegateCreationRange();
280286 }
281287
282288 sectionProperty: "name"
tests/qmltests/Dash/tst_GenericScopeView.qml+22−1
@@ -71,7 +71,13 @@ Item {
7171 name: "GenericScopeView"
7272 when: scopes.loaded
7373
74− function test_isCurrent() {
74+ function init() {
75+ shell.width = units.gu(120)
76+ genericScopeView.categoryView.positionAtBeginning();
77+ tryCompare(genericScopeView.categoryView.contentY, 0)
78+ }
79+
80+ function test_isCurrent() {
7581 genericScopeView.isCurrent = true
7682 pageHeader.searchQuery = "test"
7783 previewListView.open = true
@@ -351,6 +357,21 @@ Item {
351357 tryCompare(category2, "filtered", true);
352358 tryCompare(category2FilterGrid, "filter", true);
353359 }
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+ }
354375 }
355376 }
356377}