mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 12:47:49 -06:00
Fix removing of material
CURA-6600
This commit is contained in:
parent
49e8c8d9d9
commit
646222f2ac
5 changed files with 11 additions and 11 deletions
|
@ -253,9 +253,6 @@ class MaterialManager(QObject):
|
|||
for result in results:
|
||||
container_registry.removeContainer(result.getMetaDataEntry("id", ""))
|
||||
|
||||
#
|
||||
# Methods for GUI
|
||||
#
|
||||
@pyqtSlot("QVariant", result=bool)
|
||||
def canMaterialBeRemoved(self, material_node: "MaterialNode"):
|
||||
# Check if the material is active in any extruder train. In that case, the material shouldn't be removed!
|
||||
|
@ -284,9 +281,6 @@ class MaterialManager(QObject):
|
|||
if container:
|
||||
container.setName(name)
|
||||
|
||||
#
|
||||
# Removes the given material.
|
||||
#
|
||||
@pyqtSlot("QVariant")
|
||||
def removeMaterial(self, material_node: "MaterialNode") -> None:
|
||||
root_material_id = material_node.getMetaDataEntry("base_file")
|
||||
|
|
|
@ -128,7 +128,10 @@ 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 = CuraContainerRegistry.getInstance().findContainersMetadata(id = container_node.container_id)[0]
|
||||
metadata_list = CuraContainerRegistry.getInstance().findContainersMetadata(id = container_node.container_id)
|
||||
if not metadata_list:
|
||||
return None
|
||||
metadata = metadata_list[0]
|
||||
item = {
|
||||
"root_material_id": root_material_id,
|
||||
"id": metadata["id"],
|
||||
|
|
|
@ -28,7 +28,8 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
|||
continue
|
||||
|
||||
item = self._createMaterialItem(root_material_id, container_node)
|
||||
item_list.append(item)
|
||||
if item:
|
||||
item_list.append(item)
|
||||
|
||||
# Sort the item list alphabetically by name
|
||||
item_list = sorted(item_list, key = lambda d: d["brand"].upper())
|
||||
|
|
|
@ -24,11 +24,12 @@ class GenericMaterialsModel(BaseMaterialsModel):
|
|||
continue
|
||||
|
||||
# Only add results for generic materials
|
||||
if container_node.getMetaDataEntry("brand").lower() != "generic":
|
||||
if container_node.getMetaDataEntry("brand", "unknown").lower() != "generic":
|
||||
continue
|
||||
|
||||
item = self._createMaterialItem(root_material_id, container_node)
|
||||
item_list.append(item)
|
||||
if item:
|
||||
item_list.append(item)
|
||||
|
||||
# Sort the item list alphabetically by name
|
||||
item_list = sorted(item_list, key = lambda d: d["name"].upper())
|
||||
|
|
|
@ -55,7 +55,8 @@ class MaterialBrandsModel(BaseMaterialsModel):
|
|||
|
||||
# Now handle the individual materials
|
||||
item = self._createMaterialItem(root_material_id, container_node)
|
||||
brand_group_dict[brand][material_type].append(item)
|
||||
if item:
|
||||
brand_group_dict[brand][material_type].append(item)
|
||||
|
||||
# Part 2: Organize the tree into models
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue