QAbstractItemView: don't toggle selection on mouse move on some index

In single selection mode, the current selection toggled when the user
pressed the left mouse + Ctrl key and then moved the mouse over the
item. This was introduced with 28a21d98ef
which added the possibility to deselect an item in single selection
mode.
Fix it by adding a check if the event was a mouse move event and use the
old codepath for it.

Fixes: QTBUG-77353
Change-Id: Id845ada302c92646885dfd966721b00d940f1260
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
bb10
Christian Ehrlicher 2019-11-05 07:49:48 +01:00
parent bc4c2382aa
commit 88047be4ec
1 changed files with 1 additions and 1 deletions

View File

@ -3967,7 +3967,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM
case SingleSelection: // ClearAndSelect on valid index otherwise NoUpdate
if (event && event->type() == QEvent::MouseButtonRelease)
return QItemSelectionModel::NoUpdate;
if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index))
if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index) && event->type() != QEvent::MouseMove)
return QItemSelectionModel::Deselect | d->selectionBehaviorFlags();
else
return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags();