on xenial help sign in
Dash: Set delegate creation range for inner itemviewss
cee3cecAlbert Astals
Components/FilterGrid.qml+2
@@ -57,6 +57,8 @@ Item {
57 property alias delegate: iconTileGrid.delegate
57 property alias delegate: iconTileGrid.delegate
58 property alias cellWidth: iconTileGrid.cellWidth
58 property alias cellWidth: iconTileGrid.cellWidth
59 property alias cellHeight: iconTileGrid.cellHeight
59 property alias cellHeight: iconTileGrid.cellHeight
60+ property alias delegateCreationBegin: iconTileGrid.delegateCreationBegin
61+ property alias delegateCreationEnd: iconTileGrid.delegateCreationEnd
60 readonly property alias flicking: iconTileGrid.flicking
62 readonly property alias flicking: iconTileGrid.flicking
61 readonly property alias moving: iconTileGrid.moving
63 readonly property alias moving: iconTileGrid.moving
62 readonly property alias pressDelay: iconTileGrid.pressDelay
64 readonly property alias pressDelay: iconTileGrid.pressDelay
Components/ResponsiveGridView.qml+2
@@ -39,6 +39,8 @@ Item {
39 readonly property alias flicking: gridView.flicking
39 readonly property alias flicking: gridView.flicking
40 readonly property alias moving: gridView.moving
40 readonly property alias moving: gridView.moving
41 readonly property alias pressDelay: gridView.pressDelay
41 readonly property alias pressDelay: gridView.pressDelay
42+ property alias delegateCreationBegin: gridView.delegateCreationBegin
43+ property alias delegateCreationEnd: gridView.delegateCreationEnd
42
44
43 function contentHeightForRows(rows) {
45 function contentHeightForRows(rows) {
44 return rows * cellHeight + verticalSpacing
46 return rows * cellHeight + verticalSpacing
Dash/GenericScopeView.qml+29
@@ -72,6 +72,7 @@ ScopeView {
72 property string expandedCategoryId: ""
72 property string expandedCategoryId: ""
73
73
74 delegate: ListItems.Base {
74 delegate: ListItems.Base {
75+ id: baseItem
75 highlightWhenPressed: false
76 highlightWhenPressed: false
76
77
77 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
78 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
@@ -108,6 +109,7 @@ ScopeView {
108 item.filter = shouldFilter;
109 item.filter = shouldFilter;
109 }
110 }
110 }
111 }
112+ updateDelegateCreationRange();
111 }
113 }
112
114
113 Component.onDestruction: {
115 Component.onDestruction: {
@@ -164,6 +166,33 @@ ScopeView {
164 }
166 }
165 }
167 }
166 }
168 }
169+ onContentYChanged: rendererLoader.updateDelegateCreationRange();
170+ onHeightChanged: rendererLoader.updateDelegateCreationRange();
171+ }
172+
173+ function updateDelegateCreationRange() {
174+ // Do not update the range if we are overshooting up or down, since we'll come back
175+ // to the stable position and delete/create items without any reason
176+ if (categoryView.contentY < categoryView.originY) {
177+ return;
178+ } else if (categoryView.contentY + categoryView.height > categoryView.contentHeight) {
179+ return;
180+ }
181+
182+ if (item.hasOwnProperty("delegateCreationBegin")) {
183+ if (baseItem.y + baseItem.height <= 0) {
184+ // Not visible (item at top of the list)
185+ item.delegateCreationBegin = baseItem.height
186+ item.delegateCreationEnd = baseItem.height
187+ } else if (baseItem.y >= categoryView.height) {
188+ // Not visible (item at bottom of the list)
189+ item.delegateCreationBegin = 0
190+ item.delegateCreationEnd = 0
191+ } else {
192+ item.delegateCreationBegin = Math.max(-baseItem.y, 0)
193+ item.delegateCreationEnd = Math.min(categoryView.height + item.delegateCreationBegin, baseItem.height)
194+ }
195+ }
167 }
196 }
168 }
197 }
169 }
198 }