Merge lp:~saviq/ubuntu/saucy/qtdeclarative-opensource-src/add-qtquick-delegate-range into lp:ubuntu/saucy-proposed/qtdeclarative-opensource-src

Proposed by Michał Sawicz
Status: Merged
Merge reported by: Michał Sawicz
Merged at revision: not available
Proposed branch: lp:~saviq/ubuntu/saucy/qtdeclarative-opensource-src/add-qtquick-delegate-range
Merge into: lp:ubuntu/saucy-proposed/qtdeclarative-opensource-src
Diff against target: 1168 lines (+977/-7)
12 files modified
.pc/applied-patches (+1/-0)
debian/changelog (+7/-0)
debian/patches/qtquick_delegate_creation_range_itemviews.patch (+565/-0)
debian/patches/series (+1/-0)
src/quick/items/qquickgridview.cpp (+1/-1)
src/quick/items/qquickitemview.cpp (+75/-5)
src/quick/items/qquickitemview_p.h (+12/-0)
src/quick/items/qquickitemview_p_p.h (+5/-1)
tests/auto/quick/qquickgridview/data/delegateCreationRange.qml (+89/-0)
tests/auto/quick/qquickgridview/tst_qquickgridview.cpp (+67/-0)
tests/auto/quick/qquicklistview/data/delegateCreationRange.qml (+84/-0)
tests/auto/quick/qquicklistview/tst_qquicklistview.cpp (+70/-0)
To merge this branch: bzr merge lp:~saviq/ubuntu/saucy/qtdeclarative-opensource-src/add-qtquick-delegate-range
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Michael Zanetti (community) code review Approve
Review via email: mp+184774@code.launchpad.net

Commit message

Add qtquick_delegate_creation_range_itemviews.patch to patchset. LP #1217924

Description of the change

See bug #1217924 for details.

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Seems this was uploaded already.

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

Not sure what you mean Daniel? Uploaded where?

Revision history for this message
Daniel Holbach (dholbach) wrote :

Sorry, I was confused. After branching your code, I looked at debian/changelog and it said 5.0.2-6ubuntu1, so I assumed it had already been uploaded. It seems you didn't add a changelog entry for your upload.

Revision history for this message
Michał Sawicz (saviq) wrote :

Indeed, let me fix that...

9. By Michał Sawicz

Add changelog entry.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Code looks good to me.

review: Approve (code review)
Revision history for this message
Daniel Holbach (dholbach) wrote :

Are we good to go on this one?

Revision history for this message
Michał Sawicz (saviq) wrote :

Yes.

Revision history for this message
Daniel Holbach (dholbach) wrote :

Thanks. Uploaded.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2013-07-08 07:51:02 +0000
3+++ .pc/applied-patches 2013-09-11 12:16:09 +0000
4@@ -7,3 +7,4 @@
5 0b190b7114c816689eeb8478ea5151732bc7a5de_backport.patch
6 81a9dd71b9ce60ab4cae629b67d6f26ebdeb19db_backport.patch
7 rendering_performance_fix_lp1092358.patch
8+qtquick_delegate_creation_range_itemviews.patch
9
10=== modified file 'debian/changelog'
11--- debian/changelog 2013-07-08 07:51:02 +0000
12+++ debian/changelog 2013-09-11 12:16:09 +0000
13@@ -1,3 +1,10 @@
14+qtdeclarative-opensource-src (5.0.2-6ubuntu2) saucy; urgency=low
15+
16+ * Add qtquick_delegate_creation_range_itemviews.patch to patchset.
17+ (LP: #1217924)
18+
19+ -- Michał Sawicz <michal.sawicz@canonical.com> Wed, 11 Sep 2013 14:03:31 +0200
20+
21 qtdeclarative-opensource-src (5.0.2-6ubuntu1) saucy; urgency=low
22
23 [ Timo Jyrinki ]
24
25=== added file 'debian/patches/qtquick_delegate_creation_range_itemviews.patch'
26--- debian/patches/qtquick_delegate_creation_range_itemviews.patch 1970-01-01 00:00:00 +0000
27+++ debian/patches/qtquick_delegate_creation_range_itemviews.patch 2013-09-11 12:16:09 +0000
28@@ -0,0 +1,565 @@
29+commit e16ffd2ac3f842ec4e2e4ba8f925b03cdcdbee04
30+Author: Albert Astals Cid <albert.astals@canonical.com>
31+Date: Wed Jul 10 12:17:16 2013 +0200
32+
33+ Add the possibility of specifying the delegate creation range
34+
35+ For itemviews that are inside itemviews using the contentY/height of the
36+ itemview is not a good idea since it means you create all the items at
37+ once. This adds two new properties that let you specify the
38+ range where delegate creation should happen
39+
40+ Task-number: QTBUG-32338
41+
42+ Change-Id: Idc6c257ddbeac81412444deaa164ea847ffbc373
43+
44+--- a/src/quick/items/qquickgridview.cpp
45++++ b/src/quick/items/qquickgridview.cpp
46+@@ -652,8 +652,8 @@
47+ if (colPos != col * colSize()) {
48+ colPos = col * colSize();
49+ firstItem->setPosition(colPos, rowPos);
50+- firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
51+ }
52++ firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
53+ for (int i = 1; i < visibleItems.count(); ++i) {
54+ FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i));
55+ if (++col >= columns) {
56+--- a/src/quick/items/qquickitemview.cpp
57++++ b/src/quick/items/qquickitemview.cpp
58+@@ -699,6 +699,70 @@
59+ }
60+ }
61+
62++qreal QQuickItemView::delegateCreationBegin() const
63++{
64++ Q_D(const QQuickItemView);
65++ return d->delegateCreationBegin;
66++}
67++
68++void QQuickItemView::setDelegateCreationBegin(qreal begin)
69++{
70++ Q_D(QQuickItemView);
71++ d->delegateCreationBeginValid = true;
72++ if (d->delegateCreationBegin == begin)
73++ return;
74++ d->delegateCreationBegin = begin;
75++ if (isComponentComplete()) {
76++ d->forceLayoutPolish();
77++ }
78++ emit delegateCreationBeginChanged();
79++}
80++
81++void QQuickItemView::resetDelegateCreationBegin()
82++{
83++ Q_D(QQuickItemView);
84++ d->delegateCreationBeginValid = false;
85++ if (d->delegateCreationBegin == 0)
86++ return;
87++ d->delegateCreationBegin = 0;
88++ if (isComponentComplete()) {
89++ d->forceLayoutPolish();
90++ }
91++ emit delegateCreationBeginChanged();
92++}
93++
94++qreal QQuickItemView::delegateCreationEnd() const
95++{
96++ Q_D(const QQuickItemView);
97++ return d->delegateCreationEnd;
98++}
99++
100++void QQuickItemView::setDelegateCreationEnd(qreal end)
101++{
102++ Q_D(QQuickItemView);
103++ d->delegateCreationEndValid = true;
104++ if (d->delegateCreationEnd == end)
105++ return;
106++ d->delegateCreationEnd = end;
107++ if (isComponentComplete()) {
108++ d->forceLayoutPolish();
109++ }
110++ emit delegateCreationEndChanged();
111++}
112++
113++void QQuickItemView::resetDelegateCreationEnd()
114++{
115++ Q_D(QQuickItemView);
116++ d->delegateCreationEndValid = false;
117++ if (d->delegateCreationEnd == 0)
118++ return;
119++ d->delegateCreationEnd = 0;
120++ if (isComponentComplete()) {
121++ d->forceLayoutPolish();
122++ }
123++ emit delegateCreationEndChanged();
124++}
125++
126+ QQuickTransition *QQuickItemView::populateTransition() const
127+ {
128+ Q_D(const QQuickItemView);
129+@@ -1432,6 +1496,7 @@
130+ , highlightRange(QQuickItemView::NoHighlightRange)
131+ , highlightRangeStart(0), highlightRangeEnd(0)
132+ , highlightMoveDuration(150)
133++ , delegateCreationBegin(0), delegateCreationEnd(0)
134+ , headerComponent(0), header(0), footerComponent(0), footer(0)
135+ , transitioner(0)
136+ , minExtent(0), maxExtent(0)
137+@@ -1440,6 +1505,7 @@
138+ , haveHighlightRange(false), autoHighlight(true), highlightRangeStartValid(false), highlightRangeEndValid(false)
139+ , fillCacheBuffer(false), inRequest(false)
140+ , runDelayedRemoveTransition(false)
141++ , delegateCreationBeginValid(false), delegateCreationEndValid(false)
142+ {
143+ bufferPause.addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
144+ bufferPause.setLoopCount(1);
145+@@ -1660,11 +1726,15 @@
146+
147+ void QQuickItemViewPrivate::refill()
148+ {
149+- qreal s = qMax(size(), qreal(0.));
150+- if (isContentFlowReversed())
151+- refill(-position()-s, -position());
152+- else
153+- refill(position(), position()+s);
154++ if (delegateCreationBeginValid && delegateCreationEndValid) {
155++ refill(delegateCreationBegin, delegateCreationEnd);
156++ } else {
157++ qreal s = qMax(size(), qreal(0.));
158++ if (isContentFlowReversed())
159++ refill(-position()-s, -position());
160++ else
161++ refill(position(), position()+s);
162++ }
163+ }
164+
165+ void QQuickItemViewPrivate::refill(qreal from, qreal to)
166+--- a/src/quick/items/qquickitemview_p.h
167++++ b/src/quick/items/qquickitemview_p.h
168+@@ -91,6 +91,8 @@
169+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged RESET resetPreferredHighlightBegin)
170+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd)
171+ Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
172++ Q_PROPERTY(qreal delegateCreationBegin READ delegateCreationBegin WRITE setDelegateCreationBegin NOTIFY delegateCreationBeginChanged RESET resetDelegateCreationBegin)
173++ Q_PROPERTY(qreal delegateCreationEnd READ delegateCreationEnd WRITE setDelegateCreationEnd NOTIFY delegateCreationEndChanged RESET resetDelegateCreationEnd)
174+
175+ Q_ENUMS(HighlightRangeMode)
176+ Q_ENUMS(PositionMode)
177+@@ -197,6 +199,14 @@
178+ int highlightMoveDuration() const;
179+ virtual void setHighlightMoveDuration(int);
180+
181++ qreal delegateCreationBegin() const;
182++ void setDelegateCreationBegin(qreal);
183++ Q_INVOKABLE void resetDelegateCreationBegin();
184++
185++ qreal delegateCreationEnd() const;
186++ void setDelegateCreationEnd(qreal);
187++ Q_INVOKABLE void resetDelegateCreationEnd();
188++
189+ enum PositionMode { Beginning, Center, End, Visible, Contain, SnapPosition };
190+
191+ Q_INVOKABLE void positionViewAtIndex(int index, int mode);
192+@@ -246,6 +256,8 @@
193+ void preferredHighlightBeginChanged();
194+ void preferredHighlightEndChanged();
195+ void highlightMoveDurationChanged();
196++ void delegateCreationBeginChanged();
197++ void delegateCreationEndChanged();
198+
199+ protected:
200+ virtual void updatePolish();
201+--- a/src/quick/items/qquickitemview_p_p.h
202++++ b/src/quick/items/qquickitemview_p_p.h
203+@@ -118,7 +118,7 @@
204+ };
205+
206+
207+-class QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener
208++class Q_AUTOTEST_EXPORT QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener
209+ {
210+ Q_DECLARE_PUBLIC(QQuickItemView)
211+ public:
212+@@ -278,6 +278,8 @@
213+ qreal highlightRangeStart;
214+ qreal highlightRangeEnd;
215+ int highlightMoveDuration;
216++ qreal delegateCreationBegin;
217++ qreal delegateCreationEnd;
218+
219+ QQmlComponent *headerComponent;
220+ FxViewItem *header;
221+@@ -309,6 +311,8 @@
222+ bool fillCacheBuffer : 1;
223+ bool inRequest : 1;
224+ bool runDelayedRemoveTransition : 1;
225++ bool delegateCreationBeginValid : 1;
226++ bool delegateCreationEndValid : 1;
227+
228+ protected:
229+ virtual Qt::Orientation layoutOrientation() const = 0;
230+--- /dev/null
231++++ b/tests/auto/quick/qquickgridview/data/delegateCreationRange.qml
232+@@ -0,0 +1,89 @@
233++
234++import QtQuick 2.0
235++
236++ListView {
237++ id: list
238++ width: 400
239++ height: 600
240++ model: ListModel {
241++ ListElement { kind: "Bought" }
242++ ListElement { kind: "Available To Buy" }
243++ }
244++
245++ delegate: GridView {
246++ id: grid
247++ objectName: "grid" + index
248++ height: Math.ceil(count / (parent.width / cellWidth)) * cellHeight / 1
249++ width: parent.width
250++ interactive: false
251++ property int count: {
252++ if (grid.foo == 0) return 50;
253++ else return 100;
254++ }
255++ cellHeight: {
256++ if (grid.foo == 0) return 200;
257++ else return 100;
258++ }
259++ cellWidth: cellHeight
260++ model: count
261++ property int foo: index
262++ property bool enableRange: true
263++ onEnableRangeChanged: updatedDelegateCreationRange();
264++
265++ delegate: Item {
266++ width: cellWidth
267++ height: cellHeight
268++ Rectangle {
269++ width: parent.width - 20
270++ height: parent.height - 20
271++ anchors.centerIn: parent
272++ color: {
273++ if (grid.foo == 0) return Math.random() * 2 > 1 ? "green" : "yellow";
274++ else return Math.random() * 2 > 1 ? "red" : "blue";
275++ }
276++ Text {
277++ text: index
278++ }
279++ }
280++ }
281++
282++ delegateCreationBegin: enableRange ? 0 : undefined
283++ delegateCreationEnd: enableRange ? 0 : undefined
284++
285++ function updatedDelegateCreationRange() {
286++ if (!enableRange) {
287++ delegateCreationBegin = undefined
288++ delegateCreationEnd = undefined
289++ return;
290++ }
291++
292++ if (list.contentY + list.height <= y) {
293++ // Not visible
294++ delegateCreationBegin = 0
295++ delegateCreationEnd = 0
296++ } else if (y + height <= list.contentY) {
297++ // Not visible
298++ delegateCreationBegin = height
299++ delegateCreationEnd = height
300++ } else {
301++ delegateCreationBegin = Math.max(list.contentY - y, 0)
302++ delegateCreationEnd = Math.min(list.contentY + list.height - y, height)
303++ }
304++ }
305++
306++ Component.onCompleted: updatedDelegateCreationRange();
307++ Connections {
308++ target: list
309++ onContentYChanged: updatedDelegateCreationRange();
310++ onHeightChanged: updatedDelegateCreationRange();
311++ }
312++ }
313++
314++ section.property: "kind"
315++ section.delegate: Text {
316++ height: 40
317++ font.pixelSize: 30
318++ text: section
319++ }
320++
321++}
322+\ No newline at end of file
323+--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
324++++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
325+@@ -50,6 +50,8 @@
326+ #include <QtQml/qqmlcontext.h>
327+ #include <QtQuick/private/qquickitem_p.h>
328+ #include <QtQuick/private/qquickgridview_p.h>
329++#include <QtQuick/private/qquicklistview_p.h>
330++#include <QtQuick/private/qquickitemview_p_p.h>
331+ #include <QtQuick/private/qquicktext_p.h>
332+ #include <QtQuick/private/qquickvisualitemmodel_p.h>
333+ #include <QtQml/private/qquicklistmodel_p.h>
334+@@ -208,6 +210,8 @@
335+ void moved_topToBottom_RtL_BtT();
336+ void moved_topToBottom_RtL_BtT_data();
337+
338++ void testDelegateCreationRange();
339++
340+ private:
341+ QList<int> toIntList(const QVariantList &list);
342+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
343+@@ -6254,6 +6258,69 @@
344+ moved_defaultLayout_data();
345+ }
346+
347++void tst_QQuickGridView::testDelegateCreationRange()
348++{
349++ QQuickView *window = getView();
350++ window->setSource(testFileUrl("delegateCreationRange.qml"));
351++ window->show();
352++ QTest::qWaitForWindowActive(window);
353++
354++ QQuickListView *listview = dynamic_cast<QQuickListView*>(window->rootObject());
355++ QVERIFY(listview != 0);
356++ QQuickGridView *gridview0 = findItem<QQuickGridView>(window->rootObject(), "grid0");
357++ QVERIFY(gridview0 != 0);
358++ QQuickItemViewPrivate *gridview0Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(gridview0));
359++ QVERIFY(gridview0Priv != 0);
360++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
361++ gridview0->setProperty("enableRange", false);
362++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
363++ gridview0->setProperty("enableRange", true);
364++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
365++
366++ listview->setContentY(1200);
367++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 17);
368++ gridview0->setProperty("enableRange", false);
369++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
370++ gridview0->setProperty("enableRange", true);
371++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 17);
372++
373++ listview->setContentY(6000);
374++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 5);
375++ gridview0->setProperty("enableRange", false);
376++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
377++ gridview0->setProperty("enableRange", true);
378++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 5);
379++
380++ QQuickGridView *gridview1 = findItem<QQuickGridView>(window->rootObject(), "grid1");
381++ QVERIFY(gridview1 != 0);
382++ QQuickItemViewPrivate *gridview1Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(gridview1));
383++
384++ QTRY_COMPARE(gridview1Priv->visibleItems.count(), 58);
385++ gridview1->setProperty("enableRange", false);
386++ QTRY_COMPARE(gridview1Priv->visibleItems.count(), 100);
387++ gridview1->setProperty("enableRange", true);
388++ QTRY_COMPARE(gridview1Priv->visibleItems.count(), 58);
389++
390++ listview->setContentY(0);
391++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
392++ gridview0->setProperty("enableRange", false);
393++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
394++ gridview0->setProperty("enableRange", true);
395++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
396++
397++ listview->setContentY(800);
398++ QTest::qWait(100);
399++ listview->setContentY(600);
400++ QTest::qWait(100);
401++ listview->setContentY(400);
402++ QTest::qWait(100);
403++ listview->setContentY(200);
404++ QTest::qWait(100);
405++ listview->setContentY(0);
406++
407++ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
408++ QVERIFY(!QQuickItemPrivate::get(gridview0Priv->visibleItems[0]->item)->culled);
409++}
410+
411+ QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
412+ {
413+--- /dev/null
414++++ b/tests/auto/quick/qquicklistview/data/delegateCreationRange.qml
415+@@ -0,0 +1,84 @@
416++
417++import QtQuick 2.0
418++
419++ListView {
420++ id: list
421++ width: 400
422++ height: 600
423++ model: ListModel {
424++ ListElement { kind: "Bought" }
425++ ListElement { kind: "Available To Buy" }
426++ }
427++
428++ delegate: ListView {
429++ id: innerList
430++ objectName: "list" + index
431++ height: count * itemHeight
432++ width: parent.width
433++ interactive: false
434++ property int count: {
435++ if (innerList.foo == 0) return 50;
436++ else return 100;
437++ }
438++ property int itemHeight: innerList.foo == 0 ? 200 : 50;
439++ model: count
440++ property int foo: index
441++ property bool enableRange: true
442++ onEnableRangeChanged: updatedDelegateCreationRange();
443++
444++ delegate: Item {
445++ width: parent.width
446++ height: innerList.itemHeight
447++ Rectangle {
448++ width: parent.width - 20
449++ height: parent.height - 20
450++ anchors.centerIn: parent
451++ color: {
452++ if (innerList.foo == 0) return Math.random() * 2 > 1 ? "green" : "yellow";
453++ else return Math.random() * 2 > 1 ? "red" : "blue";
454++ }
455++ Text {
456++ text: index
457++ }
458++ }
459++ }
460++
461++ delegateCreationBegin: enableRange ? 0 : undefined
462++ delegateCreationEnd: enableRange ? 0 : undefined
463++
464++ function updatedDelegateCreationRange() {
465++ if (!enableRange) {
466++ delegateCreationBegin = undefined
467++ delegateCreationEnd = undefined
468++ return;
469++ }
470++
471++ if (list.contentY + list.height <= y) {
472++ // Not visible
473++ delegateCreationBegin = 0
474++ delegateCreationEnd = 0
475++ } else if (y + height <= list.contentY) {
476++ // Not visible
477++ delegateCreationBegin = height
478++ delegateCreationEnd = height
479++ } else {
480++ delegateCreationBegin = Math.max(list.contentY - y, 0)
481++ delegateCreationEnd = Math.min(list.contentY + list.height - y, height)
482++ }
483++ }
484++
485++ Component.onCompleted: updatedDelegateCreationRange();
486++ Connections {
487++ target: list
488++ onContentYChanged: updatedDelegateCreationRange();
489++ onHeightChanged: updatedDelegateCreationRange();
490++ }
491++ }
492++
493++ section.property: "kind"
494++ section.delegate: Text {
495++ height: 40
496++ font.pixelSize: 30
497++ text: section
498++ }
499++}
500+\ No newline at end of file
501+--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
502++++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
503+@@ -47,6 +47,7 @@
504+ #include <QtQml/qqmlexpression.h>
505+ #include <QtQml/qqmlincubator.h>
506+ #include <QtQuick/private/qquicklistview_p.h>
507++#include <QtQuick/private/qquickitemview_p_p.h>
508+ #include <QtQuick/private/qquicktext_p.h>
509+ #include <QtQuick/private/qquickvisualitemmodel_p.h>
510+ #include <QtQml/private/qquicklistmodel_p.h>
511+@@ -208,6 +209,8 @@
512+ void parentBinding();
513+ void delayedChanges_QTBUG_30555();
514+
515++ void testDelegateCreationRange();
516++
517+ private:
518+ template <class T> void items(const QUrl &source);
519+ template <class T> void changed(const QUrl &source);
520+@@ -6851,6 +6854,73 @@
521+ delete window;
522+ }
523+
524++void tst_QQuickListView::testDelegateCreationRange()
525++{
526++ QQuickView *window = getView();
527++ window->setSource(testFileUrl("delegateCreationRange.qml"));
528++ window->show();
529++ QTest::qWaitForWindowActive(window);
530++
531++ QQuickListView *listview = dynamic_cast<QQuickListView*>(window->rootObject());
532++ QVERIFY(listview != 0);
533++ QQuickListView *listview0 = findItem<QQuickListView>(window->rootObject(), "list0");
534++ QVERIFY(listview0 != 0);
535++ QQuickItemViewPrivate *listview0Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(listview0));
536++ QVERIFY(listview0Priv != 0);
537++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
538++ listview0->setProperty("enableRange", false);
539++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
540++ listview0->setProperty("enableRange", true);
541++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
542++
543++ listview->setContentY(6000);
544++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 7);
545++ listview0->setProperty("enableRange", false);
546++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
547++ listview0->setProperty("enableRange", true);
548++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 7);
549++
550++ listview->setContentY(11000);
551++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 2);
552++ listview0->setProperty("enableRange", false);
553++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
554++ listview0->setProperty("enableRange", true);
555++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 2);
556++
557++ QQuickListView *listview1 = findItem<QQuickListView>(window->rootObject(), "list1");
558++ QVERIFY(listview1 != 0);
559++ QQuickItemViewPrivate *listview1Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(listview1));
560++
561++ QTRY_COMPARE(listview1Priv->visibleItems.count(), 25);
562++ listview1->setProperty("enableRange", false);
563++ QTRY_COMPARE(listview1Priv->visibleItems.count(), 100);
564++ listview1->setProperty("enableRange", true);
565++ // For some reason in this case it goes back to 26 instead of 25
566++ // did not want to investigate it further since it would mean
567++ // changing more things in ListView inner code
568++ QTRY_COMPARE(listview1Priv->visibleItems.count(), 26);
569++
570++ listview->setContentY(0);
571++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
572++ listview0->setProperty("enableRange", false);
573++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
574++ listview0->setProperty("enableRange", true);
575++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
576++
577++ listview->setContentY(800);
578++ QTest::qWait(100);
579++ listview->setContentY(600);
580++ QTest::qWait(100);
581++ listview->setContentY(400);
582++ QTest::qWait(100);
583++ listview->setContentY(200);
584++ QTest::qWait(100);
585++ listview->setContentY(0);
586++
587++ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
588++ QVERIFY(!QQuickItemPrivate::get(listview0Priv->visibleItems[0]->item)->culled);
589++}
590++
591+ QTEST_MAIN(tst_QQuickListView)
592+
593+ #include "tst_qquicklistview.moc"
594
595=== modified file 'debian/patches/series'
596--- debian/patches/series 2013-07-08 07:51:02 +0000
597+++ debian/patches/series 2013-09-11 12:16:09 +0000
598@@ -10,3 +10,4 @@
599
600 # ubuntu
601 rendering_performance_fix_lp1092358.patch
602+qtquick_delegate_creation_range_itemviews.patch
603
604=== modified file 'src/quick/items/qquickgridview.cpp'
605--- src/quick/items/qquickgridview.cpp 2013-04-29 16:27:13 +0000
606+++ src/quick/items/qquickgridview.cpp 2013-09-11 12:16:09 +0000
607@@ -652,8 +652,8 @@
608 if (colPos != col * colSize()) {
609 colPos = col * colSize();
610 firstItem->setPosition(colPos, rowPos);
611- firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
612 }
613+ firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
614 for (int i = 1; i < visibleItems.count(); ++i) {
615 FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i));
616 if (++col >= columns) {
617
618=== modified file 'src/quick/items/qquickitemview.cpp'
619--- src/quick/items/qquickitemview.cpp 2013-04-29 16:27:13 +0000
620+++ src/quick/items/qquickitemview.cpp 2013-09-11 12:16:09 +0000
621@@ -699,6 +699,70 @@
622 }
623 }
624
625+qreal QQuickItemView::delegateCreationBegin() const
626+{
627+ Q_D(const QQuickItemView);
628+ return d->delegateCreationBegin;
629+}
630+
631+void QQuickItemView::setDelegateCreationBegin(qreal begin)
632+{
633+ Q_D(QQuickItemView);
634+ d->delegateCreationBeginValid = true;
635+ if (d->delegateCreationBegin == begin)
636+ return;
637+ d->delegateCreationBegin = begin;
638+ if (isComponentComplete()) {
639+ d->forceLayoutPolish();
640+ }
641+ emit delegateCreationBeginChanged();
642+}
643+
644+void QQuickItemView::resetDelegateCreationBegin()
645+{
646+ Q_D(QQuickItemView);
647+ d->delegateCreationBeginValid = false;
648+ if (d->delegateCreationBegin == 0)
649+ return;
650+ d->delegateCreationBegin = 0;
651+ if (isComponentComplete()) {
652+ d->forceLayoutPolish();
653+ }
654+ emit delegateCreationBeginChanged();
655+}
656+
657+qreal QQuickItemView::delegateCreationEnd() const
658+{
659+ Q_D(const QQuickItemView);
660+ return d->delegateCreationEnd;
661+}
662+
663+void QQuickItemView::setDelegateCreationEnd(qreal end)
664+{
665+ Q_D(QQuickItemView);
666+ d->delegateCreationEndValid = true;
667+ if (d->delegateCreationEnd == end)
668+ return;
669+ d->delegateCreationEnd = end;
670+ if (isComponentComplete()) {
671+ d->forceLayoutPolish();
672+ }
673+ emit delegateCreationEndChanged();
674+}
675+
676+void QQuickItemView::resetDelegateCreationEnd()
677+{
678+ Q_D(QQuickItemView);
679+ d->delegateCreationEndValid = false;
680+ if (d->delegateCreationEnd == 0)
681+ return;
682+ d->delegateCreationEnd = 0;
683+ if (isComponentComplete()) {
684+ d->forceLayoutPolish();
685+ }
686+ emit delegateCreationEndChanged();
687+}
688+
689 QQuickTransition *QQuickItemView::populateTransition() const
690 {
691 Q_D(const QQuickItemView);
692@@ -1432,6 +1496,7 @@
693 , highlightRange(QQuickItemView::NoHighlightRange)
694 , highlightRangeStart(0), highlightRangeEnd(0)
695 , highlightMoveDuration(150)
696+ , delegateCreationBegin(0), delegateCreationEnd(0)
697 , headerComponent(0), header(0), footerComponent(0), footer(0)
698 , transitioner(0)
699 , minExtent(0), maxExtent(0)
700@@ -1440,6 +1505,7 @@
701 , haveHighlightRange(false), autoHighlight(true), highlightRangeStartValid(false), highlightRangeEndValid(false)
702 , fillCacheBuffer(false), inRequest(false)
703 , runDelayedRemoveTransition(false)
704+ , delegateCreationBeginValid(false), delegateCreationEndValid(false)
705 {
706 bufferPause.addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
707 bufferPause.setLoopCount(1);
708@@ -1660,11 +1726,15 @@
709
710 void QQuickItemViewPrivate::refill()
711 {
712- qreal s = qMax(size(), qreal(0.));
713- if (isContentFlowReversed())
714- refill(-position()-s, -position());
715- else
716- refill(position(), position()+s);
717+ if (delegateCreationBeginValid && delegateCreationEndValid) {
718+ refill(delegateCreationBegin, delegateCreationEnd);
719+ } else {
720+ qreal s = qMax(size(), qreal(0.));
721+ if (isContentFlowReversed())
722+ refill(-position()-s, -position());
723+ else
724+ refill(position(), position()+s);
725+ }
726 }
727
728 void QQuickItemViewPrivate::refill(qreal from, qreal to)
729
730=== modified file 'src/quick/items/qquickitemview_p.h'
731--- src/quick/items/qquickitemview_p.h 2013-04-29 16:27:13 +0000
732+++ src/quick/items/qquickitemview_p.h 2013-09-11 12:16:09 +0000
733@@ -91,6 +91,8 @@
734 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged RESET resetPreferredHighlightBegin)
735 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd)
736 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
737+ Q_PROPERTY(qreal delegateCreationBegin READ delegateCreationBegin WRITE setDelegateCreationBegin NOTIFY delegateCreationBeginChanged RESET resetDelegateCreationBegin)
738+ Q_PROPERTY(qreal delegateCreationEnd READ delegateCreationEnd WRITE setDelegateCreationEnd NOTIFY delegateCreationEndChanged RESET resetDelegateCreationEnd)
739
740 Q_ENUMS(HighlightRangeMode)
741 Q_ENUMS(PositionMode)
742@@ -197,6 +199,14 @@
743 int highlightMoveDuration() const;
744 virtual void setHighlightMoveDuration(int);
745
746+ qreal delegateCreationBegin() const;
747+ void setDelegateCreationBegin(qreal);
748+ Q_INVOKABLE void resetDelegateCreationBegin();
749+
750+ qreal delegateCreationEnd() const;
751+ void setDelegateCreationEnd(qreal);
752+ Q_INVOKABLE void resetDelegateCreationEnd();
753+
754 enum PositionMode { Beginning, Center, End, Visible, Contain, SnapPosition };
755
756 Q_INVOKABLE void positionViewAtIndex(int index, int mode);
757@@ -246,6 +256,8 @@
758 void preferredHighlightBeginChanged();
759 void preferredHighlightEndChanged();
760 void highlightMoveDurationChanged();
761+ void delegateCreationBeginChanged();
762+ void delegateCreationEndChanged();
763
764 protected:
765 virtual void updatePolish();
766
767=== modified file 'src/quick/items/qquickitemview_p_p.h'
768--- src/quick/items/qquickitemview_p_p.h 2013-04-29 16:27:13 +0000
769+++ src/quick/items/qquickitemview_p_p.h 2013-09-11 12:16:09 +0000
770@@ -118,7 +118,7 @@
771 };
772
773
774-class QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener
775+class Q_AUTOTEST_EXPORT QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener, public QAnimationJobChangeListener
776 {
777 Q_DECLARE_PUBLIC(QQuickItemView)
778 public:
779@@ -278,6 +278,8 @@
780 qreal highlightRangeStart;
781 qreal highlightRangeEnd;
782 int highlightMoveDuration;
783+ qreal delegateCreationBegin;
784+ qreal delegateCreationEnd;
785
786 QQmlComponent *headerComponent;
787 FxViewItem *header;
788@@ -309,6 +311,8 @@
789 bool fillCacheBuffer : 1;
790 bool inRequest : 1;
791 bool runDelayedRemoveTransition : 1;
792+ bool delegateCreationBeginValid : 1;
793+ bool delegateCreationEndValid : 1;
794
795 protected:
796 virtual Qt::Orientation layoutOrientation() const = 0;
797
798=== added file 'tests/auto/quick/qquickgridview/data/delegateCreationRange.qml'
799--- tests/auto/quick/qquickgridview/data/delegateCreationRange.qml 1970-01-01 00:00:00 +0000
800+++ tests/auto/quick/qquickgridview/data/delegateCreationRange.qml 2013-09-11 12:16:09 +0000
801@@ -0,0 +1,89 @@
802+
803+import QtQuick 2.0
804+
805+ListView {
806+ id: list
807+ width: 400
808+ height: 600
809+ model: ListModel {
810+ ListElement { kind: "Bought" }
811+ ListElement { kind: "Available To Buy" }
812+ }
813+
814+ delegate: GridView {
815+ id: grid
816+ objectName: "grid" + index
817+ height: Math.ceil(count / (parent.width / cellWidth)) * cellHeight / 1
818+ width: parent.width
819+ interactive: false
820+ property int count: {
821+ if (grid.foo == 0) return 50;
822+ else return 100;
823+ }
824+ cellHeight: {
825+ if (grid.foo == 0) return 200;
826+ else return 100;
827+ }
828+ cellWidth: cellHeight
829+ model: count
830+ property int foo: index
831+ property bool enableRange: true
832+ onEnableRangeChanged: updatedDelegateCreationRange();
833+
834+ delegate: Item {
835+ width: cellWidth
836+ height: cellHeight
837+ Rectangle {
838+ width: parent.width - 20
839+ height: parent.height - 20
840+ anchors.centerIn: parent
841+ color: {
842+ if (grid.foo == 0) return Math.random() * 2 > 1 ? "green" : "yellow";
843+ else return Math.random() * 2 > 1 ? "red" : "blue";
844+ }
845+ Text {
846+ text: index
847+ }
848+ }
849+ }
850+
851+ delegateCreationBegin: enableRange ? 0 : undefined
852+ delegateCreationEnd: enableRange ? 0 : undefined
853+
854+ function updatedDelegateCreationRange() {
855+ if (!enableRange) {
856+ delegateCreationBegin = undefined
857+ delegateCreationEnd = undefined
858+ return;
859+ }
860+
861+ if (list.contentY + list.height <= y) {
862+ // Not visible
863+ delegateCreationBegin = 0
864+ delegateCreationEnd = 0
865+ } else if (y + height <= list.contentY) {
866+ // Not visible
867+ delegateCreationBegin = height
868+ delegateCreationEnd = height
869+ } else {
870+ delegateCreationBegin = Math.max(list.contentY - y, 0)
871+ delegateCreationEnd = Math.min(list.contentY + list.height - y, height)
872+ }
873+ }
874+
875+ Component.onCompleted: updatedDelegateCreationRange();
876+ Connections {
877+ target: list
878+ onContentYChanged: updatedDelegateCreationRange();
879+ onHeightChanged: updatedDelegateCreationRange();
880+ }
881+ }
882+
883+ section.property: "kind"
884+ section.delegate: Text {
885+ height: 40
886+ font.pixelSize: 30
887+ text: section
888+ }
889+
890+}
891\ No newline at end of file
892
893=== modified file 'tests/auto/quick/qquickgridview/tst_qquickgridview.cpp'
894--- tests/auto/quick/qquickgridview/tst_qquickgridview.cpp 2013-04-29 16:27:13 +0000
895+++ tests/auto/quick/qquickgridview/tst_qquickgridview.cpp 2013-09-11 12:16:09 +0000
896@@ -50,6 +50,8 @@
897 #include <QtQml/qqmlcontext.h>
898 #include <QtQuick/private/qquickitem_p.h>
899 #include <QtQuick/private/qquickgridview_p.h>
900+#include <QtQuick/private/qquicklistview_p.h>
901+#include <QtQuick/private/qquickitemview_p_p.h>
902 #include <QtQuick/private/qquicktext_p.h>
903 #include <QtQuick/private/qquickvisualitemmodel_p.h>
904 #include <QtQml/private/qquicklistmodel_p.h>
905@@ -208,6 +210,8 @@
906 void moved_topToBottom_RtL_BtT();
907 void moved_topToBottom_RtL_BtT_data();
908
909+ void testDelegateCreationRange();
910+
911 private:
912 QList<int> toIntList(const QVariantList &list);
913 void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
914@@ -6254,6 +6258,69 @@
915 moved_defaultLayout_data();
916 }
917
918+void tst_QQuickGridView::testDelegateCreationRange()
919+{
920+ QQuickView *window = getView();
921+ window->setSource(testFileUrl("delegateCreationRange.qml"));
922+ window->show();
923+ QTest::qWaitForWindowActive(window);
924+
925+ QQuickListView *listview = dynamic_cast<QQuickListView*>(window->rootObject());
926+ QVERIFY(listview != 0);
927+ QQuickGridView *gridview0 = findItem<QQuickGridView>(window->rootObject(), "grid0");
928+ QVERIFY(gridview0 != 0);
929+ QQuickItemViewPrivate *gridview0Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(gridview0));
930+ QVERIFY(gridview0Priv != 0);
931+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
932+ gridview0->setProperty("enableRange", false);
933+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
934+ gridview0->setProperty("enableRange", true);
935+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
936+
937+ listview->setContentY(1200);
938+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 17);
939+ gridview0->setProperty("enableRange", false);
940+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
941+ gridview0->setProperty("enableRange", true);
942+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 17);
943+
944+ listview->setContentY(6000);
945+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 5);
946+ gridview0->setProperty("enableRange", false);
947+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
948+ gridview0->setProperty("enableRange", true);
949+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 5);
950+
951+ QQuickGridView *gridview1 = findItem<QQuickGridView>(window->rootObject(), "grid1");
952+ QVERIFY(gridview1 != 0);
953+ QQuickItemViewPrivate *gridview1Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(gridview1));
954+
955+ QTRY_COMPARE(gridview1Priv->visibleItems.count(), 58);
956+ gridview1->setProperty("enableRange", false);
957+ QTRY_COMPARE(gridview1Priv->visibleItems.count(), 100);
958+ gridview1->setProperty("enableRange", true);
959+ QTRY_COMPARE(gridview1Priv->visibleItems.count(), 58);
960+
961+ listview->setContentY(0);
962+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
963+ gridview0->setProperty("enableRange", false);
964+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 50);
965+ gridview0->setProperty("enableRange", true);
966+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
967+
968+ listview->setContentY(800);
969+ QTest::qWait(100);
970+ listview->setContentY(600);
971+ QTest::qWait(100);
972+ listview->setContentY(400);
973+ QTest::qWait(100);
974+ listview->setContentY(200);
975+ QTest::qWait(100);
976+ listview->setContentY(0);
977+
978+ QTRY_COMPARE(gridview0Priv->visibleItems.count(), 11);
979+ QVERIFY(!QQuickItemPrivate::get(gridview0Priv->visibleItems[0]->item)->culled);
980+}
981
982 QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
983 {
984
985=== added file 'tests/auto/quick/qquicklistview/data/delegateCreationRange.qml'
986--- tests/auto/quick/qquicklistview/data/delegateCreationRange.qml 1970-01-01 00:00:00 +0000
987+++ tests/auto/quick/qquicklistview/data/delegateCreationRange.qml 2013-09-11 12:16:09 +0000
988@@ -0,0 +1,84 @@
989+
990+import QtQuick 2.0
991+
992+ListView {
993+ id: list
994+ width: 400
995+ height: 600
996+ model: ListModel {
997+ ListElement { kind: "Bought" }
998+ ListElement { kind: "Available To Buy" }
999+ }
1000+
1001+ delegate: ListView {
1002+ id: innerList
1003+ objectName: "list" + index
1004+ height: count * itemHeight
1005+ width: parent.width
1006+ interactive: false
1007+ property int count: {
1008+ if (innerList.foo == 0) return 50;
1009+ else return 100;
1010+ }
1011+ property int itemHeight: innerList.foo == 0 ? 200 : 50;
1012+ model: count
1013+ property int foo: index
1014+ property bool enableRange: true
1015+ onEnableRangeChanged: updatedDelegateCreationRange();
1016+
1017+ delegate: Item {
1018+ width: parent.width
1019+ height: innerList.itemHeight
1020+ Rectangle {
1021+ width: parent.width - 20
1022+ height: parent.height - 20
1023+ anchors.centerIn: parent
1024+ color: {
1025+ if (innerList.foo == 0) return Math.random() * 2 > 1 ? "green" : "yellow";
1026+ else return Math.random() * 2 > 1 ? "red" : "blue";
1027+ }
1028+ Text {
1029+ text: index
1030+ }
1031+ }
1032+ }
1033+
1034+ delegateCreationBegin: enableRange ? 0 : undefined
1035+ delegateCreationEnd: enableRange ? 0 : undefined
1036+
1037+ function updatedDelegateCreationRange() {
1038+ if (!enableRange) {
1039+ delegateCreationBegin = undefined
1040+ delegateCreationEnd = undefined
1041+ return;
1042+ }
1043+
1044+ if (list.contentY + list.height <= y) {
1045+ // Not visible
1046+ delegateCreationBegin = 0
1047+ delegateCreationEnd = 0
1048+ } else if (y + height <= list.contentY) {
1049+ // Not visible
1050+ delegateCreationBegin = height
1051+ delegateCreationEnd = height
1052+ } else {
1053+ delegateCreationBegin = Math.max(list.contentY - y, 0)
1054+ delegateCreationEnd = Math.min(list.contentY + list.height - y, height)
1055+ }
1056+ }
1057+
1058+ Component.onCompleted: updatedDelegateCreationRange();
1059+ Connections {
1060+ target: list
1061+ onContentYChanged: updatedDelegateCreationRange();
1062+ onHeightChanged: updatedDelegateCreationRange();
1063+ }
1064+ }
1065+
1066+ section.property: "kind"
1067+ section.delegate: Text {
1068+ height: 40
1069+ font.pixelSize: 30
1070+ text: section
1071+ }
1072+}
1073\ No newline at end of file
1074
1075=== modified file 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp'
1076--- tests/auto/quick/qquicklistview/tst_qquicklistview.cpp 2013-04-29 16:27:13 +0000
1077+++ tests/auto/quick/qquicklistview/tst_qquicklistview.cpp 2013-09-11 12:16:09 +0000
1078@@ -47,6 +47,7 @@
1079 #include <QtQml/qqmlexpression.h>
1080 #include <QtQml/qqmlincubator.h>
1081 #include <QtQuick/private/qquicklistview_p.h>
1082+#include <QtQuick/private/qquickitemview_p_p.h>
1083 #include <QtQuick/private/qquicktext_p.h>
1084 #include <QtQuick/private/qquickvisualitemmodel_p.h>
1085 #include <QtQml/private/qquicklistmodel_p.h>
1086@@ -208,6 +209,8 @@
1087 void parentBinding();
1088 void delayedChanges_QTBUG_30555();
1089
1090+ void testDelegateCreationRange();
1091+
1092 private:
1093 template <class T> void items(const QUrl &source);
1094 template <class T> void changed(const QUrl &source);
1095@@ -6851,6 +6854,73 @@
1096 delete window;
1097 }
1098
1099+void tst_QQuickListView::testDelegateCreationRange()
1100+{
1101+ QQuickView *window = getView();
1102+ window->setSource(testFileUrl("delegateCreationRange.qml"));
1103+ window->show();
1104+ QTest::qWaitForWindowActive(window);
1105+
1106+ QQuickListView *listview = dynamic_cast<QQuickListView*>(window->rootObject());
1107+ QVERIFY(listview != 0);
1108+ QQuickListView *listview0 = findItem<QQuickListView>(window->rootObject(), "list0");
1109+ QVERIFY(listview0 != 0);
1110+ QQuickItemViewPrivate *listview0Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(listview0));
1111+ QVERIFY(listview0Priv != 0);
1112+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
1113+ listview0->setProperty("enableRange", false);
1114+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
1115+ listview0->setProperty("enableRange", true);
1116+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
1117+
1118+ listview->setContentY(6000);
1119+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 7);
1120+ listview0->setProperty("enableRange", false);
1121+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
1122+ listview0->setProperty("enableRange", true);
1123+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 7);
1124+
1125+ listview->setContentY(11000);
1126+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 2);
1127+ listview0->setProperty("enableRange", false);
1128+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
1129+ listview0->setProperty("enableRange", true);
1130+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 2);
1131+
1132+ QQuickListView *listview1 = findItem<QQuickListView>(window->rootObject(), "list1");
1133+ QVERIFY(listview1 != 0);
1134+ QQuickItemViewPrivate *listview1Priv = dynamic_cast<QQuickItemViewPrivate*>(QQuickItemPrivate::get(listview1));
1135+
1136+ QTRY_COMPARE(listview1Priv->visibleItems.count(), 25);
1137+ listview1->setProperty("enableRange", false);
1138+ QTRY_COMPARE(listview1Priv->visibleItems.count(), 100);
1139+ listview1->setProperty("enableRange", true);
1140+ // For some reason in this case it goes back to 26 instead of 25
1141+ // did not want to investigate it further since it would mean
1142+ // changing more things in ListView inner code
1143+ QTRY_COMPARE(listview1Priv->visibleItems.count(), 26);
1144+
1145+ listview->setContentY(0);
1146+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
1147+ listview0->setProperty("enableRange", false);
1148+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 50);
1149+ listview0->setProperty("enableRange", true);
1150+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
1151+
1152+ listview->setContentY(800);
1153+ QTest::qWait(100);
1154+ listview->setContentY(600);
1155+ QTest::qWait(100);
1156+ listview->setContentY(400);
1157+ QTest::qWait(100);
1158+ listview->setContentY(200);
1159+ QTest::qWait(100);
1160+ listview->setContentY(0);
1161+
1162+ QTRY_COMPARE(listview0Priv->visibleItems.count(), 5);
1163+ QVERIFY(!QQuickItemPrivate::get(listview0Priv->visibleItems[0]->item)->culled);
1164+}
1165+
1166 QTEST_MAIN(tst_QQuickListView)
1167
1168 #include "tst_qquicklistview.moc"

Subscribers

People subscribed via source and target branches