diff options
author | Stephen Kelly <ske@ableton.com> | 2016-06-01 11:40:45 +0200 |
---|---|---|
committer | Stephen Kelly <ske@ableton.com> | 2016-06-21 11:51:46 +0000 |
commit | 5d23470b8d0bacb0e0ba074672f94e526cc9e456 (patch) | |
tree | a58e6907367a59b74020dff0339763a5627b1a01 /tests | |
parent | 4c1dd3efb0a28c022e0968ba80737de8694c6e4c (diff) |
Report changes correctly when inserting into a ListView
Commit v5.6.0-beta1~7 (ListView: Sanitize visibleItems list after model
insertions, 2015-12-07) introduced sanitizing of the container of visibleItems,
but it did not affect the return value of the
QQuickListViewPrivate::applyInsertionChange
function. The return value is used in
QQuickItemViewPrivate::layout()
to determine whether the layouting should proceed, or an early return is
possible instead. If the layouting does not proceed, then the newly inserted
visible items do not get painted, resulting in the linked bug.
The return value of the
QQuickListViewPrivate::applyInsertionChange
function was previously determined by whether the new count of visible items is
greater than the previous count. After the sanitation in commit
v5.6.0-beta1~7, this numeric comparison is no longer a good indicator of
whether a repaint is needed. Change the return value to indicate whether new
items were inserted which are visible in a more-direct way.
Verify that visible items are initialized correctly in tests. They should not
be 'culled'. It is necessary to invoke the layout method first to clear the
forceLayout state. Two pre-existing tests fail before the fix in this patch.
Change-Id: I625f1e02bf7001834adb147161a1e478a0ce2a0d
Task-number: QTBUG-53263
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 19f4010f8c..48230891ba 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -633,6 +633,8 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v } listview->setContentY(contentY); + QQuickItemViewPrivate::get(listview)->layout(); + QList<QPair<QString, QString> > newData; for (int i=0; i<insertCount; i++) newData << qMakePair(QString("value %1").arg(i), QString::number(i)); @@ -654,6 +656,16 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v QCOMPARE(item0->y(), itemsOffsetAfterMove); #endif + QList<FxViewItem *> visibleItems = QQuickItemViewPrivate::get(listview)->visibleItems; + for (QList<FxViewItem *>::const_iterator itemIt = visibleItems.begin(); itemIt != visibleItems.end(); ++itemIt) + { + FxViewItem *item = *itemIt; + if (item->item->position().y() >= 0 && item->item->position().y() < listview->height()) + { + QVERIFY(!QQuickItemPrivate::get(item->item)->culled); + } + } + QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; for (int i=0; i<items.count(); i++) { @@ -774,6 +786,11 @@ void tst_QQuickListView::inserted_more_data() << 80.0 // show 4-19 << 20 << 3 << 0.0; + + QTest::newRow("add multiple, within visible, content at start") + << 0.0 + << 2 << 50 + << 0.0; } void tst_QQuickListView::insertBeforeVisible() |