From 4579740df694c72679f11868e2433a909059292e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 30 Jan 2021 21:25:30 +1000 Subject: [PATCH] support dragging multiple decks at once --- qt/aqt/sidebar.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qt/aqt/sidebar.py b/qt/aqt/sidebar.py index c01db7972..a9d900bf9 100644 --- a/qt/aqt/sidebar.py +++ b/qt/aqt/sidebar.py @@ -271,6 +271,7 @@ class SidebarTreeView(QTreeView): self.setUniformRowHeights(True) self.setHeaderHidden(True) self.setIndentation(15) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.setDragDropMode(QAbstractItemView.InternalMove) self.setDragDropOverwriteMode(False) @@ -344,7 +345,6 @@ class SidebarTreeView(QTreeView): model = self.model() source_items = [model.item_for_index(idx) for idx in self.selectedIndexes()] target_item = model.item_for_index(self.indexAt(event.pos())) - print("drop") if self.handle_drag_drop(source_items, target_item): event.acceptProposedAction() @@ -648,6 +648,13 @@ class SidebarTreeView(QTreeView): if not m.children(): return + # until we support multiple selection, show user that only the current + # item is being operated on by clearing the selection + if idx: + sm = self.selectionModel() + sm.clear() + sm.select(idx, QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows) + m.exec_(QCursor.pos()) def maybe_add_tree_actions(