mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Removed logic duplication across toolkit code in "Remove Selected" action.
This commit is contained in:
parent
37238c7f57
commit
8edb869fdc
@ -235,6 +235,9 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
def remove_duplicates(self, duplicates):
|
||||
self.results.remove_duplicates(duplicates)
|
||||
|
||||
def remove_selected(self):
|
||||
self.remove_duplicates(self.selected_dupes)
|
||||
|
||||
def save(self):
|
||||
if not op.exists(self.appdata):
|
||||
os.makedirs(self.appdata)
|
||||
|
@ -106,9 +106,6 @@ class DupeGuru(app.DupeGuru):
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
def RemoveSelected(self):
|
||||
self.results.remove_duplicates(self.selected_dupes)
|
||||
|
||||
def RenameSelected(self, newname):
|
||||
try:
|
||||
d = self.selected_dupes[0]
|
||||
|
@ -106,7 +106,7 @@ class PyDupeGuruBase(PyApp):
|
||||
self.app.results.perform_on_marked(lambda x:True, True)
|
||||
|
||||
def removeSelected(self):
|
||||
self.app.RemoveSelected()
|
||||
self.app.remove_selected()
|
||||
|
||||
def renameSelected_(self,newname):
|
||||
return self.app.RenameSelected(newname)
|
||||
|
@ -150,7 +150,7 @@ class TCDupeGuru(TestCase):
|
||||
objects = self.objects
|
||||
paths = [[0, 0], [0, 1], [1]]
|
||||
app.SelectResultNodePaths(paths)
|
||||
app.RemoveSelected()
|
||||
app.remove_selected()
|
||||
# The first 2 dupes have been removed. The 3rd one is a ref. it stays there, in first pos.
|
||||
eq_(app.selected_result_node_paths(), [[0]]) # no exception
|
||||
|
||||
@ -206,7 +206,7 @@ class TCDupeGuru(TestCase):
|
||||
objects = self.objects
|
||||
paths = r2np([0, 1, 2])
|
||||
app.SelectPowerMarkerNodePaths(paths)
|
||||
app.RemoveSelected()
|
||||
app.remove_selected()
|
||||
eq_(app.selected_powermarker_node_paths(), []) # no exception
|
||||
|
||||
def test_selectPowerMarkerRows(self):
|
||||
@ -281,13 +281,13 @@ class TCDupeGuru(TestCase):
|
||||
def test_removeSelected(self):
|
||||
app = self.app
|
||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
||||
app.RemoveSelected()
|
||||
self.assertEqual(1,len(app.results.dupes))
|
||||
app.RemoveSelected()
|
||||
self.assertEqual(1,len(app.results.dupes))
|
||||
app.remove_selected()
|
||||
eq_(len(app.results.dupes), 1)
|
||||
app.remove_selected()
|
||||
eq_(len(app.results.dupes), 1)
|
||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
||||
app.RemoveSelected()
|
||||
self.assertEqual(0,len(app.results.dupes))
|
||||
app.remove_selected()
|
||||
eq_(len(app.results.dupes), 0)
|
||||
|
||||
def test_addDirectory_simple(self):
|
||||
# There's already a directory in self.app, so adding another once makes 2 of em
|
||||
|
@ -169,6 +169,15 @@ class DupeGuru(DupeGuruBase, QObject):
|
||||
DupeGuruBase.remove_duplicates(self, duplicates)
|
||||
self.emit(SIGNAL('resultsChanged()'))
|
||||
|
||||
def remove_selected(self):
|
||||
dupes = self.without_ref(self.selected_dupes)
|
||||
if not dupes:
|
||||
return
|
||||
title = "Remove duplicates"
|
||||
msg = "You are about to remove {0} files from results. Continue?".format(len(dupes))
|
||||
if self.main_window._confirm(title, msg):
|
||||
DupeGuruBase.remove_selected(self)
|
||||
|
||||
#--- Public
|
||||
def askForRegCode(self):
|
||||
self.reg.ask_for_code()
|
||||
|
@ -248,13 +248,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.app.remove_marked_duplicates()
|
||||
|
||||
def removeSelectedTriggered(self):
|
||||
dupes = self.resultsView.selectedDupes()
|
||||
if not dupes:
|
||||
return
|
||||
title = "Remove duplicates"
|
||||
msg = "You are about to remove {0} files from results. Continue?".format(len(dupes))
|
||||
if self._confirm(title, msg):
|
||||
self.app.remove_duplicates(dupes)
|
||||
self.app.remove_selected()
|
||||
|
||||
def renameTriggered(self):
|
||||
self.resultsView.edit(self.resultsView.selectionModel().currentIndex())
|
||||
|
Loading…
x
Reference in New Issue
Block a user