Merge branch 'master' into feature_sync_button

This commit is contained in:
Diego Prado Gesto 2018-03-08 16:57:21 +01:00
commit b212781a19
9 changed files with 396 additions and 25 deletions

View file

@ -108,7 +108,7 @@ class MaterialManager(QObject):
Logger.log("e", "Missing root material node for [%s]. Probably caused by update using incomplete data."
" Check all related signals for further debugging.",
material_group.name)
# Do nothing here, we wait for a next signal to trigger an update.
self._update_timer.start()
return
guid = material_group.root_material_node.metadata["GUID"]
self._guid_material_groups_map[guid].append(material_group)
@ -218,6 +218,7 @@ class MaterialManager(QObject):
self.materialsUpdated.emit()
def _updateMaps(self):
Logger.log("i", "Updating material lookup data ...")
self.initialize()
def _onContainerMetadataChanged(self, container):
@ -400,6 +401,16 @@ class MaterialManager(QObject):
material_diameter, root_material_id)
return node
def removeMaterialByRootId(self, root_material_id: str):
material_group = self.getMaterialGroup(root_material_id)
if not material_group:
Logger.log("i", "Unable to remove the material with id %s, because it doesn't exist.", root_material_id)
return
nodes_to_remove = [material_group.root_material_node] + material_group.derived_material_node_list
for node in nodes_to_remove:
self._container_registry.removeContainer(node.metadata["id"])
#
# Methods for GUI
#
@ -423,14 +434,7 @@ class MaterialManager(QObject):
@pyqtSlot("QVariant")
def removeMaterial(self, material_node: "MaterialNode"):
root_material_id = material_node.metadata["base_file"]
material_group = self.getMaterialGroup(root_material_id)
if not material_group:
Logger.log("d", "Unable to remove the material with id %s, because it doesn't exist.", root_material_id)
return
nodes_to_remove = [material_group.root_material_node] + material_group.derived_material_node_list
for node in nodes_to_remove:
self._container_registry.removeContainer(node.metadata["id"])
self.removeMaterialByRootId(root_material_id)
#
# Creates a duplicate of a material, which has the same GUID and base_file metadata.