diff --git a/cura/Machines/Models/BaseMaterialsModel.py b/cura/Machines/Models/BaseMaterialsModel.py index e936877923..cd8fc70dbd 100644 --- a/cura/Machines/Models/BaseMaterialsModel.py +++ b/cura/Machines/Models/BaseMaterialsModel.py @@ -1,18 +1,18 @@ -# Copyright (c) 2018 Ultimaker B.V. +# Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. + from typing import Optional, Dict, Set from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty from UM.Qt.ListModel import ListModel +from cura.Machines.MaterialNode import MaterialNode +from cura.Settings.CuraContainerRegistry import CuraContainerRegistry ## This is the base model class for GenericMaterialsModel and MaterialBrandsModel. # Those 2 models are used by the material drop down menu to show generic materials and branded materials separately. # The extruder position defined here is being used to bound a menu to the correct extruder. This is used in the top # bar menu "Settings" -> "Extruder nr" -> "Material" -> this menu -from cura.Machines.MaterialNode import MaterialNode - - class BaseMaterialsModel(ListModel): extruderPositionChanged = pyqtSignal() @@ -128,7 +128,7 @@ class BaseMaterialsModel(ListModel): ## This is another convenience function which is shared by all material # models so it's put here to avoid having so much duplicated code. def _createMaterialItem(self, root_material_id, container_node): - metadata = container_node.getMetadata() + metadata = CuraContainerRegistry.getInstance().findContainersMetadata(id = container_node.container_id)[0] item = { "root_material_id": root_material_id, "id": metadata["id"], diff --git a/cura/Machines/Models/FavoriteMaterialsModel.py b/cura/Machines/Models/FavoriteMaterialsModel.py index 98a2a01597..dda06a953a 100644 --- a/cura/Machines/Models/FavoriteMaterialsModel.py +++ b/cura/Machines/Models/FavoriteMaterialsModel.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Ultimaker B.V. +# Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel @@ -19,10 +19,8 @@ class FavoriteMaterialsModel(BaseMaterialsModel): item_list = [] for root_material_id, container_node in self._available_materials.items(): - metadata = container_node.getMetadata() - # Do not include the materials from a to-be-removed package - if bool(metadata.get("removed", False)): + if bool(container_node.getMetaDataEntry("removed", False)): continue # Only add results for favorite materials diff --git a/cura/Machines/Models/GenericMaterialsModel.py b/cura/Machines/Models/GenericMaterialsModel.py index e81a73de24..8a03dcfdeb 100644 --- a/cura/Machines/Models/GenericMaterialsModel.py +++ b/cura/Machines/Models/GenericMaterialsModel.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Ultimaker B.V. +# Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel @@ -19,14 +19,12 @@ class GenericMaterialsModel(BaseMaterialsModel): item_list = [] for root_material_id, container_node in self._available_materials.items(): - metadata = container_node.getMetadata() - # Do not include the materials from a to-be-removed package - if bool(metadata.get("removed", False)): + if bool(container_node.getMetaDataEntry("removed", False)): continue # Only add results for generic materials - if metadata["brand"].lower() != "generic": + if container_node.getMetaDataEntry("brand").lower() != "generic": continue item = self._createMaterialItem(root_material_id, container_node)