diff options
author | fieldOfView <aldo@fieldofview.com> | 2021-04-19 23:14:14 +0300 |
---|---|---|
committer | fieldOfView <aldo@fieldofview.com> | 2021-04-19 23:14:14 +0300 |
commit | 0ad49dd41217ebe295685484da78cfb6c57c84a1 (patch) | |
tree | 7ff92eccfc7ac107969fcbb2f43b7e6daa1c7f44 /cura/UI | |
parent | 7e98fb7fb065b6d672ecc808f7747d962c05f681 (diff) |
Allow renaming groups to something other than "Group #n"
Diffstat (limited to 'cura/UI')
-rw-r--r-- | cura/UI/ObjectsModel.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/cura/UI/ObjectsModel.py b/cura/UI/ObjectsModel.py index 02d4096278..0c109d7a4a 100644 --- a/cura/UI/ObjectsModel.py +++ b/cura/UI/ObjectsModel.py @@ -132,30 +132,35 @@ 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 - name = node.getName() - - name_match = self._naming_regex.fullmatch(name) - if name_match is None: - original_name = name - name_index = 0 - else: - original_name = name_match.groups()[0] - name_index = int(name_match.groups()[1]) - else: + 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]) - else: + 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) + if name_match is None: + original_name = name + name_index = 0 + else: + original_name = name_match.groups()[0] + name_index = int(name_match.groups()[1]) if original_name not in name_to_node_info_dict: # Keep track of 2 things: |