mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 04:37:51 -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:
|
for result in results:
|
||||||
container_registry.removeContainer(result.getMetaDataEntry("id", ""))
|
container_registry.removeContainer(result.getMetaDataEntry("id", ""))
|
||||||
|
|
||||||
#
|
|
||||||
# Methods for GUI
|
|
||||||
#
|
|
||||||
@pyqtSlot("QVariant", result=bool)
|
@pyqtSlot("QVariant", result=bool)
|
||||||
def canMaterialBeRemoved(self, material_node: "MaterialNode"):
|
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!
|
# 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:
|
if container:
|
||||||
container.setName(name)
|
container.setName(name)
|
||||||
|
|
||||||
#
|
|
||||||
# Removes the given material.
|
|
||||||
#
|
|
||||||
@pyqtSlot("QVariant")
|
@pyqtSlot("QVariant")
|
||||||
def removeMaterial(self, material_node: "MaterialNode") -> None:
|
def removeMaterial(self, material_node: "MaterialNode") -> None:
|
||||||
root_material_id = material_node.getMetaDataEntry("base_file")
|
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
|
## This is another convenience function which is shared by all material
|
||||||
# models so it's put here to avoid having so much duplicated code.
|
# models so it's put here to avoid having so much duplicated code.
|
||||||
def _createMaterialItem(self, root_material_id, container_node):
|
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 = {
|
item = {
|
||||||
"root_material_id": root_material_id,
|
"root_material_id": root_material_id,
|
||||||
"id": metadata["id"],
|
"id": metadata["id"],
|
||||||
|
|
|
@ -28,7 +28,8 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
item = self._createMaterialItem(root_material_id, container_node)
|
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
|
# Sort the item list alphabetically by name
|
||||||
item_list = sorted(item_list, key = lambda d: d["brand"].upper())
|
item_list = sorted(item_list, key = lambda d: d["brand"].upper())
|
||||||
|
|
|
@ -24,11 +24,12 @@ class GenericMaterialsModel(BaseMaterialsModel):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Only add results for generic materials
|
# Only add results for generic materials
|
||||||
if container_node.getMetaDataEntry("brand").lower() != "generic":
|
if container_node.getMetaDataEntry("brand", "unknown").lower() != "generic":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
item = self._createMaterialItem(root_material_id, container_node)
|
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
|
# Sort the item list alphabetically by name
|
||||||
item_list = sorted(item_list, key = lambda d: d["name"].upper())
|
item_list = sorted(item_list, key = lambda d: d["name"].upper())
|
||||||
|
|
|
@ -55,7 +55,8 @@ class MaterialBrandsModel(BaseMaterialsModel):
|
||||||
|
|
||||||
# Now handle the individual materials
|
# Now handle the individual materials
|
||||||
item = self._createMaterialItem(root_material_id, container_node)
|
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
|
# Part 2: Organize the tree into models
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue