mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	Removed logic duplication across toolkit code in "Add to Ignore List" action.
This commit is contained in:
		
							parent
							
								
									64c67e19d2
								
							
						
					
					
						commit
						3c75d2f8b7
					
				| @ -302,11 +302,10 @@ http://www.hardcoded.net/licenses/hs_license | ||||
|     NSArray *nodeList = [self getSelected:YES]; | ||||
|     if (![nodeList count]) | ||||
|         return; | ||||
|     if ([Dialogs askYesNo:[NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO | ||||
|     NSString *msg = [NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",[nodeList count]]; | ||||
|     if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) // NO | ||||
|         return; | ||||
|     [self performPySelection:[self getSelectedPaths:YES]]; | ||||
|     [py addSelectedToIgnoreList]; | ||||
|     [py removeSelected]; | ||||
|     [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										12
									
								
								core/app.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								core/app.py
									
									
									
									
									
								
							| @ -132,6 +132,12 @@ class DupeGuru(RegistrableApplication, Broadcaster): | ||||
|             if other is not dupe: | ||||
|                 self.scanner.ignore_list.Ignore(unicode(other.path), unicode(dupe.path)) | ||||
|      | ||||
|     def add_selected_to_ignore_list(self): | ||||
|         dupes = self.without_ref(self.selected_dupes) | ||||
|         for dupe in dupes: | ||||
|             self.add_to_ignore_list(dupe) | ||||
|         self.remove_duplicates(dupes) | ||||
|      | ||||
|     def apply_filter(self, filter): | ||||
|         self.results.apply_filter(None) | ||||
|         if self.options['escape_filter_regexp']: | ||||
| @ -220,6 +226,9 @@ class DupeGuru(RegistrableApplication, Broadcaster): | ||||
|                 self.results.make_ref(dupe) | ||||
|                 changed_groups.add(g) | ||||
|      | ||||
|     def remove_duplicates(self, duplicates): | ||||
|         self.results.remove_duplicates(duplicates) | ||||
|      | ||||
|     def save(self): | ||||
|         if not op.exists(self.appdata): | ||||
|             os.makedirs(self.appdata) | ||||
| @ -248,6 +257,9 @@ class DupeGuru(RegistrableApplication, Broadcaster): | ||||
|         self.results.groups = [] | ||||
|         self._start_job(JOB_SCAN, do) | ||||
|      | ||||
|     def without_ref(self, dupes): | ||||
|         return [dupe for dupe in dupes if self.results.get_group_of_duplicate(dupe).ref is not dupe] | ||||
|      | ||||
|     #--- Properties | ||||
|     @property | ||||
|     def stat_line(self): | ||||
|  | ||||
| @ -90,10 +90,6 @@ class DupeGuru(app.DupeGuru): | ||||
|         return self.get_folder_path(node_path[1:], curr_path) | ||||
|      | ||||
|     #---Public | ||||
|     def AddSelectedToIgnoreList(self): | ||||
|         for dupe in self.selected_dupes: | ||||
|             self.add_to_ignore_list(dupe) | ||||
|      | ||||
|     copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked) | ||||
|     delete_marked = demo_method(app.DupeGuru.delete_marked) | ||||
| 
 | ||||
|  | ||||
| @ -85,7 +85,7 @@ class PyDupeGuruBase(PyApp): | ||||
|      | ||||
|     #---Actions | ||||
|     def addSelectedToIgnoreList(self): | ||||
|         self.app.AddSelectedToIgnoreList() | ||||
|         self.app.add_selected_to_ignore_list() | ||||
|      | ||||
|     def deleteMarked(self): | ||||
|         self.app.delete_marked() | ||||
|  | ||||
| @ -307,10 +307,10 @@ class TCDupeGuru(TestCase): | ||||
|     def test_ignore(self): | ||||
|         app = self.app | ||||
|         app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group | ||||
|         app.AddSelectedToIgnoreList() | ||||
|         app.add_selected_to_ignore_list() | ||||
|         self.assertEqual(1,len(app.scanner.ignore_list)) | ||||
|         app.SelectPowerMarkerNodePaths(r2np([0])) #first dupe of the 3 dupes group | ||||
|         app.AddSelectedToIgnoreList() | ||||
|         app.add_selected_to_ignore_list() | ||||
|         #BOTH the ref and the other dupe should have been added | ||||
|         self.assertEqual(3,len(app.scanner.ignore_list)) | ||||
|      | ||||
| @ -337,7 +337,7 @@ class TCDupeGuru(TestCase): | ||||
|         app = self.app | ||||
|         app.scanner.ignore_list.Ignore = FakeIgnore | ||||
|         app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group | ||||
|         app.AddSelectedToIgnoreList() | ||||
|         app.add_selected_to_ignore_list() | ||||
|      | ||||
|     def test_GetOutlineViewChildCounts_out_of_range(self): | ||||
|         # Out of range requests don't crash and return an empty value | ||||
|  | ||||
| @ -130,19 +130,19 @@ class DupeGuru(DupeGuruBase, QObject): | ||||
|             msg = "A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again." | ||||
|             QMessageBox.information(self.main_window, 'Action in progress', msg) | ||||
|      | ||||
|     #--- Public | ||||
|     def add_dupes_to_ignore_list(self, duplicates): | ||||
|         for dupe in duplicates: | ||||
|             self.add_to_ignore_list(dupe) | ||||
|         self.remove_duplicates(duplicates) | ||||
|     def add_selected_to_ignore_list(self): | ||||
|         dupes = self.without_ref(self.selected_dupes) | ||||
|         if not dupes: | ||||
|             return | ||||
|         title = "Add to Ignore List" | ||||
|         msg = "All selected {0} matches are going to be ignored in all subsequent scans. Continue?".format(len(dupes)) | ||||
|         if self.main_window._confirm(title, msg): | ||||
|             DupeGuruBase.add_selected_to_ignore_list(self) | ||||
|      | ||||
|     def apply_filter(self, filter): | ||||
|         DupeGuruBase.apply_filter(self, filter) | ||||
|         self.emit(SIGNAL('resultsChanged()')) | ||||
|      | ||||
|     def askForRegCode(self): | ||||
|         self.reg.ask_for_code() | ||||
|      | ||||
|     @demo_method | ||||
|     def copy_or_move_marked(self, copy): | ||||
|         opname = 'copy' if copy else 'move' | ||||
| @ -160,6 +160,14 @@ class DupeGuru(DupeGuruBase, QObject): | ||||
|         DupeGuruBase.make_reference(self, duplicates) | ||||
|         self.emit(SIGNAL('resultsChanged()')) | ||||
|      | ||||
|     def remove_duplicates(self, duplicates): | ||||
|         DupeGuruBase.remove_duplicates(self, duplicates) | ||||
|         self.emit(SIGNAL('resultsChanged()')) | ||||
|      | ||||
|     #--- Public | ||||
|     def askForRegCode(self): | ||||
|         self.reg.ask_for_code() | ||||
|      | ||||
|     def mark_all(self): | ||||
|         self.results.mark_all() | ||||
|         self.emit(SIGNAL('dupeMarkingChanged()')) | ||||
| @ -183,10 +191,6 @@ class DupeGuru(DupeGuruBase, QObject): | ||||
|         url = QUrl.fromLocalFile(unicode(self.selected_dupes[0].path)) | ||||
|         QDesktopServices.openUrl(url) | ||||
|      | ||||
|     def remove_duplicates(self, duplicates): | ||||
|         self.results.remove_duplicates(duplicates) | ||||
|         self.emit(SIGNAL('resultsChanged()')) | ||||
|      | ||||
|     def remove_marked_duplicates(self): | ||||
|         marked = [d for d in self.results.dupes if self.results.is_marked(d)] | ||||
|         self.remove_duplicates(marked) | ||||
| @ -205,8 +209,8 @@ class DupeGuru(DupeGuruBase, QObject): | ||||
|         url = QUrl.fromLocalFile(unicode(self.selected_dupe[0].path[:-1])) | ||||
|         QDesktopServices.openUrl(url) | ||||
|      | ||||
|     def select_duplicate(self, dupe): | ||||
|         self._select_dupes([dupe]) | ||||
|     def select_dupes(self, dupes): | ||||
|         self._select_dupes(dupes) | ||||
|      | ||||
|     def show_about_box(self): | ||||
|         self.about_box.show() | ||||
|  | ||||
| @ -142,13 +142,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): | ||||
|         self.actionsButton.showMenu() | ||||
|      | ||||
|     def addToIgnoreListTriggered(self): | ||||
|         dupes = self.resultsView.selectedDupes() | ||||
|         if not dupes: | ||||
|             return | ||||
|         title = "Add to Ignore List" | ||||
|         msg = "All selected {0} matches are going to be ignored in all subsequent scans. Continue?".format(len(dupes)) | ||||
|         if self._confirm(title, msg): | ||||
|             self.app.add_dupes_to_ignore_list(dupes) | ||||
|         self.app.add_selected_to_ignore_list() | ||||
|      | ||||
|     def applyFilterTriggered(self): | ||||
|         title = "Apply Filter" | ||||
| @ -324,7 +318,5 @@ class MainWindow(QMainWindow, Ui_MainWindow): | ||||
|         self._update_status_line() | ||||
|      | ||||
|     def selectionChanged(self, selected, deselected): | ||||
|         index = self.resultsView.selectionModel().currentIndex() | ||||
|         dupe = index.internalPointer().dupe if index.isValid() else None | ||||
|         self.app.select_duplicate(dupe) | ||||
|         self.app.select_dupes(self.resultsView.selectedDupes()) | ||||
|      | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user