@@ -38,6 +38,7 @@ FocusScope {
38 property int paginationCount: 0
38 property int paginationCount: 0
39 property int paginationIndex: 0
39 property int paginationIndex: 0
40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
41+ property var holdingList: null
42 property var scopeStyle: ScopeStyle {
43 property var scopeStyle: ScopeStyle {
43 style: scope ? scope.customizations : {}
44 style: scope ? scope.customizations : {}
@@ -47,6 +48,10 @@ FocusScope {
48 signal backClicked()
49 signal backClicked()
52+ floatingSeeLess.companionBase = null;
50 function positionAtBeginning() {
55 function positionAtBeginning() {
51 categoryView.positionAtBeginning()
56 categoryView.positionAtBeginning()
@@ -152,11 +157,55 @@ FocusScope {
152 forceNoClip: subPageLoader.open
157 forceNoClip: subPageLoader.open
153 pixelAligned: true
158 pixelAligned: true
155− property Item expandedCategoryItem: null
160+ property string expandedCategoryId: ""
161+ property int runMaximizeAfterSizeChanges: 0
157 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
163 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
158 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
164 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
166+ onExpandedCategoryIdChanged: {
167+ var firstCreated = firstCreatedIndex();
168+ var shrinkingAny = false;
169+ var shrinkHeightDifference = 0;
170+ for (var i = 0; i < createdItemCount(); ++i) {
171+ var baseItem = item(firstCreated + i);
172+ if (baseItem.expandable) {
173+ var shouldExpand = baseItem.category === expandedCategoryId;
174+ if (shouldExpand != baseItem.expanded) {
176+ var animate = false;
177+ if (!subPageLoader.open) {
178+ var animateShrinking = !shouldExpand && baseItem.y + baseItem.item.collapsedHeight + baseItem.seeAll.height < categoryView.height;
179+ var animateGrowing = shouldExpand && baseItem.y + baseItem.height < categoryView.height;
180+ animate = shrinkingAny || animateShrinking || animateGrowing;
183+ if (!shouldExpand) {
184+ shrinkingAny = true;
185+ shrinkHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
188+ if (shouldExpand && !subPageLoader.open) {
189+ if (!shrinkingAny) {
190+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
192+ // If the space that shrkinking is smaller than the one we need to grow we'll call maximizeVisibleArea
193+ // after the shrink/grow animation ends
194+ var growHeightDifference = baseItem.item.expandedHeight - baseItem.item.collapsedHeight;
195+ if (growHeightDifference > shrinkHeightDifference) {
196+ runMaximizeAfterSizeChanges = 2;
198+ runMaximizeAfterSizeChanges = 0;
203+ baseItem.expand(shouldExpand, animate);
160 delegate: ListItems.Base {
209 delegate: ListItems.Base {
161 id: baseItem
210 id: baseItem
162 objectName: "dashCategory" + category
211 objectName: "dashCategory" + category
@@ -175,6 +224,7 @@ FocusScope {
175 readonly property string category: categoryId
224 readonly property string category: categoryId
176 readonly property string headerLink: model.headerLink
225 readonly property string headerLink: model.headerLink
177 readonly property var item: rendererLoader.item
226 readonly property var item: rendererLoader.item
227+ readonly property var seeAll: seeAll
179 function expand(expand, animate) {
229 function expand(expand, animate) {
180 heightBehaviour.enabled = animate;
230 heightBehaviour.enabled = animate;
@@ -194,13 +244,13 @@ FocusScope {
194 // This can happen with the VJ that doesn't know how height it will be on creation
244 // This can happen with the VJ that doesn't know how height it will be on creation
195 // so doesn't set expandable until a bit too late for onLoaded
245 // so doesn't set expandable until a bit too late for onLoaded
196 if (expandable) {
246 if (expandable) {
197− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
247+ var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
198 baseItem.expand(shouldExpand, false /*animate*/);
248 baseItem.expand(shouldExpand, false /*animate*/);
202− onHeightChanged: rendererLoader.updateDelegateCreationRange();
252+ onHeightChanged: rendererLoader.updateRanges();
203− onYChanged: rendererLoader.updateDelegateCreationRange();
253+ onYChanged: rendererLoader.updateRanges();
206 id: rendererLoader
256 id: rendererLoader
@@ -215,9 +265,23 @@ FocusScope {
215 id: heightBehaviour
265 id: heightBehaviour
216 enabled: false
266 enabled: false
217 animation: UbuntuNumberAnimation {
267 animation: UbuntuNumberAnimation {
268+ duration: UbuntuAnimation.FastDuration
218 onRunningChanged: {
269 onRunningChanged: {
219 if (!running) {
270 if (!running) {
220 heightBehaviour.enabled = false
271 heightBehaviour.enabled = false
272+ if (categoryView.runMaximizeAfterSizeChanges > 0) {
273+ categoryView.runMaximizeAfterSizeChanges--;
274+ if (categoryView.runMaximizeAfterSizeChanges == 0) {
275+ var firstCreated = categoryView.firstCreatedIndex();
276+ for (var i = 0; i < categoryView.createdItemCount(); ++i) {
277+ var baseItem = categoryView.item(firstCreated + i);
278+ if (baseItem.category === categoryView.expandedCategoryId) {
279+ categoryView.maximizeVisibleArea(firstCreated + i, baseItem.item.expandedHeight + baseItem.seeAll.height);
@@ -245,10 +309,10 @@ FocusScope {
245 item.objectName = Qt.binding(function() { return categoryId })
309 item.objectName = Qt.binding(function() { return categoryId })
246 item.scopeStyle = scopeView.scopeStyle;
310 item.scopeStyle = scopeView.scopeStyle;
247 if (baseItem.expandable) {
311 if (baseItem.expandable) {
248− var shouldExpand = baseItem === categoryView.expandedCategoryItem;
312+ var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
249 baseItem.expand(shouldExpand, false /*animate*/);
313 baseItem.expand(shouldExpand, false /*animate*/);
251− updateDelegateCreationRange();
315+ updateRanges();
252 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
316 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
253 // Yeah, hackish :/
317 // Yeah, hackish :/
254 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
318 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
@@ -303,13 +367,25 @@ FocusScope {
306− onOriginYChanged: rendererLoader.updateDelegateCreationRange();
370+ onOriginYChanged: rendererLoader.updateRanges();
307− onContentYChanged: rendererLoader.updateDelegateCreationRange();
371+ onContentYChanged: rendererLoader.updateRanges();
308− onHeightChanged: rendererLoader.updateDelegateCreationRange();
372+ onHeightChanged: rendererLoader.updateRanges();
309− onContentHeightChanged: rendererLoader.updateDelegateCreationRange();
373+ onContentHeightChanged: rendererLoader.updateRanges();
377+ onIsCurrentChanged: rendererLoader.updateRanges();
381+ onMovingChanged: if (!moving) rendererLoader.updateRanges();
312− function updateDelegateCreationRange() {
384+ function updateRanges() {
385+ if (holdingList && holdingList.moving) {
313 if (categoryView.moving) {
389 if (categoryView.moving) {
314 // Do not update the range if we are overshooting up or down, since we'll come back
390 // Do not update the range if we are overshooting up or down, since we'll come back
315 // to the stable position and delete/create items without any reason
391 // to the stable position and delete/create items without any reason
@@ -321,10 +397,18 @@ FocusScope {
400+ if (item && item.hasOwnProperty("visibleRangeBegin")) {
401+ item.visibleRangeBegin = Math.max(-baseItem.y, 0)
402+ item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
324 if (item && item.hasOwnProperty("displayMarginBeginning")) {
405 if (item && item.hasOwnProperty("displayMarginBeginning")) {
325 // TODO do we need item.originY here, test 1300302 once we have a silo
406 // TODO do we need item.originY here, test 1300302 once we have a silo
326 // and we can run it on the phone
407 // and we can run it on the phone
408+ if (scopeView.isCurrent) {
409+ item.displayMarginBeginning = 1073741823;
410+ item.displayMarginEnd = 1073741823;
327− if (baseItem.y + baseItem.height <= 0) {
411+ } else if (baseItem.y + baseItem.height <= 0) {
328 // Not visible (item at top of the list viewport)
412 // Not visible (item at top of the list viewport)
329 item.displayMarginBeginning = -baseItem.height;
413 item.displayMarginBeginning = -baseItem.height;
330 item.displayMarginEnd = 0;
414 item.displayMarginEnd = 0;
@@ -333,9 +417,9 @@ FocusScope {
333 item.displayMarginBeginning = 0;
417 item.displayMarginBeginning = 0;
334 item.displayMarginEnd = -baseItem.height;
418 item.displayMarginEnd = -baseItem.height;
336− item.displayMarginBeginning = -Math.max(-baseItem.y, 0);
420+ item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
337− item.displayMarginEnd = -Math.max(baseItem.height - seeAll.height
421+ item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height
338− - categoryView.height + baseItem.y, 0)
422+ - categoryView.height + baseItem.y, 0));
@@ -352,10 +436,11 @@ FocusScope {
352 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
436 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
354 onClicked: {
438 onClicked: {
355− if (categoryView.expandedCategoryItem !== baseItem) {
439+ if (categoryView.expandedCategoryId !== baseItem.category) {
356− categoryView.expandedCategoryItem = baseItem;
440+ categoryView.expandedCategoryId = baseItem.category;
441+ floatingSeeLess.companionBase = baseItem;
358− categoryView.expandedCategoryItem = null;
443+ categoryView.expandedCategoryId = "";
@@ -455,7 +540,7 @@ FocusScope {
455 objectName: "floatingSeeLess"
540 objectName: "floatingSeeLess"
457 property Item companionTo: companionBase ? companionBase.seeAllButton : null
542 property Item companionTo: companionBase ? companionBase.seeAllButton : null
458− property Item companionBase: categoryView.expandedCategoryItem
543+ property Item companionBase: null
459 property bool showBecausePosition: false
544 property bool showBecausePosition: false
460 property real yOffset: 0
545 property real yOffset: 0
@@ -467,7 +552,7 @@ FocusScope {
467 height: seeLessLabel.font.pixelSize + units.gu(4)
552 height: seeLessLabel.font.pixelSize + units.gu(4)
468 visible: companionTo && showBecausePosition
553 visible: companionTo && showBecausePosition
470− onClicked: categoryView.expandedCategoryItem = null;
555+ onClicked: categoryView.expandedCategoryId = "";
472 function updateVisibility() {
557 function updateVisibility() {
473 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
558 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
@@ -476,6 +561,10 @@ FocusScope {
476 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
561 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
477 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
562 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
478 yOffset = Math.min(yOffset, height);
563 yOffset = Math.min(yOffset, height);
565+ if (!showBecausePosition && categoryView.expandedCategoryId === "") {
566+ companionBase = null;