mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 01:26:01 +08:00
Document _uniqueName
This function should really just be moved to ContainerRegistry... I'll do that later. Contributes to issues CURA-340 and CURA-1278.
This commit is contained in:
parent
dff94b4559
commit
66bf0831f3
@ -176,7 +176,14 @@ class ExtruderManager(QObject):
|
|||||||
|
|
||||||
container_registry.addContainer(container_stack)
|
container_registry.addContainer(container_stack)
|
||||||
|
|
||||||
|
## Creates a new unique name for a container that doesn't exist yet.
|
||||||
|
#
|
||||||
|
# It tries if the original name you provide exists, and if it doesn't
|
||||||
|
# it'll add a " #1" or " #2" after the name to make it unique.
|
||||||
|
#
|
||||||
|
# \param original The original name that may not be unique.
|
||||||
|
# \return A unique name that looks a lot like the original but may have
|
||||||
|
# a number behind it to make it unique.
|
||||||
def _uniqueName(self, original):
|
def _uniqueName(self, original):
|
||||||
container_registry = UM.Settings.ContainerRegistry.getInstance()
|
container_registry = UM.Settings.ContainerRegistry.getInstance()
|
||||||
|
|
||||||
@ -189,8 +196,7 @@ class ExtruderManager(QObject):
|
|||||||
unique_name = name
|
unique_name = name
|
||||||
|
|
||||||
i = 1
|
i = 1
|
||||||
while container_registry.findContainers(id=unique_name) or container_registry.findContainers(
|
while container_registry.findContainers(id = unique_name) or container_registry.findContainers(name = unique_name): # A container already has this name.
|
||||||
name=unique_name): # A container already has this name.
|
|
||||||
i += 1 # Try next numbering.
|
i += 1 # Try next numbering.
|
||||||
unique_name = "%s #%d" % (name, i) # Fill name like this: "Extruder #2".
|
unique_name = "%s #%d" % (name, i) # Fill name like this: "Extruder #2".
|
||||||
return unique_name
|
return unique_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user