Simplify the renameNodes method

Especially when duplicating large amounts of items this would cause a bit of a slowdown

CURA-7106
This commit is contained in:
Jaime van Kessel 2020-06-23 10:14:44 +02:00
parent ba34fb6e35
commit 46076bf21d
No known key found for this signature in database
GPG key ID: 3710727397403C91

View file

@ -98,7 +98,8 @@ class ObjectsModel(ListModel):
return True
def _renameNodes(self, node_info_dict: Dict[str, _NodeInfo]) -> List[SceneNode]:
@staticmethod
def _renameNodes(node_info_dict: Dict[str, _NodeInfo]) -> List[SceneNode]:
# Go through all names and find out the names for all nodes that need to be renamed.
all_nodes = [] # type: List[SceneNode]
for name, node_info in node_info_dict.items():
@ -118,9 +119,7 @@ class ObjectsModel(ListModel):
else:
new_group_name = "{0}#{1}".format(name, current_index)
old_name = node.getName()
node.setName(new_group_name)
Logger.log("d", "Node [%s] renamed to [%s]", old_name, new_group_name)
all_nodes.append(node)
return all_nodes