diff --git a/cocoa/base/DirectoryPanel.m b/cocoa/base/DirectoryPanel.m index 0511b905..9d12f00d 100644 --- a/cocoa/base/DirectoryPanel.m +++ b/cocoa/base/DirectoryPanel.m @@ -100,18 +100,8 @@ http://www.hardcoded.net/licenses/bsd_license - (IBAction)removeSelectedDirectory:(id)sender { [[self window] makeKeyAndOrderFront:nil]; - if ([outlineView selectedRow] < 0) - return; - NSIndexPath *path = [outline selectedIndexPath]; - NSInteger state = [outline intProperty:@"state" valueAtPath:path]; - if (([path length] == 1) && (state != 2)) { - [[outline py] removeSelectedDirectory]; - } - else { - NSInteger newState = state == 2 ? 0 : 2; // If excluded, put it back - [outline setIntProperty:@"state" value:newState atPath:path]; - [outlineView display]; - } + [[outline py] removeSelectedDirectory]; + [outlineView setNeedsDisplay:YES]; [self refreshRemoveButtonText]; } diff --git a/core/gui/directory_tree.py b/core/gui/directory_tree.py index 68589349..ea9bdfb8 100644 --- a/core/gui/directory_tree.py +++ b/core/gui/directory_tree.py @@ -77,9 +77,15 @@ class DirectoryTree(GUIObject, Tree): self.app.add_directory(path) def remove_selected(self): - assert len(self.selected_path) == 1 - root_index = self.selected_path[0] - self.app.remove_directory(root_index) + selected_node = self.selected_node + if selected_node is None: + 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) + else: + newstate = DirectoryState.Normal if selected_node.state == DirectoryState.Excluded else DirectoryState.Excluded + selected_node.state = newstate def update_all_states(self): for node in self: diff --git a/qt/base/directories_dialog.py b/qt/base/directories_dialog.py index 48e9d22b..1612fa0b 100644 --- a/qt/base/directories_dialog.py +++ b/qt/base/directories_dialog.py @@ -208,13 +208,7 @@ class DirectoriesDialog(QMainWindow): self.app.recentResults.insertItem(destination) def removeFolderButtonClicked(self): - indexes = self.treeView.selectedIndexes() - if not indexes: - return - index = indexes[0] - node = index.internalPointer() - if node.parent is None: - self.directoriesModel.model.remove_selected() + self.directoriesModel.model.remove_selected() def scanButtonClicked(self): if self.app.model.results.is_modified: