Added delete to the sidebar context and gear menus. Issue #328

This commit is contained in:
Maurice Parker
2018-09-25 21:10:54 -05:00
parent d738bff2ad
commit 89bdcc7a61
2 changed files with 38 additions and 27 deletions

View File

@@ -127,25 +127,7 @@ import RSCore
if outlineView.selectionIsEmpty {
return
}
let nodesToDelete = treeController.normalizedSelectedNodes(selectedNodes)
guard let undoManager = undoManager, let deleteCommand = DeleteFromSidebarCommand(nodesToDelete: nodesToDelete, treeController: treeController, undoManager: undoManager) else {
return
}
animatingChanges = true
outlineView.beginUpdates()
let indexSetsGroupedByParent = Node.indexSetsGroupedByParent(nodesToDelete)
for (parent, indexSet) in indexSetsGroupedByParent {
outlineView.removeItems(at: indexSet, inParent: parent.isRoot ? nil : parent, withAnimation: [.slideDown])
}
outlineView.endUpdates()
runCommand(deleteCommand)
animatingChanges = false
deleteNodes(selectedNodes)
}
@IBAction func openInBrowser(_ sender: Any?) {
@@ -278,6 +260,31 @@ import RSCore
postSidebarSelectionDidChangeNotification(selectedObjects.isEmpty ? nil : selectedObjects)
}
//MARK: - Node Manipulation
func deleteNodes(_ nodes: [Node]) {
let nodesToDelete = treeController.normalizedSelectedNodes(nodes)
guard let undoManager = undoManager, let deleteCommand = DeleteFromSidebarCommand(nodesToDelete: nodesToDelete, treeController: treeController, undoManager: undoManager) else {
return
}
animatingChanges = true
outlineView.beginUpdates()
let indexSetsGroupedByParent = Node.indexSetsGroupedByParent(nodesToDelete)
for (parent, indexSet) in indexSetsGroupedByParent {
outlineView.removeItems(at: indexSet, inParent: parent.isRoot ? nil : parent, withAnimation: [.slideDown])
}
outlineView.endUpdates()
runCommand(deleteCommand)
animatingChanges = false
}
}
// MARK: - NSUserInterfaceValidations