on xenial help sign in
second scenario and bugfixes for it
f7d2979Albert Astals
qml/Dash/GenericScopeView.qml+19−6
@@ -152,7 +152,7 @@ FocusScope {
152 interactive: !navigationShown
152 interactive: !navigationShown
153
153
154 property string expandedCategoryId: ""
154 property string expandedCategoryId: ""
155− property bool needMaximizeAfterExpand: false
155+ property int runMaximizeAfterSizeChanges: 0
156
156
157 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
157 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
158 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
158 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
@@ -186,7 +186,11 @@ FocusScope {
186 // If the space that shrkinking is smaller than the one we need to grow we'll call maximizeVisibleArea
186 // If the space that shrkinking is smaller than the one we need to grow we'll call maximizeVisibleArea
187 // after the shrink/grow animation ends
187 // after the shrink/grow animation ends
188 var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
188 var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
189− needMaximizeAfterExpand = growHeightDifference > shrinkHeightDifference;
189+ if (growHeightDifference > shrinkHeightDifference) {
190+ runMaximizeAfterSizeChanges = 2;
191+ } else {
192+ runMaximizeAfterSizeChanges = 0;
193+ }
190 }
194 }
191 }
195 }
192
196
@@ -253,13 +257,22 @@ FocusScope {
253 id: heightBehaviour
257 id: heightBehaviour
254 enabled: false
258 enabled: false
255 animation: UbuntuNumberAnimation {
259 animation: UbuntuNumberAnimation {
256− duration: categoryView.needMaximizeAfterExpand ? UbuntuAnimation.FastDuration / 2 : UbuntuAnimation.FastDuration
260+ duration: UbuntuAnimation.FastDuration
257 onRunningChanged: {
261 onRunningChanged: {
258 if (!running) {
262 if (!running) {
259 heightBehaviour.enabled = false
263 heightBehaviour.enabled = false
264+ if (categoryView.runMaximizeAfterSizeChanges > 0) {
265+ categoryView.runMaximizeAfterSizeChanges--;
266+ if (categoryView.runMaximizeAfterSizeChanges == 0) {
267+ var firstCreated = categoryView.firstCreatedIndex();
268+ for (var i = 0; i < categoryView.createdItemCount(); ++i) {
269+ var baseItem = categoryView.item(firstCreated + i);
260− if (categoryView.needMaximizeAfterExpand && baseItem.category === categoryView.expandedCategoryId) {
270+ if (baseItem.category === categoryView.expandedCategoryId) {
261− categoryView.maximizeVisibleArea(index, item.expandedHeight + seeAll.height);
271+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
262− categoryView.needMaximizeAfterExpand = false;
272+ break;
273+ }
274+ }
275+ }
263 }
276 }
264 }
277 }
265 }
278 }
tests/mocks/Unity/fake_categories.cpp+2−1
@@ -139,7 +139,8 @@ ResultsModel* Categories::resultModel(int row) const
139{
139{
140 ResultsModel *result = m_resultsModels[row];
140 ResultsModel *result = m_resultsModels[row];
141 if (!result) {
141 if (!result) {
142+ Categories *that = const_cast<Categories*>(this);
142− result = new ResultsModel(15, row);
143+ result = new ResultsModel(15, row, that);
143 m_resultsModels[row] = result;
144 m_resultsModels[row] = result;
144 }
145 }
145 return result;
146 return result;
tests/qmltests/Dash/tst_GenericScopeView.qml+46−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013, 2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -400,7 +400,10 @@ Item {
400 mockScope.setName("Mock Scope");
400 mockScope.setName("Mock Scope");
401 mockScope.categories.setCount(2);
401 mockScope.categories.setCount(2);
402 mockScope.categories.resultModel(0).setResultCount(50);
402 mockScope.categories.resultModel(0).setResultCount(50);
403+ mockScope.categories.resultModel(1).setResultCount(15);
404+ mockScope.categories.setLayout(0, "grid");
403 mockScope.categories.setLayout(1, "grid");
405 mockScope.categories.setLayout(1, "grid");
406+ mockScope.categories.setHeaderLink(0, "");
404 mockScope.categories.setHeaderLink(1, "");
407 mockScope.categories.setHeaderLink(1, "");
405 genericScopeView.scope = mockScope;
408 genericScopeView.scope = mockScope;
406 waitForRendering(genericScopeView.categoryView);
409 waitForRendering(genericScopeView.categoryView);
@@ -419,6 +422,7 @@ Item {
419
422
420 scrollToCategory("dashCategory1");
423 scrollToCategory("dashCategory1");
421
424
425+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory1") !== null; }, true);
422 var category1 = findChild(genericScopeView, "dashCategory1")
426 var category1 = findChild(genericScopeView, "dashCategory1")
423 var seeAll1 = findChild(category1, "seeAll")
427 var seeAll1 = findChild(category1, "seeAll")
424 verify(category1.expandable);
428 verify(category1.expandable);
@@ -433,6 +437,47 @@ Item {
433 == genericScopeView.categoryView.contentHeight;}
437 == genericScopeView.categoryView.contentHeight;}
434 , true);
438 , true);
435 }
439 }
440+
441+ function test_seeAllTwoCategoriesScenario2() {
442+ mockScope.setId("mockScope");
443+ mockScope.setName("Mock Scope");
444+ mockScope.categories.setCount(2);
445+ mockScope.categories.resultModel(0).setResultCount(15);
446+ mockScope.categories.resultModel(1).setResultCount(50);
447+ mockScope.categories.setLayout(0, "grid");
448+ mockScope.categories.setLayout(1, "grid");
449+ mockScope.categories.setHeaderLink(0, "");
450+ mockScope.categories.setHeaderLink(1, "");
451+ genericScopeView.scope = mockScope;
452+ waitForRendering(genericScopeView.categoryView);
453+
454+ var category0 = findChild(genericScopeView, "dashCategory0")
455+ var seeAll0 = findChild(category0, "seeAll")
456+
457+ waitForRendering(seeAll0);
458+ verify(category0.expandable);
459+ verify(!category0.expanded);
460+
461+ mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
462+ verify(category0.expanded);
463+ tryCompare(category0, "height", category0.item.expandedHeight + seeAll0.height);
464+
465+ scrollToCategory("dashCategory1");
466+
467+ var category1 = findChild(genericScopeView, "dashCategory1")
468+ var seeAll1 = findChild(category1, "seeAll")
469+ verify(category1.expandable);
470+ verify(!category1.expanded);
471+
472+ mouseClick(seeAll1, seeAll1.width / 2, seeAll1.height / 2);
473+ verify(!category0.expanded);
474+ verify(category1.expanded);
475+ tryCompare(category1, "height", category1.item.expandedHeight + seeAll1.height);
476+ tryCompareFunction(function() {
477+ return category0.height + genericScopeView.categoryView.pageHeader.height + category1.y
478+ == genericScopeView.categoryView.contentY;}
479+ , true);
480+ }
436 }
481 }
437 }
482 }
438}
483}