From 9edee82fa1d83951c74422f516b1813c4f207c58 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 6 Feb 2010 12:27:11 +0100 Subject: [PATCH] Removed logic duplication across toolkit code in "Make Reference" action. --- cocoa/base/ResultWindow.m | 1 - core/app.py | 5 +++-- core/app_cocoa.py | 3 --- core/app_cocoa_inter.py | 2 +- core/tests/app_cocoa_test.py | 12 ++++++------ qt/base/app.py | 4 ++-- qt/base/main_window.py | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/cocoa/base/ResultWindow.m b/cocoa/base/ResultWindow.m index 46e3c6c0..afaa6fb9 100644 --- a/cocoa/base/ResultWindow.m +++ b/cocoa/base/ResultWindow.m @@ -425,7 +425,6 @@ http://www.hardcoded.net/licenses/hs_license // but after a lot of fussing around, believe it or not, it actually is. NSInteger matchesTag = _powerMode ? 2 : 0; NSInteger startLen = [[py getOutlineView:matchesTag childCountsForPath:[NSArray array]] count]; - [self performPySelection:[self getSelectedPaths:YES]]; [py makeSelectedReference]; [self performPySelection:[self getSelectedPaths:NO]]; // In some cases (when in a filtered view in Power Marker mode, it's possible that the demoted diff --git a/core/app.py b/core/app.py index 5b1c3605..8b294773 100644 --- a/core/app.py +++ b/core/app.py @@ -215,9 +215,10 @@ class DupeGuru(RegistrableApplication, Broadcaster): p = op.join(self.appdata, 'ignore_list.xml') self.scanner.ignore_list.load_from_xml(p) - def make_reference(self, duplicates): + def make_selected_reference(self): + dupes = self.without_ref(self.selected_dupes) changed_groups = set() - for dupe in duplicates: + for dupe in dupes: g = self.results.get_group_of_duplicate(dupe) if g not in changed_groups: self.results.make_ref(dupe) diff --git a/core/app_cocoa.py b/core/app_cocoa.py index 092ea007..cc56d56e 100644 --- a/core/app_cocoa.py +++ b/core/app_cocoa.py @@ -92,9 +92,6 @@ class DupeGuru(app.DupeGuru): #---Public copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked) delete_marked = demo_method(app.DupeGuru.delete_marked) - - def MakeSelectedReference(self): - self.make_reference(self.selected_dupes) def OpenSelected(self): # local import because first appkit import takes a lot of memory. we want to avoid it. diff --git a/core/app_cocoa_inter.py b/core/app_cocoa_inter.py index 8d11f7cf..985b1883 100644 --- a/core/app_cocoa_inter.py +++ b/core/app_cocoa_inter.py @@ -94,7 +94,7 @@ class PyDupeGuruBase(PyApp): self.app.apply_filter(filter) def makeSelectedReference(self): - self.app.MakeSelectedReference() + self.app.make_selected_reference() def copyOrMove_markedTo_recreatePath_(self, copy, destination, recreate_path): self.app.copy_or_move_marked(copy, destination, recreate_path) diff --git a/core/tests/app_cocoa_test.py b/core/tests/app_cocoa_test.py index f707a422..cc7b23bf 100644 --- a/core/tests/app_cocoa_test.py +++ b/core/tests/app_cocoa_test.py @@ -264,9 +264,9 @@ class TCDupeGuru(TestCase): objects = self.objects groups = self.groups app.SelectPowerMarkerNodePaths(r2np([0,2])) - app.MakeSelectedReference() - self.assert_(groups[0].ref is objects[1]) - self.assert_(groups[1].ref is objects[4]) + app.make_selected_reference() + assert groups[0].ref is objects[1] + assert groups[1].ref is objects[4] def test_makeSelectedReference_by_selecting_two_dupes_in_the_same_group(self): app = self.app @@ -274,9 +274,9 @@ class TCDupeGuru(TestCase): groups = self.groups app.SelectPowerMarkerNodePaths(r2np([0,1,2])) #Only 0 and 2 must go ref, not 1 because it is a part of the same group - app.MakeSelectedReference() - self.assert_(groups[0].ref is objects[1]) - self.assert_(groups[1].ref is objects[4]) + app.make_selected_reference() + assert groups[0].ref is objects[1] + assert groups[1].ref is objects[4] def test_removeSelected(self): app = self.app diff --git a/qt/base/app.py b/qt/base/app.py index 4efb1bca..46068da9 100644 --- a/qt/base/app.py +++ b/qt/base/app.py @@ -156,8 +156,8 @@ class DupeGuru(DupeGuruBase, QObject): delete_marked = demo_method(DupeGuruBase.delete_marked) - def make_reference(self, duplicates): - DupeGuruBase.make_reference(self, duplicates) + def make_selected_reference(self): + DupeGuruBase.make_selected_reference(self) self.emit(SIGNAL('resultsChanged()')) def remove_duplicates(self, duplicates): diff --git a/qt/base/main_window.py b/qt/base/main_window.py index ec910cba..dc15532f 100644 --- a/qt/base/main_window.py +++ b/qt/base/main_window.py @@ -205,7 +205,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): QDesktopServices.openUrl(url) def makeReferenceTriggered(self): - self.app.make_reference(self.resultsView.selectedDupes()) + self.app.make_selected_reference() def markAllTriggered(self): self.app.mark_all()