aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickgridview.cpp4
-rw-r--r--src/quick/items/qquicklistview.cpp4
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemResize.qml16
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp32
4 files changed, 52 insertions, 4 deletions
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index e3f216b3a2..ff928a599f 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -922,13 +922,13 @@ void QQuickGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
tempPosition -= bias;
}
FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart);
- if (!topItem && strictHighlightRange && currentItem) {
+ if (strictHighlightRange && currentItem) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
topItem = currentItem;
}
FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd);
- if (!bottomItem && strictHighlightRange && currentItem) {
+ if (strictHighlightRange && currentItem) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
bottomItem = currentItem;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index e37aca01c5..b08a8cfffe 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -1470,13 +1470,13 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
tempPosition -= bias;
}
FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart);
- if (!topItem && strictHighlightRange && currentItem) {
+ if (strictHighlightRange && currentItem) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
topItem = currentItem;
}
FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd);
- if (!bottomItem && strictHighlightRange && currentItem) {
+ if (strictHighlightRange && currentItem) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
bottomItem = currentItem;
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml
new file mode 100644
index 0000000000..7ecc833a64
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+ListView {
+ id: list
+ currentIndex: 5
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightFollowsCurrentItem: true
+ model: 10
+ spacing: 10
+ delegate: Item {
+ width: ListView.view.width
+ height: ListView.view.height
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 6377650696..0c0e9115c5 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -179,6 +179,7 @@ private slots:
void creationContext();
void snapToItem_data();
void snapToItem();
+ void snapOneItemResize_QTBUG_43555();
void snapOneItem_data();
void snapOneItem();
@@ -5203,6 +5204,37 @@ void tst_QQuickListView::snapToItem()
releaseView(window);
}
+void tst_QQuickListView::snapOneItemResize_QTBUG_43555()
+{
+ QQuickView *window = createView();
+ window->resize(QSize(100, 320));
+ window->setResizeMode(QQuickView::SizeRootObjectToView);
+ QQuickViewTestUtil::moveMouseAway(window);
+
+ window->setSource(testFileUrl("snapOneItemResize.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), 5);
+ currentIndexSpy.clear();
+
+ window->resize(QSize(400, 320));
+
+ QTRY_COMPARE(int(listview->width()), 400);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_COMPARE(listview->currentIndex(), 5);
+ QCOMPARE(currentIndexSpy.count(), 0);
+
+ delete window;
+}
+
void tst_QQuickListView::qAbstractItemModel_package_items()
{
items<QaimModel>(testFileUrl("listviewtest-package.qml"));