on xenial help sign in
Sent the visible range so that even if we set a huge displayMargin for current view, the views are only created, not marked as visible
b5ed3a4Albert Astals
qml/Dash/CardGrid.qml+1
@@ -55,6 +55,7 @@ DashRenderer {
55 delegate: Item {
55 delegate: Item {
56 width: grid.cellWidth
56 width: grid.cellWidth
57 height: grid.cellHeight
57 height: grid.cellHeight
58+ visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
58 Loader {
59 Loader {
59 id: loader
60 id: loader
60 sourceComponent: cardTool.cardComponent
61 sourceComponent: cardTool.cardComponent
qml/Dash/CardVerticalJournal.qml+1
@@ -49,6 +49,7 @@ DashRenderer {
49 id: loader
49 id: loader
50 sourceComponent: cardTool.cardComponent
50 sourceComponent: cardTool.cardComponent
51 width: cardTool.cardWidth
51 width: cardTool.cardWidth
52+ visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
52 onLoaded: {
53 onLoaded: {
53 item.objectName = "delegate" + index;
54 item.objectName = "delegate" + index;
54 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
55 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/DashRenderer.qml+4
@@ -27,6 +27,10 @@ Item {
27
27
28 property int displayMarginEnd: 0
28 property int displayMarginEnd: 0
29
29
30+ property int visibleRangeBegin: 0
31+
32+ property int visibleRangeEnd: 0
33+
30 property real originY: 0
34 property real originY: 0
31
35
32 // The model to renderer
36 // The model to renderer
qml/Dash/GenericScopeView.qml+14−9
@@ -196,8 +196,8 @@ FocusScope {
196 }
196 }
197 }
197 }
198
198
199− onHeightChanged: rendererLoader.updateDelegateCreationRange();
199+ onHeightChanged: rendererLoader.updateRanges();
200− onYChanged: rendererLoader.updateDelegateCreationRange();
200+ onYChanged: rendererLoader.updateRanges();
201
201
202 Loader {
202 Loader {
203 id: rendererLoader
203 id: rendererLoader
@@ -245,7 +245,7 @@ FocusScope {
245 var shouldExpand = categoryId === categoryView.expandedCategoryId;
245 var shouldExpand = categoryId === categoryView.expandedCategoryId;
246 baseItem.expand(shouldExpand, false /*animate*/);
246 baseItem.expand(shouldExpand, false /*animate*/);
247 }
247 }
248− updateDelegateCreationRange();
248+ updateRanges();
249 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
249 if (scope && scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) {
250 // Yeah, hackish :/
250 // Yeah, hackish :/
251 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
251 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
@@ -300,17 +300,17 @@ FocusScope {
300 }
300 }
301 }
301 }
302 }
302 }
303− onOriginYChanged: rendererLoader.updateDelegateCreationRange();
303+ onOriginYChanged: rendererLoader.updateRanges();
304− onContentYChanged: rendererLoader.updateDelegateCreationRange();
304+ onContentYChanged: rendererLoader.updateRanges();
305− onHeightChanged: rendererLoader.updateDelegateCreationRange();
305+ onHeightChanged: rendererLoader.updateRanges();
306− onContentHeightChanged: rendererLoader.updateDelegateCreationRange();
306+ onContentHeightChanged: rendererLoader.updateRanges();
307 }
307 }
308 Connections {
308 Connections {
309 target: scopeView
309 target: scopeView
310− onIsCurrentChanged: rendererLoader.updateDelegateCreationRange();
310+ onIsCurrentChanged: rendererLoader.updateRanges();
311 }
311 }
312
312
313− function updateDelegateCreationRange() {
313+ function updateRanges() {
314 if (categoryView.moving) {
314 if (categoryView.moving) {
315 // Do not update the range if we are overshooting up or down, since we'll come back
315 // Do not update the range if we are overshooting up or down, since we'll come back
316 // to the stable position and delete/create items without any reason
316 // to the stable position and delete/create items without any reason
@@ -322,6 +322,11 @@ FocusScope {
322 }
322 }
323 }
323 }
324
324
325+ if (item && item.hasOwnProperty("visibleRangeBegin")) {
326+ item.visibleRangeBegin = Math.max(-baseItem.y, 0)
327+ item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
328+ }
329+
325 if (item && item.hasOwnProperty("displayMarginBeginning")) {
330 if (item && item.hasOwnProperty("displayMarginBeginning")) {
326 // TODO do we need item.originY here, test 1300302 once we have a silo
331 // TODO do we need item.originY here, test 1300302 once we have a silo
327 // and we can run it on the phone
332 // and we can run it on the phone