[#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;
}
[removeButton setEnabled:YES];
NSInteger state = [outline intProperty:@"state" valueAtPath:[outline selectedIndexPath]];
NSString *imgName = state == 2 ? @"NSGoLeftTemplate" : @"NSRemoveTemplate";
NSIndexPath *path = [outline selectedIndexPath];
NSInteger state = [outline intProperty:@"state" valueAtPath:path];
BOOL shouldDisplayArrow = ([path length] > 1) && (state == 2);
NSString *imgName = shouldDisplayArrow ? @"NSGoLeftTemplate" : @"NSRemoveTemplate";
[removeButton setImage:[NSImage imageNamed:imgName]];
}

View File

@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">1617</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<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>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSTextField</string>
@ -31,7 +31,10 @@
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</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">
<object class="NSCustomObject" id="566600593">
<string key="NSClassName">DirectoryPanel</string>
@ -233,7 +236,7 @@
</object>
</object>
<double key="NSRowHeight">14</double>
<int key="NSTvFlags">1379958784</int>
<int key="NSTvFlags">1514176512</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<int key="NSColumnAutoresizingStyle">1</int>
@ -510,14 +513,6 @@
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<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="IBOutletConnection" key="connection">
<string key="label">window</string>
@ -542,14 +537,6 @@
</object>
<int key="connectionID">54</int>
</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="IBActionConnection" key="connection">
<string key="label">removeSelectedDirectory:</string>
@ -590,6 +577,22 @@
</object>
<int key="connectionID">78</int>
</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>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -1025,6 +1028,17 @@
<object class="IBPartialClassDescription">
<string key="className">HSOutlineView</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">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/HSOutlineView.h</string>
@ -1064,7 +1078,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<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 class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>

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:

View File

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