Use MaterialManagementModel to rename materials

It's the replacement for the deprecation.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-09-17 17:57:32 +02:00
parent 9392a3553c
commit 8710bb77a7
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276

View File

@ -268,18 +268,12 @@ class MaterialManager(QObject):
return False
return True
## Change the user-visible name of a material.
# \param material_node The ContainerTree node of the material to rename.
# \param name The new name for the material.
@pyqtSlot("QVariant", str)
def setMaterialName(self, material_node: "MaterialNode", name: str) -> None:
if material_node.container is None:
return
root_material_id = material_node.container.getMetaDataEntry("base_file")
if root_material_id is None:
return
if CuraContainerRegistry.getInstance().isReadOnly(root_material_id):
Logger.log("w", "Cannot set name of read-only container %s.", root_material_id)
return
containers = CuraContainerRegistry.getInstance().findInstanceContainers(id = root_material_id)
containers[0].setName(name)
return cura.CuraApplication.CuraApplication.getMaterialManagementModel().setMaterialName(material_node, name)
@pyqtSlot("QVariant")
def removeMaterial(self, material_node: "MaterialNode") -> None: