aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2024-04-08 16:34:00 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2024-04-11 17:26:23 +0200
commit60194389cd68f51376f611fe878a395c39e6f0eb (patch)
tree65bdc12501ff5305bb01b3bbf02305343ece882b /src/quick
parent9d8c749854bff84046fa2c3c7f7d7039609facc1 (diff)
ItemView: Avoid undesired repositioning in updateCurrent
When updateCurrent is called, it in turn calls updateHighlight. updateHighlight already takes autoHighlight into consideration for some of its logic, but still calls unconditionally into updateTrackedItem. That in turn will trigger some movement of the list, to position the tracked item, which is the highlight. That movement is already only done for the case where the move reason is setIndex. We add an additional condition to check that we really need to track the highlight (either autoHighlight needs to be true, or highlightRange is unequal to NoHighlightRange). This does have the effect that the currentItem can be completely outside of the viewport. [ChangeLog][Important Behavior Change][QtQuick][ListView] If highlightFollowsCurrentItem is set to false, and highlightRangeMode is set to NoHighlightRange, then programatically setting the currentIndex of the list will no longer scroll the view to that item. Fixes: QTBUG-68527 Pick-to: 6.7 Change-Id: I32aeec2621524d72981ec5d9b933d3f608d89390 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickitemview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index ff845936b9..70d460a323 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -1267,7 +1267,9 @@ void QQuickItemView::trackedPositionChanged()
return;
}
- if (d->moveReason == QQuickItemViewPrivate::SetIndex) {
+ const bool needMoveToTrackHighlight = d->autoHighlight || d->highlightRange != NoHighlightRange;
+
+ if (d->moveReason == QQuickItemViewPrivate::SetIndex && needMoveToTrackHighlight) {
qreal trackedPos = d->trackedItem->position();
qreal trackedSize = d->trackedItem->size();
qreal viewPos = d->isContentFlowReversed() ? -d->position()-d->size() : d->position();