diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-12-31 13:38:25 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-01-05 08:46:30 +0000 |
commit | f0a0c00a0ad97143c4a9a190da1a827e2b2d38a9 (patch) | |
tree | d97f7f4aaf06e87dfc9d5ddd2fd2ac68ffd49d11 /src/widgets | |
parent | 696405b7f6c4de6c656df5c2ab86f0c7fc87be04 (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
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 672d2ea8f414fa5f79f1801d965533b705831921)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 2e0ddf678f..19824911fa 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3998,10 +3998,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 |