Delete selection now also removed group nodes when they only have one child left

CURA-1891
This commit is contained in:
Jaime van Kessel 2016-07-29 11:00:28 +02:00
parent 1ed0503e02
commit 21d4e9b894

View file

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