1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

[#179 state:fixed] Added multiple-selection to the folder selection dialog and thus added the ability to remove multiple folders at once.

This commit is contained in:
Virgil Dupras
2011-11-28 15:25:18 -05:00
parent 756190cb8e
commit 1b7068bfe9
5 changed files with 60 additions and 35 deletions

View File

@@ -368,9 +368,11 @@ class DupeGuru(RegistrableApplication, Broadcaster):
def purge_ignore_list(self):
self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s))
def remove_directory(self,index):
def remove_directories(self, indexes):
try:
del self.directories[index]
indexes = sorted(indexes, reverse=True)
for index in indexes:
del self.directories[index]
self.notify('directories_changed')
except IndexError:
pass

View File

@@ -77,15 +77,20 @@ class DirectoryTree(GUIObject, Tree):
self.app.add_directory(path)
def remove_selected(self):
selected_node = self.selected_node
if selected_node is None:
selected_paths = self.selected_paths
if not selected_paths:
return
if selected_node.parent is self and selected_node.state != DirectoryState.Excluded:
root_index = self.selected_path[0]
self.app.remove_directory(root_index)
to_delete = [path[0] for path in selected_paths if len(path) == 1]
if to_delete:
self.app.remove_directories(to_delete)
else:
newstate = DirectoryState.Normal if selected_node.state == DirectoryState.Excluded else DirectoryState.Excluded
selected_node.state = newstate
# All selected nodes or on second-or-more level, exclude them.
nodes = self.selected_nodes
newstate = DirectoryState.Excluded
if all(node.state == DirectoryState.Excluded for node in nodes):
newstate = DirectoryState.Normal
for node in nodes:
node.state = newstate
def update_all_states(self):
for node in self: