1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2025-03-10 05:34:36 +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

@ -130,8 +130,10 @@ http://www.hardcoded.net/licenses/bsd_license
return; return;
} }
[removeButton setEnabled:YES]; [removeButton setEnabled:YES];
NSInteger state = [outline intProperty:@"state" valueAtPath:[outline selectedIndexPath]]; NSIndexPath *path = [outline selectedIndexPath];
NSString *imgName = state == 2 ? @"NSGoLeftTemplate" : @"NSRemoveTemplate"; NSInteger state = [outline intProperty:@"state" valueAtPath:path];
BOOL shouldDisplayArrow = ([path length] > 1) && (state == 2);
NSString *imgName = shouldDisplayArrow ? @"NSGoLeftTemplate" : @"NSRemoveTemplate";
[removeButton setImage:[NSImage imageNamed:imgName]]; [removeButton setImage:[NSImage imageNamed:imgName]];
} }

View File

@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00"> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data> <data>
<int key="IBDocument.SystemTarget">1060</int> <int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">11B26</string> <string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.InterfaceBuilderVersion">1617</string> <string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138</string> <string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">566.00</string> <string key="IBDocument.HIToolboxVersion">567.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1617</string> <string key="NS.object.0">1938</string>
</object> </object>
<array key="IBDocument.IntegratedClassDependencies"> <array key="IBDocument.IntegratedClassDependencies">
<string>NSTextField</string> <string>NSTextField</string>
@ -31,7 +31,10 @@
<array key="IBDocument.PluginDependencies"> <array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array> </array>
<dictionary class="NSMutableDictionary" key="IBDocument.Metadata"/> <object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="238648523"> <array class="NSMutableArray" key="IBDocument.RootObjects" id="238648523">
<object class="NSCustomObject" id="566600593"> <object class="NSCustomObject" id="566600593">
<string key="NSClassName">DirectoryPanel</string> <string key="NSClassName">DirectoryPanel</string>
@ -233,7 +236,7 @@
</object> </object>
</object> </object>
<double key="NSRowHeight">14</double> <double key="NSRowHeight">14</double>
<int key="NSTvFlags">1379958784</int> <int key="NSTvFlags">1514176512</int>
<reference key="NSDelegate"/> <reference key="NSDelegate"/>
<reference key="NSDataSource"/> <reference key="NSDataSource"/>
<int key="NSColumnAutoresizingStyle">1</int> <int key="NSColumnAutoresizingStyle">1</int>
@ -510,14 +513,6 @@
</array> </array>
<object class="IBObjectContainer" key="IBDocument.Objects"> <object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords"> <array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">initialFirstResponder</string>
<reference key="source" ref="970147395"/>
<reference key="destination" ref="10140319"/>
</object>
<int key="connectionID">19</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
<string key="label">window</string> <string key="label">window</string>
@ -542,14 +537,6 @@
</object> </object>
<int key="connectionID">54</int> <int key="connectionID">54</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">startScanning:</string>
<reference key="source" ref="244639324"/>
<reference key="destination" ref="580397230"/>
</object>
<int key="connectionID">60</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection"> <object class="IBActionConnection" key="connection">
<string key="label">removeSelectedDirectory:</string> <string key="label">removeSelectedDirectory:</string>
@ -590,6 +577,22 @@
</object> </object>
<int key="connectionID">78</int> <int key="connectionID">78</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">startScanning:</string>
<reference key="source" ref="244639324"/>
<reference key="destination" ref="580397230"/>
</object>
<int key="connectionID">60</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">initialFirstResponder</string>
<reference key="source" ref="970147395"/>
<reference key="destination" ref="10140319"/>
</object>
<int key="connectionID">19</int>
</object>
</array> </array>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects"> <array key="orderedObjects">
@ -1025,6 +1028,17 @@
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">HSOutlineView</string> <string key="className">HSOutlineView</string>
<string key="superclassName">NSOutlineView</string> <string key="superclassName">NSOutlineView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">copy:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">copy:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">copy:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier"> <object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string> <string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/HSOutlineView.h</string> <string key="minorKey">./Classes/HSOutlineView.h</string>
@ -1064,7 +1078,7 @@
</object> </object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/> <real value="1060" key="NS.object.0"/>
</object> </object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>

View File

@ -368,8 +368,10 @@ class DupeGuru(RegistrableApplication, Broadcaster):
def purge_ignore_list(self): def purge_ignore_list(self):
self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s)) 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: try:
indexes = sorted(indexes, reverse=True)
for index in indexes:
del self.directories[index] del self.directories[index]
self.notify('directories_changed') self.notify('directories_changed')
except IndexError: except IndexError:

View File

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

View File

@ -108,6 +108,8 @@ class DirectoriesDialog(QMainWindow):
self.promptLabel = QLabel(tr("Select folders to scan and press \"Scan\"."), self.centralwidget) self.promptLabel = QLabel(tr("Select folders to scan and press \"Scan\"."), self.centralwidget)
self.verticalLayout.addWidget(self.promptLabel) self.verticalLayout.addWidget(self.promptLabel)
self.treeView = QTreeView(self.centralwidget) self.treeView = QTreeView(self.centralwidget)
self.treeView.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.treeView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.treeView.setAcceptDrops(True) self.treeView.setAcceptDrops(True)
triggers = QAbstractItemView.DoubleClicked|QAbstractItemView.EditKeyPressed\ triggers = QAbstractItemView.DoubleClicked|QAbstractItemView.EditKeyPressed\
|QAbstractItemView.SelectedClicked |QAbstractItemView.SelectedClicked