summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-10-16 10:45:46 +0200
committerMitch Curtis <mitch.curtis@qt.io>2019-10-16 20:34:57 +0200
commit072b5369ee107251d6800970263f573f74864fca (patch)
tree82c6ad6aae749cd10b11ee3dfe8dfa1477a510cf
parent56963a4485445d91bd1ab37ad0bdf22f504ea0ce (diff)
Adapt Tumbler after ListView changesv5.14.0-beta2
After 2d9cf3ef, ListView now changes the currentIndex for some unknown reason. The changes clearly didn't cause any failures in Qt Quick's auto tests, but some Tumbler auto tests fail. Presumably, the failures are due to TumblerView's intimate usage of Qt Quick's C++ API, where it creates either a PathView or a ListView on demand internally. From what I could see, the currentIndex change was caused by this code: if (FxViewItem *snapItem = d->snapItemAt(d->highlight->position())) { if (snapItem->index >= 0 && snapItem->index != d->currentIndex) d->updateCurrent(snapItem->index); } So I worked around the issue by delaying the call to setHighlightRangeMode() until after the delegate has been created. I also tried moving the call to setSnapMode() (which seems very relevant given the context), but it caused test failures. Change-Id: I7017760c21193dc6ce8181669ba7cf047b18dfba Fixes: QTBUG-79150 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--src/quickcontrols2/qquicktumblerview.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp
index 5f5c065d..4a64ad7f 100644
--- a/src/quickcontrols2/qquicktumblerview.cpp
+++ b/src/quickcontrols2/qquicktumblerview.cpp
@@ -180,7 +180,6 @@ void QQuickTumblerView::createView()
QQml_setParent_noEvent(m_listView, this);
m_listView->setParentItem(this);
m_listView->setSnapMode(QQuickListView::SnapToItem);
- m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
m_listView->setClip(true);
// Give the view a size.
@@ -193,6 +192,8 @@ void QQuickTumblerView::createView()
// the view animates any potential currentIndex change over one second,
// which we don't want when the contentItem has just been created.
m_listView->setDelegate(m_delegate);
+ // Set this after setting the delegate to avoid unexpected currentIndex changes: QTBUG-79150
+ m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
m_listView->setHighlightMoveDuration(1000);
qCDebug(lcTumblerView) << "finished creating ListView";