From 21d4e9b8942532744dde1d149beb1358d760c723 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Jul 2016 11:00:28 +0200 Subject: [PATCH] Delete selection now also removed group nodes when they only have one child left CURA-1891 --- cura/CuraApplication.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index bc4378feff..2de70b7304 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -555,12 +555,19 @@ class CuraApplication(QtApplication): def deleteSelection(self): if not self.getController().getToolsEnabled(): return - + removed_group_nodes = [] op = GroupedOperation() nodes = Selection.getAllSelectedObjects() for node in nodes: op.addOperation(RemoveSceneNodeOperation(node)) - + group_node = node.getParent() + if group_node and group_node.callDecoration("isGroup") and group_node not in removed_group_nodes: + remaining_nodes_in_group = list(set(group_node.getChildren()) - set(nodes)) + if len(remaining_nodes_in_group) == 1: + removed_group_nodes.append(group_node) + remaining_nodes_in_group[0].translate(group_node.getPosition()) + remaining_nodes_in_group[0].setParent(group_node.getParent()) + op.addOperation(RemoveSceneNodeOperation(group_node)) op.push() pass