diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-06-21 15:12:36 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-06-28 09:46:11 +0200 |
commit | 692b2da77427259a3589cf8a1311075863f2f5ec (patch) | |
tree | 2718a180d3254122f6cb4cac00745c612ea76084 /tests | |
parent | b8a85408d943bffba403d783b9082bd279460bed (diff) |
Fix: ListView footer positioned wrong after last item removed
The refill() method would bail out early on an empty model. Make sure
that it at least updates the header and footer in such situations.
Fixes: QTBUG-31677
Change-Id: I1f3a1848ff263a8f7f9ccfc3b20f16b61348f57b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquicklistview/data/footer2.qml | 33 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 16 |
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/footer2.qml b/tests/auto/quick/qquicklistview/data/footer2.qml new file mode 100644 index 0000000000..bba74d89f7 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/footer2.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: { + list.model -= 3; + } + } + + ListView { + id: list + objectName: "list" + anchors.fill: parent + model: 3 + delegate: Rectangle { + color: "red" + width: 240 + height: 10 + } + footer: Rectangle { + color: "blue" + width: 240 + height: 10 + } + } +} + diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index fddba77f35..cfd740f33d 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -152,6 +152,7 @@ private slots: void headerChangesViewport(); void footer(); void footer_data(); + void footer2(); void extents(); void extents_data(); void resetModel_headerFooter(); @@ -4138,6 +4139,21 @@ void tst_QQuickListView::footer_data() << QPointF(0, -(30 * 20) - 10); } +void tst_QQuickListView::footer2() // QTBUG-31677 +{ + QQuickView *window = getView(); + window->setSource(testFileUrl("footer2.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); + QTRY_VERIFY(listview != nullptr); + + QQuickItem *footer = listview->footerItem(); + QVERIFY(footer != nullptr); + QTRY_COMPARE(footer->y(), 0.0); +} + class LVAccessor : public QQuickListView { public: |