mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
Load tree when all metadata has been loaded
This should build up the tree initially. Contributes to issue CURA-6600.
This commit is contained in:
parent
2565be01f3
commit
65b1a43e88
2 changed files with 17 additions and 2 deletions
|
@ -16,7 +16,18 @@ from typing import Dict
|
|||
class ContainerTree:
|
||||
def __init__(self) -> None:
|
||||
self.machines = {} # type: Dict[str, MachineNode] # Mapping from definition ID to machine nodes.
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self._machineAdded)
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
container_registry.allMetadataLoaded.connect(self._reloadAll)
|
||||
container_registry.containerAdded.connect(self._machineAdded)
|
||||
self._reloadAll()
|
||||
|
||||
## (Re)builds the initial container tree.
|
||||
def _reloadAll(self):
|
||||
all_stacks = ContainerRegistry.getInstance().findContainerStacks()
|
||||
for stack in all_stacks:
|
||||
definition_id = stack.definition.getId()
|
||||
if definition_id not in self.machines:
|
||||
self.machines[definition_id] = MachineNode(definition_id)
|
||||
|
||||
## When a printer gets added, we need to build up the tree for that container.
|
||||
def _machineAdded(self, definition_container: ContainerInterface):
|
||||
|
|
|
@ -19,10 +19,14 @@ class MachineNode(ContainerNode):
|
|||
super().__init__(container_id, None)
|
||||
self.variants = {} # type: Dict[str, VariantNode] # mapping variant names to their nodes.
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
container_registry.allMetadataLoaded.connect(self._reloadAll)
|
||||
container_registry.containerAdded.connect(self._variantAdded)
|
||||
self._reloadAll()
|
||||
|
||||
## (Re)loads all variants under this printer.
|
||||
def _reloadAll(self):
|
||||
# Find all the variants for this definition ID.
|
||||
variants = container_registry.findInstanceContainersMetadata(type = "variant", definition = self.container_id, hardware_type = "nozzle")
|
||||
variants = ContainerRegistry.getInstance().findInstanceContainersMetadata(type = "variant", definition = self.container_id, hardware_type = "nozzle")
|
||||
for variant in variants:
|
||||
variant_name = variant["name"]
|
||||
if variant_name not in self.variants:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue