Merge branch 'fix_group_rename' of https://github.com/fieldOfView/Cura

This commit is contained in:
Jaime van Kessel 2021-04-28 17:07:33 +02:00
commit 95652556fe
No known key found for this signature in database
GPG key ID: 3710727397403C91
2 changed files with 20 additions and 15 deletions

View file

@ -132,9 +132,26 @@ class ObjectsModel(ListModel):
is_group = bool(node.callDecoration("isGroup"))
name_handled_as_group = False
force_rename = False
if not is_group:
# Handle names for individual nodes
if is_group:
# Handle names for grouped nodes
original_name = self._group_name_prefix
current_name = node.getName()
if current_name.startswith(self._group_name_prefix):
# This group has a standard group name, but we may need to renumber it
name_index = int(current_name.split("#")[-1])
name_handled_as_group = True
elif not current_name:
# Force rename this group because this node has not been named as a group yet, probably because
# it's a newly created group.
name_index = 0
force_rename = True
name_handled_as_group = True
if not is_group or not name_handled_as_group:
# Handle names for individual nodes or groups that already have a non-group name
name = node.getName()
name_match = self._naming_regex.fullmatch(name)
@ -144,18 +161,6 @@ class ObjectsModel(ListModel):
else:
original_name = name_match.groups()[0]
name_index = int(name_match.groups()[1])
else:
# Handle names for grouped nodes
original_name = self._group_name_prefix
current_name = node.getName()
if current_name.startswith(self._group_name_prefix):
name_index = int(current_name.split("#")[-1])
else:
# Force rename this group because this node has not been named as a group yet, probably because
# it's a newly created group.
name_index = 0
force_rename = True
if original_name not in name_to_node_info_dict:
# Keep track of 2 things:

View file

@ -217,7 +217,7 @@ class Test_Update:
with patch("UM.Application.Application.getInstance", MagicMock(return_value=application_with_mocked_scene)):
objects_model._update()
assert objects_model.items == [{
'name': 'Group #1',
'name': 'Group',
'selected': False,
'outside_build_area': True,
'buildplate_number': None,