summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-12-31 13:38:25 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2021-01-05 07:49:21 +0100
commit672d2ea8f414fa5f79f1801d965533b705831921 (patch)
tree9be44079ad5d6bde90ee3fd13b9b6d4db98c6b9e /src/widgets/itemviews
parent587fed817aec5a435fb6467cd42b77831271ec34 (diff)
QAbstractItemView: fix selectionCommand() with no event
QAbstractItemView::selectionCommand() returned the wrong SelectionFlags when no event is given since c4366ff0183a9a4a5c6eff0312b713e9c5eb97ea. Therefore re-add the call to QGuiApplication::keyboardModifiers() when no event is given and add a unittest for them so it's not removed again. Fixes: QTBUG-89711 Change-Id: I107357df08c4ff1b1a14d49523401c5e7b428f56 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 8f8f597d11..9b889ea36d 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -3997,10 +3997,10 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionComm
QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionCommand(
const QModelIndex &index, const QEvent *event) const
{
- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+ Qt::KeyboardModifiers modifiers = event && event->isInputEvent()
+ ? static_cast<const QInputEvent*>(event)->modifiers()
+ : QGuiApplication::keyboardModifiers();
if (event) {
- if (event->isInputEvent())
- modifiers = static_cast<const QInputEvent*>(event)->modifiers();
switch (event->type()) {
case QEvent::MouseMove: {
// Toggle on MouseMove