diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-02-11 13:58:04 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-03-30 11:17:59 +0000 |
commit | 2e0c29a4bbe2b3ae427137e65f179b0550dcf169 (patch) | |
tree | cfcd19f6a98c3e8aa5be060a6d69cbc4e59d34c2 /src | |
parent | bff56f953adc8ce743aa774d6ad09725d8b9bc45 (diff) |
itemviews: Use the start of the current selection when getting the range
When doing a shift-select while moving the mouse then the start point
should be based on the start of the current selection and not the
pressed position. If there is no current selection start index, then
we can safely depend on pressed position as this will be the previous
index pressed on.
This resolves an issue introduced by
e02293a76d21e7077f1952d4ed8af6c6d1970190 when fixing QTBUG-78797
Fixes: QTBUG-81542
Change-Id: Ia66c42b220452fdcbc8cfccc05dbc8a3911c3f5e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index f879af6ad2..73604cb8f4 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1844,10 +1844,16 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event) || edit(index, NoEditTriggers, event)) return; - if (d->selectionMode != SingleSelection) - topLeft = d->pressedPosition - d->offset(); - else + if (d->selectionMode != SingleSelection) { + // Use the current selection start index if it is valid as this will be based on the + // start of the selection and not the last item being pressed which can be different + // when in extended selection + topLeft = d->currentSelectionStartIndex.isValid() + ? visualRect(d->currentSelectionStartIndex).center() + : d->pressedPosition - d->offset(); + } else { topLeft = bottomRight; + } d->checkMouseMove(index); |