mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-08 09:49:51 +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):
|
def remove_duplicates(self, duplicates):
|
||||||
self.results.remove_duplicates(duplicates)
|
self.results.remove_duplicates(duplicates)
|
||||||
|
|
||||||
|
def remove_selected(self):
|
||||||
|
self.remove_duplicates(self.selected_dupes)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if not op.exists(self.appdata):
|
if not op.exists(self.appdata):
|
||||||
os.makedirs(self.appdata)
|
os.makedirs(self.appdata)
|
||||||
|
@ -106,9 +106,6 @@ class DupeGuru(app.DupeGuru):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def RemoveSelected(self):
|
|
||||||
self.results.remove_duplicates(self.selected_dupes)
|
|
||||||
|
|
||||||
def RenameSelected(self, newname):
|
def RenameSelected(self, newname):
|
||||||
try:
|
try:
|
||||||
d = self.selected_dupes[0]
|
d = self.selected_dupes[0]
|
||||||
|
@ -106,7 +106,7 @@ class PyDupeGuruBase(PyApp):
|
|||||||
self.app.results.perform_on_marked(lambda x:True, True)
|
self.app.results.perform_on_marked(lambda x:True, True)
|
||||||
|
|
||||||
def removeSelected(self):
|
def removeSelected(self):
|
||||||
self.app.RemoveSelected()
|
self.app.remove_selected()
|
||||||
|
|
||||||
def renameSelected_(self,newname):
|
def renameSelected_(self,newname):
|
||||||
return self.app.RenameSelected(newname)
|
return self.app.RenameSelected(newname)
|
||||||
|
@ -150,7 +150,7 @@ class TCDupeGuru(TestCase):
|
|||||||
objects = self.objects
|
objects = self.objects
|
||||||
paths = [[0, 0], [0, 1], [1]]
|
paths = [[0, 0], [0, 1], [1]]
|
||||||
app.SelectResultNodePaths(paths)
|
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.
|
# 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
|
eq_(app.selected_result_node_paths(), [[0]]) # no exception
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ class TCDupeGuru(TestCase):
|
|||||||
objects = self.objects
|
objects = self.objects
|
||||||
paths = r2np([0, 1, 2])
|
paths = r2np([0, 1, 2])
|
||||||
app.SelectPowerMarkerNodePaths(paths)
|
app.SelectPowerMarkerNodePaths(paths)
|
||||||
app.RemoveSelected()
|
app.remove_selected()
|
||||||
eq_(app.selected_powermarker_node_paths(), []) # no exception
|
eq_(app.selected_powermarker_node_paths(), []) # no exception
|
||||||
|
|
||||||
def test_selectPowerMarkerRows(self):
|
def test_selectPowerMarkerRows(self):
|
||||||
@ -281,13 +281,13 @@ class TCDupeGuru(TestCase):
|
|||||||
def test_removeSelected(self):
|
def test_removeSelected(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
||||||
app.RemoveSelected()
|
app.remove_selected()
|
||||||
self.assertEqual(1,len(app.results.dupes))
|
eq_(len(app.results.dupes), 1)
|
||||||
app.RemoveSelected()
|
app.remove_selected()
|
||||||
self.assertEqual(1,len(app.results.dupes))
|
eq_(len(app.results.dupes), 1)
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
||||||
app.RemoveSelected()
|
app.remove_selected()
|
||||||
self.assertEqual(0,len(app.results.dupes))
|
eq_(len(app.results.dupes), 0)
|
||||||
|
|
||||||
def test_addDirectory_simple(self):
|
def test_addDirectory_simple(self):
|
||||||
# There's already a directory in self.app, so adding another once makes 2 of em
|
# 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)
|
DupeGuruBase.remove_duplicates(self, duplicates)
|
||||||
self.emit(SIGNAL('resultsChanged()'))
|
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
|
#--- Public
|
||||||
def askForRegCode(self):
|
def askForRegCode(self):
|
||||||
self.reg.ask_for_code()
|
self.reg.ask_for_code()
|
||||||
|
@ -248,13 +248,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.app.remove_marked_duplicates()
|
self.app.remove_marked_duplicates()
|
||||||
|
|
||||||
def removeSelectedTriggered(self):
|
def removeSelectedTriggered(self):
|
||||||
dupes = self.resultsView.selectedDupes()
|
self.app.remove_selected()
|
||||||
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)
|
|
||||||
|
|
||||||
def renameTriggered(self):
|
def renameTriggered(self):
|
||||||
self.resultsView.edit(self.resultsView.selectionModel().currentIndex())
|
self.resultsView.edit(self.resultsView.selectionModel().currentIndex())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user