Browse Source

Remove (all?, most?) deprecated ContainerNode.getMetaDataEntry calls.

part of CURA-6600
Remco Burema 5 years ago
parent
commit
507cb356d2

+ 1 - 1
cura/Machines/MachineNode.py

@@ -70,7 +70,7 @@ class MachineNode(ContainerNode):
         # Create the quality group for each available type.
         quality_groups = {}
         for quality_type, global_quality_node in self.global_qualities.items():
-            quality_groups[quality_type] = QualityGroup(name = global_quality_node.getMetaDataEntry("name", "Unnamed profile"), quality_type = quality_type)
+            quality_groups[quality_type] = QualityGroup(name = global_quality_node.container.getMetaDataEntry("name", "Unnamed profile"), quality_type = quality_type)
             quality_groups[quality_type].node_for_global = global_quality_node
             for extruder, qualities_per_type in qualities_per_type_per_extruder:
                 quality_groups[quality_type].nodes_for_extruders[extruder] = qualities_per_type[quality_type]

+ 4 - 4
cura/Machines/MaterialManager.py

@@ -247,7 +247,7 @@ class MaterialManager(QObject):
         # Check if the material is active in any extruder train. In that case, the material shouldn't be removed!
         # In the future we might enable this again, but right now, it's causing a ton of issues if we do (since it
         # corrupts the configuration)
-        root_material_id = material_node.getMetaDataEntry("base_file")
+        root_material_id = material_node.container.getMetaDataEntry("base_file")
         ids_to_remove = [metadata.get("id", "") for metadata in CuraContainerRegistry.getInstance().findInstanceContainersMetadata(base_file=root_material_id)]
 
         for extruder_stack in CuraContainerRegistry.getInstance().findContainerStacks(type = "extruder_train"):
@@ -257,7 +257,7 @@ class MaterialManager(QObject):
 
     @pyqtSlot("QVariant", str)
     def setMaterialName(self, material_node: "MaterialNode", name: str) -> None:
-        root_material_id = material_node.getMetaDataEntry("base_file")
+        root_material_id = material_node.container.getMetaDataEntry("base_file")
         if root_material_id is None:
             return
         if CuraContainerRegistry.getInstance().isReadOnly(root_material_id):
@@ -268,7 +268,7 @@ class MaterialManager(QObject):
 
     @pyqtSlot("QVariant")
     def removeMaterial(self, material_node: "MaterialNode") -> None:
-        root_material_id = material_node.getMetaDataEntry("base_file")
+        root_material_id = material_node.container.getMetaDataEntry("base_file")
         if root_material_id is not None:
             self.removeMaterialByRootId(root_material_id)
 
@@ -332,7 +332,7 @@ class MaterialManager(QObject):
     #
     @pyqtSlot("QVariant", result = str)
     def duplicateMaterial(self, material_node: MaterialNode, new_base_id: Optional[str] = None, new_metadata: Dict[str, Any] = None) -> Optional[str]:
-        root_material_id = cast(str, material_node.getMetaDataEntry("base_file", ""))
+        root_material_id = cast(str, material_node.container.getMetaDataEntry("base_file", ""))
         return self.duplicateMaterialByRootId(root_material_id, new_base_id, new_metadata)
 
     # Create a new material by cloning Generic PLA for the current material diameter and generate a new GUID.

+ 1 - 1
cura/Machines/Models/FavoriteMaterialsModel.py

@@ -29,7 +29,7 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
 
         for root_material_id, container_node in self._available_materials.items():
             # Do not include the materials from a to-be-removed package
-            if bool(container_node.getMetaDataEntry("removed", False)):
+            if bool(container_node.container.getMetaDataEntry("removed", False)):
                 continue
 
             # Only add results for favorite materials

+ 2 - 2
cura/Machines/Models/GenericMaterialsModel.py

@@ -20,11 +20,11 @@ class GenericMaterialsModel(BaseMaterialsModel):
 
         for root_material_id, container_node in self._available_materials.items():
             # Do not include the materials from a to-be-removed package
-            if bool(container_node.getMetaDataEntry("removed", False)):
+            if bool(container_node.container.getMetaDataEntry("removed", False)):
                 continue
 
             # Only add results for generic materials
-            if container_node.getMetaDataEntry("brand", "unknown").lower() != "generic":
+            if container_node.container.getMetaDataEntry("brand", "unknown").lower() != "generic":
                 continue
 
             item = self._createMaterialItem(root_material_id, container_node)

+ 3 - 3
cura/Machines/Models/MaterialBrandsModel.py

@@ -38,18 +38,18 @@ class MaterialBrandsModel(BaseMaterialsModel):
         # Part 1: Generate the entire tree of brands -> material types -> spcific materials
         for root_material_id, container_node in self._available_materials.items():
             # Do not include the materials from a to-be-removed package
-            if bool(container_node.getMetaDataEntry("removed", False)):
+            if bool(container_node.container.getMetaDataEntry("removed", False)):
                 continue
 
             # Add brands we haven't seen yet to the dict, skipping generics
-            brand = container_node.getMetaDataEntry("brand", "")
+            brand = container_node.container.getMetaDataEntry("brand", "")
             if brand.lower() == "generic":
                 continue
             if brand not in brand_group_dict:
                 brand_group_dict[brand] = {}
 
             # Add material types we haven't seen yet to the dict
-            material_type = container_node.getMetaDataEntry("material", "")
+            material_type = container_node.container.getMetaDataEntry("material", "")
             if material_type not in brand_group_dict[brand]:
                 brand_group_dict[brand][material_type] = []
 

+ 2 - 2
cura/Machines/QualityChangesGroup.py

@@ -18,10 +18,10 @@ class QualityChangesGroup(QualityGroup):
         self._container_registry = Application.getInstance().getContainerRegistry()
 
     def addNode(self, node: "QualityNode") -> None:
-        extruder_position = node.getMetaDataEntry("position")
+        extruder_position = node.container.getMetaDataEntry("position")
 
         if extruder_position is None and self.node_for_global is not None or extruder_position in self.nodes_for_extruders: #We would be overwriting another node.
-            ConfigurationErrorMessage.getInstance().addFaultyContainers(node.getMetaDataEntry("id"))
+            ConfigurationErrorMessage.getInstance().addFaultyContainers(node.container_id)
             return
 
         if extruder_position is None:  # Then we're a global quality changes profile.

+ 2 - 2
cura/Machines/QualityGroup.py

@@ -60,12 +60,12 @@ class QualityGroup(QObject):
         self.node_for_global = node
 
         # Update is_experimental flag
-        is_experimental = parseBool(node.getMetaDataEntry("is_experimental", False))
+        is_experimental = parseBool(node.container.getMetaDataEntry("is_experimental", False))
         self.is_experimental |= is_experimental
 
     def setExtruderNode(self, position: int, node: "ContainerNode") -> None:
         self.nodes_for_extruders[position] = node
 
         # Update is_experimental flag
-        is_experimental = parseBool(node.getMetaDataEntry("is_experimental", False))
+        is_experimental = parseBool(node.container.getMetaDataEntry("is_experimental", False))
         self.is_experimental |= is_experimental

+ 1 - 1
cura/Machines/QualityManager.py

@@ -165,7 +165,7 @@ class QualityManager(QObject):
         Logger.log("i", "Removing quality changes group [%s]", quality_changes_group.name)
         removed_quality_changes_ids = set()
         for node in quality_changes_group.getAllNodes():
-            container_id = node.getMetaDataEntry("id")
+            container_id = node.container_id
             self._container_registry.removeContainer(container_id)
             removed_quality_changes_ids.add(container_id)
 

+ 3 - 3
cura/Settings/ContainerManager.py

@@ -83,7 +83,7 @@ class ContainerManager(QObject):
     #  Update: In order for QML to use objects and sub objects, those (sub) objects must all be QObject. Is that what we want?
     @pyqtSlot("QVariant", str, str)
     def setContainerMetaDataEntry(self, container_node: "ContainerNode", entry_name: str, entry_value: str) -> bool:
-        root_material_id = container_node.getMetaDataEntry("base_file", "")
+        root_material_id = container_node.container.getMetaDataEntry("base_file", "")
         if cura.CuraApplication.CuraApplication.getInstance().getContainerRegistry().isReadOnly(root_material_id):
             Logger.log("w", "Cannot set metadata of read-only container %s.", root_material_id)
             return False
@@ -99,7 +99,7 @@ class ContainerManager(QObject):
         sub_item_changed = False
         if entries:
             root_name = entries.pop(0)
-            root = material_group.root_material_node.getMetaDataEntry(root_name)
+            root = material_group.root_material_node.container.getMetaDataEntry(root_name)
 
             item = root
             for _ in range(len(entries)):
@@ -341,7 +341,7 @@ class ContainerManager(QObject):
     @pyqtSlot("QVariant")
     def unlinkMaterial(self, material_node: "MaterialNode") -> None:
         # Get the material group
-        material_group = MaterialManager.getInstance().getMaterialGroup(material_node.getMetaDataEntry("base_file", ""))
+        material_group = MaterialManager.getInstance().getMaterialGroup(material_node.container.getMetaDataEntry("base_file", ""))
 
         if material_group is None:
             Logger.log("w", "Unable to find material group for %s", material_node)

+ 3 - 3
cura/Settings/IntentManager.py

@@ -81,7 +81,7 @@ class IntentManager(QObject):
         available_quality_types = {quality_group.quality_type for quality_group in quality_groups.values() if quality_group.node_for_global is not None}
 
         final_intent_ids = set()  # type: Set[str]
-        current_definition_id = global_stack.definition.getMetaDataEntry("id")
+        current_definition_id = global_stack.definition.getId()
         for extruder_stack in global_stack.extruderList:
             nozzle_name = extruder_stack.variant.getMetaDataEntry("name")
             material_id = extruder_stack.material.getMetaDataEntry("base_file")
@@ -106,7 +106,7 @@ class IntentManager(QObject):
         global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
         if global_stack is None:
             return ["default"]
-        current_definition_id = global_stack.definition.getMetaDataEntry("id")
+        current_definition_id = global_stack.definition.getId()
         final_intent_categories = set()  # type: Set[str]
         for extruder_stack in global_stack.extruderList:
             nozzle_name = extruder_stack.variant.getMetaDataEntry("name")
@@ -136,7 +136,7 @@ class IntentManager(QObject):
         global_stack = application.getGlobalContainerStack()
         if global_stack is None:
             return
-        current_definition_id = global_stack.definition.getMetaDataEntry("id")
+        current_definition_id = global_stack.definition.getId()
         for extruder_stack in global_stack.extruderList:
             nozzle_name = extruder_stack.variant.getMetaDataEntry("name")
             material_id = extruder_stack.material.getMetaDataEntry("base_file")

Some files were not shown because too many files changed in this diff