[#179] Pushed the delete-or-exclude folder down from GUI layers to the core.

This commit is contained in:
Virgil Dupras 2011-11-28 14:52:48 -05:00
parent 3342b32882
commit 756190cb8e
3 changed files with 12 additions and 22 deletions

View File

@ -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];
}

View File

@ -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:

View File

@ -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: