diff options
author | Alberto Mardegan <mardy@users.sourceforge.net> | 2016-11-21 22:35:37 +0300 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@qt.io> | 2017-11-03 08:27:17 +0000 |
commit | 0d84aaf05c7306c8e39bac7acd7c85dc04358b17 (patch) | |
tree | cc3bbf5ff22800c6de650282f8eba2242e76f8e4 /tests/auto/quick/qquickgridview/tst_qquickgridview.cpp | |
parent | f64ef7ede82260b8c2740930c85e224229855da3 (diff) |
QQuickItemView: avoid wrong repositioning of removed items
If all the items currently in the view are being removed,
lastVisibleIndex will be -1. This caused an unwanted repositioning
of all the deleted items, which got moved to a wrong location.
Therefore, when all visible items are removed, we should avoid
recomputing any item's position.
Task-number: QTBUG-57225
Change-Id: I9909748a9cccb5e6a3726306e250921ce69fcba9
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickgridview/tst_qquickgridview.cpp')
-rw-r--r-- | tests/auto/quick/qquickgridview/tst_qquickgridview.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 2b14842658..7333cc3ceb 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -153,6 +153,7 @@ private slots: void multipleTransitions(); void multipleTransitions_data(); void multipleDisplaced(); + void regression_QTBUG_57225(); void inserted_leftToRight_RtL_TtB(); void inserted_leftToRight_RtL_TtB_data(); @@ -5798,6 +5799,36 @@ void tst_QQuickGridView::multipleDisplaced() delete window; } +void tst_QQuickGridView::regression_QTBUG_57225() +{ + // deleting all visible items should not cause a repositioning of said items. + + QaimModel model; + for (int i = 0; i < 20; i++) + model.addItem("Original item" + QString::number(i), ""); + + QQuickView *window = createView(); + QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + window->setSource(testFileUrl("qtbug57225.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid"); + QVERIFY(gridview != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + model.removeItems(0, 8); + QTRY_VERIFY(gridview->property("animationDone").toBool()); + + // verify that none of the removed items has moved to a negative position + QPoint minimumPosition = gridview->property("minimumPosition").toPoint(); + QVERIFY(minimumPosition.x() >= 0); + QVERIFY(minimumPosition.y() >= 0); + + delete window; +} + void tst_QQuickGridView::cacheBuffer() { QQuickView *window = createView(); |