WIP: Refactor setMaterialName()

This commit is contained in:
Lipu Fei 2018-02-16 14:17:35 +01:00
parent e5cc7efdf2
commit f7f9c68fcc
2 changed files with 10 additions and 16 deletions

View file

@ -160,21 +160,16 @@ class ContainerManager(QObject):
return container.getProperty(setting_key, property_name)
## Set the name of the specified container.
@pyqtSlot(str, str, result = bool)
def setContainerName(self, container_id, new_name):
if self._container_registry.isReadOnly(container_id):
Logger.log("w", "Cannot set name of read-only container %s.", container_id)
return False
## Set the name of the specified material.
@pyqtSlot("QVariant", str)
def setMaterialName(self, material_node, new_name):
root_material_id = material_node.metadata["base_file"]
if self._container_registry.isReadOnly(root_material_id):
Logger.log("w", "Cannot set name of read-only container %s.", root_material_id)
return
containers = self._container_registry.findContainers(id = container_id) #We need to get the full container, not just metadata, since we need to know whether it's read-only.
if not containers:
Logger.log("w", "Could not set name of container %s because it was not found.", container_id)
return False
containers[0].setName(new_name)
return True
material_group = self._material_manager.getMaterialGroup(root_material_id)
material_group.root_material_node.getContainer().setName(new_name)
## Find instance containers matching certain criteria.
#