on xenial help sign in
Use the new displayMargin feature
a174c26Albert Astals
plugins/Dash/abstractdashview.cpp+18−48
@@ -23,10 +23,8 @@ AbstractDashView::AbstractDashView()
23 , m_asyncRequestedIndex(-1)
23 , m_asyncRequestedIndex(-1)
24 , m_columnSpacing(0)
24 , m_columnSpacing(0)
25 , m_rowSpacing(0)
25 , m_rowSpacing(0)
26− , m_delegateCreationBegin(0)
26+ , m_displayMarginBeginning(0)
27− , m_delegateCreationEnd(0)
27+ , m_displayMarginEnd(0)
28− , m_delegateCreationBeginValid(false)
29− , m_delegateCreationEndValid(false)
30 , m_needsRelayout(false)
28 , m_needsRelayout(false)
31 , m_delegateValidated(false)
29 , m_delegateValidated(false)
32 , m_implicitHeightDirty(false)
30 , m_implicitHeightDirty(false)
@@ -114,62 +112,36 @@ void AbstractDashView::setRowSpacing(qreal rowSpacing)
114 }
112 }
115}
113}
116
114
117−qreal AbstractDashView::delegateCreationBegin() const
115+qreal AbstractDashView::displayMarginBeginning() const
118{
116{
119− return m_delegateCreationBegin;
117+ return m_displayMarginBeginning;
120}
118}
121
119
122−void AbstractDashView::setDelegateCreationBegin(qreal begin)
120+void AbstractDashView::setDisplayMarginBeginning(qreal begin)
123{
121{
124− m_delegateCreationBeginValid = true;
122+ if (m_displayMarginBeginning == begin)
125− if (m_delegateCreationBegin == begin)
126 return;
123 return;
127− m_delegateCreationBegin = begin;
124+ m_displayMarginBeginning = begin;
128 if (isComponentComplete()) {
125 if (isComponentComplete()) {
129 polish();
126 polish();
130 }
127 }
131− emit delegateCreationBeginChanged();
128+ emit displayMarginBeginningChanged();
132}
129}
133
130
134−void AbstractDashView::resetDelegateCreationBegin()
131+qreal AbstractDashView::displayMarginEnd() const
135{
132{
136− m_delegateCreationBeginValid = false;
133+ return m_displayMarginEnd;
137− if (m_delegateCreationBegin == 0)
138− return;
139− m_delegateCreationBegin = 0;
140− if (isComponentComplete()) {
141− polish();
142− }
143− emit delegateCreationBeginChanged();
144−}
145−
146−qreal AbstractDashView::delegateCreationEnd() const
147−{
148− return m_delegateCreationEnd;
149−}
150−
151−void AbstractDashView::setDelegateCreationEnd(qreal end)
152−{
153− m_delegateCreationEndValid = true;
154− if (m_delegateCreationEnd == end)
155− return;
156− m_delegateCreationEnd = end;
157− if (isComponentComplete()) {
158− polish();
159− }
160− emit delegateCreationEndChanged();
161}
134}
162
135
163−void AbstractDashView::resetDelegateCreationEnd()
136+void AbstractDashView::setDisplayMarginEnd(qreal end)
164{
137{
165− m_delegateCreationEndValid = false;
138+ if (m_displayMarginEnd == end)
166− if (m_delegateCreationEnd == 0)
167 return;
139 return;
168− m_delegateCreationEnd = 0;
140+ m_displayMarginEnd = end;
169 if (isComponentComplete()) {
141 if (isComponentComplete()) {
170 polish();
142 polish();
171 }
143 }
172− emit delegateCreationEndChanged();
144+ emit displayMarginEndChanged();
173}
145}
174
146
175void AbstractDashView::createDelegateModel()
147void AbstractDashView::createDelegateModel()
@@ -186,9 +158,8 @@ void AbstractDashView::refill()
186 return;
158 return;
187 }
159 }
188
160
189− const bool delegateRangesValid = m_delegateCreationBeginValid && m_delegateCreationEndValid;
161+ const qreal from = -m_displayMarginBeginning;
190− const qreal from = delegateRangesValid ? m_delegateCreationBegin : 0;
162+ const qreal to = height() + m_displayMarginEnd;
191− const qreal to = delegateRangesValid ? m_delegateCreationEnd : from + height();
192 const qreal buffer = (to - from) * bufferRatio;
163 const qreal buffer = (to - from) * bufferRatio;
193 const qreal bufferFrom = from - buffer;
164 const qreal bufferFrom = from - buffer;
194 const qreal bufferTo = to + buffer;
165 const qreal bufferTo = to + buffer;
@@ -330,9 +301,8 @@ void AbstractDashView::updatePolish()
330
301
331 refill();
302 refill();
332
303
333− const bool delegateRangesValid = m_delegateCreationBeginValid && m_delegateCreationEndValid;
304+ const qreal from = -m_displayMarginBeginning;
334− const qreal from = delegateRangesValid ? m_delegateCreationBegin : 0;
305+ const qreal to = height() + m_displayMarginEnd;
335− const qreal to = delegateRangesValid ? m_delegateCreationEnd : from + height();
336 updateItemCulling(from, to);
306 updateItemCulling(from, to);
337
307
338 if (m_implicitHeightDirty) {
308 if (m_implicitHeightDirty) {
plugins/Dash/abstractdashview.h+14−20
@@ -35,14 +35,12 @@ class AbstractDashView : public QQuickItem
35 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
35 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
36 Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
36 Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
37 Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
37 Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
38− Q_PROPERTY(qreal delegateCreationBegin READ delegateCreationBegin
38+ Q_PROPERTY(qreal displayMarginBeginning READ displayMarginBeginning
39− WRITE setDelegateCreationBegin
39+ WRITE setDisplayMarginBeginning
40− NOTIFY delegateCreationBeginChanged
40+ NOTIFY displayMarginBeginningChanged)
41− RESET resetDelegateCreationBegin)
41+ Q_PROPERTY(qreal displayMarginEnd READ displayMarginEnd
42− Q_PROPERTY(qreal delegateCreationEnd READ delegateCreationEnd
42+ WRITE setDisplayMarginEnd
43− WRITE setDelegateCreationEnd
43+ NOTIFY displayMarginEndChanged)
44− NOTIFY delegateCreationEndChanged
45− RESET resetDelegateCreationEnd)
46
44
47friend class VerticalJournalTest;
45friend class VerticalJournalTest;
48friend class HorizontalJournalTest;
46friend class HorizontalJournalTest;
@@ -63,21 +61,19 @@ public:
63 qreal rowSpacing() const;
61 qreal rowSpacing() const;
64 void setRowSpacing(qreal rowSpacing);
62 void setRowSpacing(qreal rowSpacing);
65
63
66− qreal delegateCreationBegin() const;
64+ qreal displayMarginBeginning() const;
67− void setDelegateCreationBegin(qreal);
65+ void setDisplayMarginBeginning(qreal);
68− void resetDelegateCreationBegin();
69
66
70− qreal delegateCreationEnd() const;
67+ qreal displayMarginEnd() const;
71− void setDelegateCreationEnd(qreal);
68+ void setDisplayMarginEnd(qreal);
72− void resetDelegateCreationEnd();
73
69
74Q_SIGNALS:
70Q_SIGNALS:
75 void modelChanged();
71 void modelChanged();
76 void delegateChanged();
72 void delegateChanged();
77 void columnSpacingChanged();
73 void columnSpacingChanged();
78 void rowSpacingChanged();
74 void rowSpacingChanged();
79− void delegateCreationBeginChanged();
75+ void displayMarginBeginningChanged();
80− void delegateCreationEndChanged();
76+ void displayMarginEndChanged();
81
77
82protected Q_SLOTS:
78protected Q_SLOTS:
83 void relayout();
79 void relayout();
@@ -117,10 +113,8 @@ private:
117
113
118 int m_columnSpacing;
114 int m_columnSpacing;
119 int m_rowSpacing;
115 int m_rowSpacing;
120− qreal m_delegateCreationBegin;
116+ qreal m_displayMarginBeginning;
121− qreal m_delegateCreationEnd;
117+ qreal m_displayMarginEnd;
122− bool m_delegateCreationBeginValid;
123− bool m_delegateCreationEndValid;
124 bool m_needsRelayout;
118 bool m_needsRelayout;
125 bool m_delegateValidated;
119 bool m_delegateValidated;
126 bool m_implicitHeightDirty;
120 bool m_implicitHeightDirty;
qml/Components/FilterGrid.qml+2−2
@@ -52,8 +52,8 @@ Item {
52 property alias delegate: iconTileGrid.delegate
52 property alias delegate: iconTileGrid.delegate
53 property alias cellWidth: iconTileGrid.cellWidth
53 property alias cellWidth: iconTileGrid.cellWidth
54 property alias cellHeight: iconTileGrid.cellHeight
54 property alias cellHeight: iconTileGrid.cellHeight
55− property alias delegateCreationBegin: iconTileGrid.delegateCreationBegin
55+ property alias displayMarginBeginning: iconTileGrid.displayMarginBeginning
56− property alias delegateCreationEnd: iconTileGrid.delegateCreationEnd
56+ property alias displayMarginEnd: iconTileGrid.displayMarginEnd
57 readonly property alias originY: iconTileGrid.originY
57 readonly property alias originY: iconTileGrid.originY
58 readonly property alias flicking: iconTileGrid.flicking
58 readonly property alias flicking: iconTileGrid.flicking
59 readonly property alias moving: iconTileGrid.moving
59 readonly property alias moving: iconTileGrid.moving
qml/Components/ResponsiveGridView.qml+3−3
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−import QtQuick 2.0
17+import QtQuick 2.3
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19
19
20/*
20/*
@@ -41,8 +41,8 @@ Item {
41 readonly property alias moving: gridView.moving
41 readonly property alias moving: gridView.moving
42 readonly property alias pressDelay: gridView.pressDelay
42 readonly property alias pressDelay: gridView.pressDelay
43 readonly property alias originY: gridView.originY
43 readonly property alias originY: gridView.originY
44− property alias delegateCreationBegin: gridView.delegateCreationBegin
44+ property alias displayMarginBeginning: gridView.displayMarginBeginning
45− property alias delegateCreationEnd: gridView.delegateCreationEnd
45+ property alias displayMarginEnd: gridView.displayMarginEnd
46 property alias highlightIndex: gridView.highlightIndex
46 property alias highlightIndex: gridView.highlightIndex
47 readonly property alias currentItem: gridView.currentItem
47 readonly property alias currentItem: gridView.currentItem
48
48
qml/Dash/CardFilterGrid.qml+2−2
@@ -43,8 +43,8 @@ DashRenderer {
43 verticalSpacing: genericFilterGrid.verticalSpacing
43 verticalSpacing: genericFilterGrid.verticalSpacing
44 model: genericFilterGrid.model
44 model: genericFilterGrid.model
45 collapsedRowCount: Math.min(2, cardTool && cardTool.template && cardTool.template["collapsed-rows"] || 2)
45 collapsedRowCount: Math.min(2, cardTool && cardTool.template && cardTool.template["collapsed-rows"] || 2)
46− delegateCreationBegin: genericFilterGrid.delegateCreationBegin
46+ displayMarginBeginning: genericFilterGrid.displayMarginBeginning
47− delegateCreationEnd: genericFilterGrid.delegateCreationEnd
47+ displayMarginEnd: genericFilterGrid.displayMarginEnd
48 delegate: Item {
48 delegate: Item {
49 width: filterGrid.cellWidth
49 width: filterGrid.cellWidth
50 height: filterGrid.cellHeight
50 height: filterGrid.cellHeight
qml/Dash/DashRenderer.qml+2−2
@@ -29,9 +29,9 @@ Item {
29
29
30 property int uncollapsedHeight: height
30 property int uncollapsedHeight: height
31
31
32− property var delegateCreationBegin: undefined
32+ property int displayMarginBeginning: 0
33
33
34− property var delegateCreationEnd: undefined
34+ property int displayMarginEnd: 0
35
35
36 property real originY: 0
36 property real originY: 0
37
37
qml/Dash/GenericScopeView.qml+9−7
@@ -244,18 +244,20 @@ FocusScope {
244 }
244 }
245 }
245 }
246
246
247− if (item && item.hasOwnProperty("delegateCreationBegin")) {
247+ if (item && item.hasOwnProperty("displayMarginBeginning")) {
248+ // TODO do we need item.originY here, test 1300302 once we have a silo
249+ // and we can run it on the phone
248 if (baseItem.y + baseItem.height <= 0) {
250 if (baseItem.y + baseItem.height <= 0) {
249 // Not visible (item at top of the list viewport)
251 // Not visible (item at top of the list viewport)
250− item.delegateCreationBegin = item.originY + baseItem.height
252+ item.displayMarginBeginning = -baseItem.height;
251− item.delegateCreationEnd = item.originY + baseItem.height
253+ item.displayMarginEnd = 0;
252 } else if (baseItem.y >= categoryView.height) {
254 } else if (baseItem.y >= categoryView.height) {
253 // Not visible (item at bottom of the list viewport)
255 // Not visible (item at bottom of the list viewport)
254− item.delegateCreationBegin = item.originY
256+ item.displayMarginBeginning = 0;
255− item.delegateCreationEnd = item.originY
257+ item.displayMarginEnd = -baseItem.height;
256 } else {
258 } else {
257− item.delegateCreationBegin = item.originY + Math.max(-baseItem.y, 0)
259+ item.displayMarginBeginning = -Math.max(-baseItem.y, 0);
258− item.delegateCreationEnd = item.originY + Math.min(categoryView.height + item.delegateCreationBegin, baseItem.height)
260+ item.displayMarginEnd = -Math.max(baseItem.height - categoryView.height + baseItem.y, 0)
259 }
261 }
260 }
262 }
261 }
263 }
tests/plugins/Dash/horizontaljournaltest.cpp+6−6
@@ -258,8 +258,8 @@ private Q_SLOTS:
258
258
259 void testDelegateCreationRanges()
259 void testDelegateCreationRanges()
260 {
260 {
261− hj->setDelegateCreationBegin(300);
261+ hj->setDisplayMarginBeginning(-300);
262− hj->setDelegateCreationEnd(view->height());
262+ hj->setDisplayMarginEnd(-(hj->height() - view->height()));
263
263
264 QTRY_COMPARE(hj->m_firstVisibleIndex, 6);
264 QTRY_COMPARE(hj->m_firstVisibleIndex, 6);
265 QTRY_COMPARE(hj->m_visibleItems.count(), 7);
265 QTRY_COMPARE(hj->m_visibleItems.count(), 7);
@@ -274,8 +274,8 @@ private Q_SLOTS:
274 QTRY_COMPARE(hj->m_lastInRowIndexPosition[ 7], 210.);
274 QTRY_COMPARE(hj->m_lastInRowIndexPosition[ 7], 210.);
275 QTRY_COMPARE(hj->m_lastInRowIndexPosition[12], 305.);
275 QTRY_COMPARE(hj->m_lastInRowIndexPosition[12], 305.);
276
276
277− hj->resetDelegateCreationBegin();
277+ hj->setDisplayMarginBeginning(0);
278− hj->resetDelegateCreationEnd();
278+ hj->setDisplayMarginEnd(0);
279
279
280 // This is exactly the same block as the first again
280 // This is exactly the same block as the first again
281 checkInitialPositions();
281 checkInitialPositions();
@@ -469,8 +469,8 @@ private Q_SLOTS:
469
469
470 void testNegativeDelegateCreationRange()
470 void testNegativeDelegateCreationRange()
471 {
471 {
472− hj->setDelegateCreationBegin(0);
472+ hj->setDisplayMarginBeginning(0);
473− hj->setDelegateCreationEnd(-100);
473+ hj->setDisplayMarginEnd(-(hj->height() + 100));
474
474
475 QStringList widthList;
475 QStringList widthList;
476 widthList << "100" << "50" << "50" << "30";
476 widthList << "100" << "50" << "50" << "30";
tests/plugins/Dash/organicgridtest.cpp+2−5
@@ -499,17 +499,14 @@ private Q_SLOTS:
499 QTRY_COMPARE(grid->m_firstVisibleIndex, 0);
499 QTRY_COMPARE(grid->m_firstVisibleIndex, 0);
500 QTRY_COMPARE(grid->m_visibleItems.count(), 198);
500 QTRY_COMPARE(grid->m_visibleItems.count(), 198);
501
501
502− grid->setDelegateCreationBegin(300);
502+ grid->setDisplayMarginBeginning(-300);
503− grid->setDelegateCreationEnd(400);
503+ grid->setDisplayMarginEnd(-(grid->height() - 400));
504 checkImplicitHeight(2290);
504 checkImplicitHeight(2290);
505
505
506 QTRY_COMPARE(grid->m_firstVisibleIndex, 36);
506 QTRY_COMPARE(grid->m_firstVisibleIndex, 36);
507 QTRY_COMPARE(grid->m_visibleItems.count(), 54);
507 QTRY_COMPARE(grid->m_visibleItems.count(), 54);
508 checkImplicitHeight(2290);
508 checkImplicitHeight(2290);
509
509
510− grid->resetDelegateCreationBegin();
511− grid->resetDelegateCreationEnd();
512−
513 view->resize(470, 470);
510 view->resize(470, 470);
514
511
515 grid->setSmallDelegateSize(QSizeF(90, 90));
512 grid->setSmallDelegateSize(QSizeF(90, 90));
tests/plugins/Dash/verticaljournaltest.cpp+6−6
@@ -263,8 +263,8 @@ private Q_SLOTS:
263
263
264 void testDelegateCreationRanges()
264 void testDelegateCreationRanges()
265 {
265 {
266− vj->setDelegateCreationBegin(200);
266+ vj->setDisplayMarginBeginning(-200);
267− vj->setDelegateCreationEnd(view->height());
267+ vj->setDisplayMarginEnd(-(vj->height() - view->height()));
268
268
269 QTRY_COMPARE(vj->m_columnVisibleItems.count(), 3);
269 QTRY_COMPARE(vj->m_columnVisibleItems.count(), 3);
270 QTRY_COMPARE(vj->m_columnVisibleItems[0].count(), 4);
270 QTRY_COMPARE(vj->m_columnVisibleItems[0].count(), 4);
@@ -286,8 +286,8 @@ private Q_SLOTS:
286 verifyItem(vj->m_columnVisibleItems[1][3], 15, 160, 430, false);
286 verifyItem(vj->m_columnVisibleItems[1][3], 15, 160, 430, false);
287 QCOMPARE(vj->implicitHeight(), 690. + 4. * 690. / 16.);
287 QCOMPARE(vj->implicitHeight(), 690. + 4. * 690. / 16.);
288
288
289− vj->resetDelegateCreationBegin();
289+ vj->setDisplayMarginBeginning(0);
290− vj->resetDelegateCreationEnd();
290+ vj->setDisplayMarginEnd(0);
291
291
292 // This is exactly the same block as the first again
292 // This is exactly the same block as the first again
293 checkInitialPositions();
293 checkInitialPositions();
@@ -478,8 +478,8 @@ private Q_SLOTS:
478
478
479 void testNegativeDelegateCreationRange()
479 void testNegativeDelegateCreationRange()
480 {
480 {
481− vj->setDelegateCreationBegin(0);
481+ vj->setDisplayMarginBeginning(0);
482− vj->setDelegateCreationEnd(-100);
482+ vj->setDisplayMarginEnd(-(vj->height() + 100));
483
483
484 QStringList heightList;
484 QStringList heightList;
485 heightList << "100" << "50" << "50" << "30";
485 heightList << "100" << "50" << "50" << "30";
tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
@@ -199,7 +199,7 @@ Item {
199 var header0 = findChild(genericScopeView, "dashSectionHeader0")
199 var header0 = findChild(genericScopeView, "dashSectionHeader0")
200 mouseClick(header0, header0.width / 2, header0.height / 2);
200 mouseClick(header0, header0.width / 2, header0.height / 2);
201 tryCompare(category, "filtered", false);
201 tryCompare(category, "filtered", false);
202− tryCompare(category.item, "delegateCreationEnd", category.item.delegateCreationBegin + genericScopeView.height);
202+ tryCompareFunction(function() { return category.item.height == genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd; }, true);
203 mouseClick(header0, header0.width / 2, header0.height / 2);
203 mouseClick(header0, header0.width / 2, header0.height / 2);
204 tryCompare(category, "filtered", true);
204 tryCompare(category, "filtered", true);
205 }
205 }