mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	[#138] Added a prompt label and a remove button to the reprioritization dialog (Qt).
This commit is contained in:
		
							parent
							
								
									90f9493ccc
								
							
						
					
					
						commit
						cf606a494c
					
				| @ -23,6 +23,9 @@ class PrioritizationList(GUISelectableList): | ||||
|         self.dialog = dialog | ||||
|         GUISelectableList.__init__(self) | ||||
|      | ||||
|     def _refresh_contents(self): | ||||
|         self[:] = [crit.display for crit in self.dialog.prioritizations] | ||||
|      | ||||
|     def move_indexes(self, indexes, dest_index): | ||||
|         indexes.sort() | ||||
|         prilist = self.dialog.prioritizations | ||||
| @ -30,7 +33,13 @@ class PrioritizationList(GUISelectableList): | ||||
|         for i in reversed(indexes): | ||||
|             del prilist[i] | ||||
|         prilist[dest_index:dest_index] = selected | ||||
|         self[:] = [crit.display for crit in prilist] | ||||
|         self._refresh_contents() | ||||
|      | ||||
|     def remove_selected(self): | ||||
|         prilist = self.dialog.prioritizations | ||||
|         for i in sorted(self.selected_indexes, reverse=True): | ||||
|             del prilist[i] | ||||
|         self._refresh_contents() | ||||
| 
 | ||||
| class PrioritizeDialog: | ||||
|     def __init__(self, view, app): | ||||
| @ -57,5 +66,8 @@ class PrioritizeDialog: | ||||
|         self.prioritizations.append(crit) | ||||
|         self.prioritization_list[:] = [crit.display for crit in self.prioritizations] | ||||
|      | ||||
|     def remove_selected(self): | ||||
|         self.prioritization_list.remove_selected() | ||||
|      | ||||
|     def perform_reprioritization(self): | ||||
|         self.app.reprioritize_groups(self._sort_key) | ||||
|  | ||||
| @ -111,6 +111,17 @@ def test_reorder_prioritizations(app): | ||||
|     ] | ||||
|     eq_(app.pdialog.prioritization_list[:], expected) | ||||
| 
 | ||||
| @with_app(app_normal_results) | ||||
| def test_remove_crit_from_list(app): | ||||
|     app.add_pri_criterion("Kind", 0) | ||||
|     app.add_pri_criterion("Kind", 1) | ||||
|     app.pdialog.prioritization_list.select(0) | ||||
|     app.pdialog.remove_selected() | ||||
|     expected = [ | ||||
|         "Kind (ext2)", | ||||
|     ] | ||||
|     eq_(app.pdialog.prioritization_list[:], expected) | ||||
| 
 | ||||
| #--- | ||||
| def app_one_name_ends_with_number(): | ||||
|     dupes = [ | ||||
|  | ||||
| @ -8,10 +8,11 @@ | ||||
| 
 | ||||
| from PyQt4.QtCore import Qt, QMimeData, QByteArray | ||||
| from PyQt4.QtGui import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QListView, | ||||
|     QDialogButtonBox, QAbstractItemView) | ||||
|     QDialogButtonBox, QAbstractItemView, QLabel) | ||||
| 
 | ||||
| from hscommon.trans import tr | ||||
| from qtlib.selectable_list import ComboboxModel, ListviewModel | ||||
| from qtlib.util import verticalSpacer | ||||
| from core.gui.prioritize_dialog import PrioritizeDialog as PrioritizeDialogModel | ||||
| 
 | ||||
| MIME_INDEXES = 'application/dupeguru.rowindexes' | ||||
| @ -60,16 +61,23 @@ class PrioritizeDialog(QDialog): | ||||
|         self.prioritizationList = PrioritizationList(model=self.model.prioritization_list, view=self.prioritizationListView) | ||||
|          | ||||
|         self.addCriteriaButton.clicked.connect(self.model.add_selected) | ||||
|         self.removeCriteriaButton.clicked.connect(self.model.remove_selected) | ||||
|         self.buttonBox.accepted.connect(self.accept) | ||||
|         self.buttonBox.rejected.connect(self.reject) | ||||
| 
 | ||||
|     def _setupUi(self): | ||||
|         self.setWindowTitle(tr("Re-prioritize duplicates")) | ||||
|         self.resize(413, 323) | ||||
|         self.resize(700, 400) | ||||
|          | ||||
|         #widgets | ||||
|         msg = tr("Add criteria to the right box and click OK to send the dupes that correspond the " | ||||
|             "best to these criteria to their respective group's " | ||||
|             "reference position. Read the help file for more information.") | ||||
|         self.promptLabel = QLabel(msg) | ||||
|         self.promptLabel.setWordWrap(True) | ||||
|         self.categoryCombobox = QComboBox() | ||||
|         self.criteriaListView = QListView() | ||||
|         self.removeCriteriaButton = QPushButton("<--") | ||||
|         self.addCriteriaButton = QPushButton("-->") | ||||
|         self.prioritizationListView = QListView() | ||||
|         self.prioritizationListView.setAcceptDrops(True) | ||||
| @ -81,12 +89,18 @@ class PrioritizeDialog(QDialog): | ||||
|          | ||||
|         # layout | ||||
|         self.mainLayout = QVBoxLayout(self) | ||||
|         self.mainLayout.addWidget(self.promptLabel) | ||||
|         self.widgetsLayout = QHBoxLayout() | ||||
|         self.leftWidgetsLayout = QVBoxLayout() | ||||
|         self.leftWidgetsLayout.addWidget(self.categoryCombobox) | ||||
|         self.leftWidgetsLayout.addWidget(self.criteriaListView) | ||||
|         self.widgetsLayout.addLayout(self.leftWidgetsLayout) | ||||
|         self.widgetsLayout.addWidget(self.addCriteriaButton) | ||||
|         self.addRemoveButtonsLayout = QVBoxLayout() | ||||
|         self.addRemoveButtonsLayout.addItem(verticalSpacer()) | ||||
|         self.addRemoveButtonsLayout.addWidget(self.removeCriteriaButton) | ||||
|         self.addRemoveButtonsLayout.addWidget(self.addCriteriaButton) | ||||
|         self.addRemoveButtonsLayout.addItem(verticalSpacer()) | ||||
|         self.widgetsLayout.addLayout(self.addRemoveButtonsLayout) | ||||
|         self.widgetsLayout.addWidget(self.prioritizationListView) | ||||
|         self.mainLayout.addLayout(self.widgetsLayout) | ||||
|         self.mainLayout.addWidget(self.buttonBox) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user