mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
don't select contiguously with shift+click; enable multiple selection
https://github.com/ankitects/anki/issues/1011
This commit is contained in:
parent
7972fa6493
commit
c91d21e18e
1 changed files with 15 additions and 4 deletions
|
@ -299,10 +299,9 @@ class SidebarTreeView(QTreeView):
|
|||
self.setHeaderHidden(True)
|
||||
self.setIndentation(15)
|
||||
self.setAutoExpandDelay(600)
|
||||
# this doesn't play nicely with shift+click to OR items - we may want
|
||||
# to put it behind a 'multi-select' mode
|
||||
# self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
|
||||
# pylint: disable=no-member
|
||||
mode = QAbstractItemView.SelectionMode.ExtendedSelection # type: ignore
|
||||
self.setSelectionMode(mode)
|
||||
self.setDragDropMode(QAbstractItemView.InternalMove)
|
||||
self.setDragDropOverwriteMode(False)
|
||||
|
||||
|
@ -397,6 +396,18 @@ class SidebarTreeView(QTreeView):
|
|||
else:
|
||||
super().keyPressEvent(event)
|
||||
|
||||
# don't extend selection when shift+clicking with mouse (conflicts
|
||||
# with OR-ing). User can still shift+up/down to select contiguously.
|
||||
def selectionCommand(
|
||||
self, index: QModelIndex, event: QEvent = None
|
||||
) -> QItemSelectionModel.SelectionFlags:
|
||||
flags = super().selectionCommand(index, event)
|
||||
mods = self.mw.app.keyboardModifiers()
|
||||
if isinstance(event, QMouseEvent) and mods & Qt.ShiftModifier:
|
||||
# pylint: disable=no-member
|
||||
flags &= ~QItemSelectionModel.SelectionFlag.Current # type: ignore
|
||||
return flags
|
||||
|
||||
###########
|
||||
|
||||
def handle_drag_drop(self, sources: List[SidebarItem], target: SidebarItem) -> bool:
|
||||
|
|
Loading…
Reference in a new issue