summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-05-28 13:03:34 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-07 20:23:17 +0200
commitdc5e8aa81c7083659e2ec3090489f34072ebc383 (patch)
treeb064e7dc6a443bb4425230f15875741550d9ceb0 /src/widgets
parentad554707dc1e564fa0ac0f164ed093ddc80f14b0 (diff)
QAbstractItemView: don't toggle extended selection on Ctrl+Press
In ExtendedSelection mode, a Ctrl+Press might be both the start of a selection toggle, or the start of a Ctrl+Drag operation. If we already toggle on the press, then it's impossible to drag the existing selection while the Control key is pressed. Ignore Ctrl+Press events and let the corresponding release event toggle the selection. Adjust the relevant test cases accordingly. The QItemDelegate test case used a click+control event incorrectly, such an event doesn't change the clicked state and should not be eaten, and now it does change the selection, so fix the test. Task-number: QTBUG-59888 Change-Id: Ia76126e31c28bc97d3e93e54965bdb1d0b8ac6a4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 6799aa4ea6..f4f41e6f68 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -4028,6 +4028,11 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
return QItemSelectionModel::Clear;
if (!index.isValid())
return QItemSelectionModel::NoUpdate;
+ // since the press might start a drag, deselect only on release
+ if (controlKeyPressed && !rightButtonPressed && pressedAlreadySelected
+ && dragEnabled && isIndexDragEnabled(index)) {
+ return QItemSelectionModel::NoUpdate;
+ }
break;
}
case QEvent::MouseButtonRelease: {
@@ -4040,6 +4045,10 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
|| !index.isValid()) && state != QAbstractItemView::DragSelectingState
&& !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid()))
return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
+ if (index == pressedIndex && controlKeyPressed && !rightButtonPressed
+ && dragEnabled && isIndexDragEnabled(index)) {
+ break;
+ }
return QItemSelectionModel::NoUpdate;
}
case QEvent::KeyPress: {