Compare commits

...

5 Commits

Author SHA1 Message Date
Andrew Senetar 421a58a61c
Merge pull request #758 from serg-z/serg-z/prioritize-dialog-multi-selections
Prioritize dialog: adding/removing multiple items, adding/removing on double clicking an item, drag-n-drop fix
2021-01-11 18:50:15 -06:00
Sergey Zhuravlevich b5a3313f80 Prioritize dialog: fix drag-n-drop putting items before the last item
When the items in the prioritizations list were drag-n-dropped to the
empty space, the row was equal to -1 and the dropped items ended up
being moved to the position before the last item. Fixing the row value
helps to avoid that behavior.

Signed-off-by: Sergey Zhuravlevich <sergey@zhur.xyz>
2021-01-07 17:42:43 +01:00
Sergey Zhuravlevich 116ac18e13 Prioritize dialog: add/remove criteria on double clicking an item
Signed-off-by: Sergey Zhuravlevich <sergey@zhur.xyz>
2021-01-07 17:42:43 +01:00
Sergey Zhuravlevich 32dcd90b50 Prioritize dialog: allow removing multiple prioritizations at once
Removing prioritizations one-by-one can be tedious. This commit enables
extended selection in the prioritizations list. Multiple items can be
selected with conventional methods, such as holding down Ctrl or Shift
key and clicking the items or holding down the left mouse button and
hovering the cursor over the list. All items also can be selected with
Ctrl+A.

Multiple items drag-n-drop is also possible.

To avoid confusion, the selection in the prioritizations list is cleared
after the items are removed or drag-n-dropped.

Signed-off-by: Sergey Zhuravlevich <sergey@zhur.xyz>
2021-01-07 17:42:30 +01:00
Sergey Zhuravlevich c2fef8d624 Prioritize dialog: allow adding multiple criteria at once
Adding criteria to the prioritizations list one-by-one can be tedious.
This commit enables extended selection in the criteria list and
implements adding multiple items. Multiple criteria can be selected with
conventional methods, such as holding down Ctrl or Shift keys and
clicking the items or holding down the left mouse button and hovering
the cursor over the list. All items also can be selected with Ctrl+A.

Signed-off-by: Sergey Zhuravlevich <sergey@zhur.xyz>
2021-01-07 17:42:07 +01:00
2 changed files with 16 additions and 3 deletions

View File

@ -72,13 +72,15 @@ class PrioritizeDialog(GUIObject):
# Add selected criteria in criteria_list to prioritization_list.
if self.criteria_list.selected_index is None:
return
crit = self.criteria[self.criteria_list.selected_index]
self.prioritizations.append(crit)
del crit
for i in self.criteria_list.selected_indexes:
crit = self.criteria[i]
self.prioritizations.append(crit)
del crit
self.prioritization_list[:] = [crit.display for crit in self.prioritizations]
def remove_selected(self):
self.prioritization_list.remove_selected()
self.prioritization_list.select([])
def perform_reprioritization(self):
self.app.reprioritize_groups(self._sort_key)

View File

@ -47,9 +47,16 @@ class PrioritizationList(ListviewModel):
# to know where the drop took place.
if parentIndex.isValid():
return False
# "When row and column are -1 it means that the dropped data should be considered as
# dropped directly on parent."
# Moving items to row -1 would put them before the last item. Fix the row to drop the
# dragged items after the last item.
if row < 0:
row = len(self.model) - 1
strMimeData = bytes(mimeData.data(MIME_INDEXES)).decode()
indexes = list(map(int, strMimeData.split(",")))
self.model.move_indexes(indexes, row)
self.view.selectionModel().clearSelection()
return True
def mimeData(self, indexes):
@ -84,7 +91,9 @@ class PrioritizeDialog(QDialog):
self.model.view = self
self.addCriteriaButton.clicked.connect(self.model.add_selected)
self.criteriaListView.doubleClicked.connect(self.model.add_selected)
self.removeCriteriaButton.clicked.connect(self.model.remove_selected)
self.prioritizationListView.doubleClicked.connect(self.model.remove_selected)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
@ -102,6 +111,7 @@ class PrioritizeDialog(QDialog):
self.promptLabel.setWordWrap(True)
self.categoryCombobox = QComboBox()
self.criteriaListView = QListView()
self.criteriaListView.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.addCriteriaButton = QPushButton(
self.style().standardIcon(QStyle.SP_ArrowRight), ""
)
@ -113,6 +123,7 @@ class PrioritizeDialog(QDialog):
self.prioritizationListView.setDragEnabled(True)
self.prioritizationListView.setDragDropMode(QAbstractItemView.InternalMove)
self.prioritizationListView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.prioritizationListView.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.buttonBox = QDialogButtonBox()
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)