From 70e505ad922e6074e036225318df2b7a5f5f2765 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 28 Apr 2013 14:12:08 -0400 Subject: [PATCH 1/2] Tweaked Make Selected into Reference. Having dupes from ref folders (which makes ref switching impossible) would make the new feature glitchy (selection would be emptied). Now, in cases where the action results in nothing being changed, the selection stays intact. [#222] --- core/app.py | 10 ++++++---- core/engine.py | 5 +++-- core/results.py | 4 +++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/app.py b/core/app.py index 6eb1168f..61100c38 100644 --- a/core/app.py +++ b/core/app.py @@ -442,14 +442,16 @@ class DupeGuru(RegistrableApplication, Broadcaster): for dupe in dupes: g = self.results.get_group_of_duplicate(dupe) if g not in changed_groups: - self.results.make_ref(dupe) - changed_groups.add(g) + if self.results.make_ref(dupe): + changed_groups.add(g) # It's not always obvious to users what this action does, so to make it a bit clearer, # we change our selection to the ref of all changed groups. However, we also want to keep # the files that were ref before and weren't changed by the action. In effect, what this # does is that we keep our old selection, but remove all non-ref dupes from it. - self.selected_dupes = [d for d in self.selected_dupes - if self.results.get_group_of_duplicate(d).ref is d] + # If no group was changed, however, we don't touch the selection. + if changed_groups: + self.selected_dupes = [d for d in self.selected_dupes + if self.results.get_group_of_duplicate(d).ref is d] self.notify('results_changed') def mark_all(self): diff --git a/core/engine.py b/core/engine.py index 6273a391..ae2ca956 100644 --- a/core/engine.py +++ b/core/engine.py @@ -325,14 +325,15 @@ class Group: def switch_ref(self, with_dupe): if self.ref.is_ref: - return + return False try: self.ordered.remove(with_dupe) self.ordered.insert(0, with_dupe) self._percentage = None self._matches_for_ref = None + return True except ValueError: - pass + return False dupes = property(lambda self: self[1:]) diff --git a/core/results.py b/core/results.py index fd2229d4..153d3d64 100644 --- a/core/results.py +++ b/core/results.py @@ -244,8 +244,9 @@ class Results(Markable): def make_ref(self, dupe): g = self.get_group_of_duplicate(dupe) r = g.ref + if not g.switch_ref(dupe): + return False self._remove_mark_flag(dupe) - g.switch_ref(dupe); if not r.is_ref: self.__total_count += 1 self.__total_size += r.size @@ -254,6 +255,7 @@ class Results(Markable): self.__total_size -= dupe.size self.__dupes = None self.is_modified = True + return True def perform_on_marked(self, func, remove_from_results): # Performs `func` on all marked dupes. If an EnvironmentError is raised during the call, From 35a162faf4d6031fbd7e783595ef6481f6d386d4 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 28 Apr 2013 14:32:57 -0400 Subject: [PATCH 2/2] Added "..." next to "Re-Prioritize Results" in cocoa's main menu. [#225 state:fixed] --- cocoa/base/en.lproj/Localizable.strings | 2 +- cocoa/base/ui/main_menu.py | 2 +- locale/core.pot | 12 ++++++------ locale/ui.pot | 12 ++++-------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cocoa/base/en.lproj/Localizable.strings b/cocoa/base/en.lproj/Localizable.strings index b9ba0b2b..477383ed 100644 --- a/cocoa/base/en.lproj/Localizable.strings +++ b/cocoa/base/en.lproj/Localizable.strings @@ -105,7 +105,7 @@ "Quick Look" = "Quick Look"; "Quit dupeGuru" = "Quit dupeGuru"; "Re-Prioritize duplicates" = "Re-Prioritize duplicates"; -"Re-Prioritize Results" = "Re-Prioritize Results"; +"Re-Prioritize Results..." = "Re-Prioritize Results..."; "Recreate absolute path" = "Recreate absolute path"; "Recreate relative path" = "Recreate relative path"; "Reference" = "Reference"; diff --git a/cocoa/base/ui/main_menu.py b/cocoa/base/ui/main_menu.py index c6d324a4..8696f501 100644 --- a/cocoa/base/ui/main_menu.py +++ b/cocoa/base/ui/main_menu.py @@ -52,7 +52,7 @@ actionMenu.addItem("Send Marked to Trash...", Action(None, 'trashMarked'), 'cmd+ actionMenu.addItem("Move Marked to...", Action(None, 'moveMarked'), 'cmd+m') actionMenu.addItem("Copy Marked to...", Action(None, 'copyMarked'), 'cmd+alt+m') actionMenu.addItem("Remove Marked from Results", Action(None, 'removeMarked'), 'cmd+r') -actionMenu.addItem("Re-Prioritize Results", Action(None, 'reprioritizeResults')) +actionMenu.addItem("Re-Prioritize Results...", Action(None, 'reprioritizeResults')) actionMenu.addSeparator() actionMenu.addItem("Remove Selected from Results", Action(None, 'removeSelected'), 'cmd+backspace') actionMenu.addItem("Add Selected to Ignore List", Action(None, 'ignoreSelected'), 'cmd+g') diff --git a/locale/core.pot b/locale/core.pot index 1254c3ed..39bb0a6d 100644 --- a/locale/core.pot +++ b/locale/core.pot @@ -72,23 +72,23 @@ msgstr "" msgid "You have no custom command set up. Set it up in your preferences." msgstr "" -#: core/app.py:502 core/app.py:513 +#: core/app.py:504 core/app.py:515 msgid "You are about to remove %d files from results. Continue?" msgstr "" -#: core/app.py:533 +#: core/app.py:535 msgid "{} duplicate groups were changed by the re-prioritization." msgstr "" -#: core/app.py:553 +#: core/app.py:555 msgid "Collecting files to scan" msgstr "" -#: core/app.py:564 +#: core/app.py:566 msgid "The selected directories contain no scannable file." msgstr "" -#: core/app.py:603 +#: core/app.py:605 msgid "%s (%d discarded)" msgstr "" @@ -104,7 +104,7 @@ msgstr "" msgid "Read size of %d/%d files" msgstr "" -#: core/engine.py:360 +#: core/engine.py:361 msgid "Grouped %d/%d matches" msgstr "" diff --git a/locale/ui.pot b/locale/ui.pot index 7622916d..9cf2be8a 100644 --- a/locale/ui.pot +++ b/locale/ui.pot @@ -118,7 +118,7 @@ msgid "" "Wait a few seconds, then try again." msgstr "" -#: qt/base/app.py:261 +#: qt/base/app.py:257 msgid "{} file (*.{})" msgstr "" @@ -241,7 +241,7 @@ msgstr "" msgid "All Files (*.*)" msgstr "" -#: qt/base/directories_dialog.py:206 qt/base/result_window.py:290 +#: qt/base/directories_dialog.py:206 qt/base/result_window.py:287 msgid "dupeGuru Results (*.dupeguru)" msgstr "" @@ -392,7 +392,7 @@ msgstr "" msgid "Remove Marked from Results" msgstr "" -#: qt/base/result_window.py:52 +#: qt/base/result_window.py:52 cocoa/base/en.lproj/Localizable.strings:0 msgid "Re-Prioritize Results..." msgstr "" @@ -476,7 +476,7 @@ msgstr "" msgid "Delta Values" msgstr "" -#: qt/base/result_window.py:289 cocoa/base/en.lproj/Localizable.strings:0 +#: qt/base/result_window.py:286 cocoa/base/en.lproj/Localizable.strings:0 msgid "Select a file to save your results to" msgstr "" @@ -798,10 +798,6 @@ msgstr "" msgid "Quit dupeGuru" msgstr "" -#: cocoa/base/en.lproj/Localizable.strings:0 -msgid "Re-Prioritize Results" -msgstr "" - #: cocoa/base/en.lproj/Localizable.strings:0 msgid "Remove Dead Tracks in iTunes" msgstr ""