mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Move removeMaterial to MaterialManagementModel
Moving away from the MaterialManager. Contributes to issue CURA-6600.
This commit is contained in:
parent
99ccddefa4
commit
3dc7c7b61c
4 changed files with 21 additions and 4 deletions
|
@ -46,3 +46,20 @@ class MaterialManagementModel(QObject):
|
|||
Logger.log("w", "Cannot set name of read-only container %s.", root_material_id)
|
||||
return
|
||||
return container_registry.findContainers(id = root_material_id)[0].setName(name)
|
||||
|
||||
## Deletes a material from Cura.
|
||||
#
|
||||
# This function does not do any safety checking any more. Please call this
|
||||
# function only if:
|
||||
# - The material is not read-only.
|
||||
# - The material is not used in any stacks.
|
||||
# If the material was not lazy-loaded yet, this will fully load the
|
||||
# container. When removing this material node, all other materials with
|
||||
# the same base fill will also be removed.
|
||||
# \param material_node The material to remove.
|
||||
@pyqtSlot("QVariant")
|
||||
def removeMaterial(self, material_node: "MaterialNode") -> None:
|
||||
container_registry = CuraContainerRegistry.getInstance()
|
||||
materials_this_base_file = container_registry.findContainersMetadata(base_file = material_node.base_file)
|
||||
for material_metadata in materials_this_base_file:
|
||||
container_registry.removeContainer(material_metadata["id"])
|
|
@ -302,7 +302,7 @@ Item
|
|||
{
|
||||
// Set the active material as the fallback. It will be selected when the current material is deleted
|
||||
base.newRootMaterialIdToSwitchTo = base.active_root_material_id
|
||||
base.materialManager.removeMaterial(base.currentItem.container_node);
|
||||
base.materialManagement.removeMaterial(base.currentItem.container_node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -565,7 +565,7 @@ TabView
|
|||
}
|
||||
|
||||
// update the values
|
||||
base.materialManagement.setMaterialName(base.currentMaterialNode, new_name)
|
||||
materialManagement.setMaterialName(base.currentMaterialNode, new_name)
|
||||
properties.name = new_name
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue