Browse Source

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
tags/4.1.0
Andrew Senetar 3 months ago
committed by GitHub
parent
commit
421a58a61c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions
  1. +5
    -3
      core/gui/prioritize_dialog.py
  2. +11
    -0
      qt/prioritize_dialog.py

+ 5
- 3
core/gui/prioritize_dialog.py 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)

+ 11
- 0
qt/prioritize_dialog.py 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)



Loading…
Cancel
Save