Re-added material detail view

Contributes to CURA-5378
This commit is contained in:
Ian Paschal 2018-08-22 15:58:58 +02:00
parent 00eb8e6788
commit 6225fff1f8
8 changed files with 51 additions and 51 deletions

View file

@ -34,7 +34,7 @@ class BaseMaterialsModel(ListModel):
self.addRoleName(self.RootMaterialIdRole, "root_material_id")
self.addRoleName(self.IdRole, "id")
self.addRoleName(self.GUIDRole, "guid")
self.addRoleName(self.GUIDRole, "GUID")
self.addRoleName(self.NameRole, "name")
self.addRoleName(self.BrandRole, "brand")
self.addRoleName(self.MaterialRole, "material")

View file

@ -127,24 +127,23 @@ class BrandMaterialsModel(ListModel):
# Now handle the individual materials
item = {
"root_material_id": root_material_id,
# "root_material_id": container_node.metadata["base_file"] <- as written in material management model
"id": metadata["id"],
"container_id": metadata["id"], # TODO: Remove duplicate in material manager qml
"guid": metadata["GUID"],
"name": metadata["name"],
"brand": metadata["brand"],
"description": metadata["description"],
"material": metadata["material"],
"color_name": metadata["color_name"],
"color_code": metadata["color_code"],
"density": metadata.get("properties", {}).get("density", ""),
"diameter": metadata.get("properties", {}).get("diameter", ""),
"root_material_id": root_material_id,
"id": metadata["id"],
"container_id": metadata["id"], # TODO: Remove duplicate in material manager qml
"GUID": metadata["GUID"],
"name": metadata["name"],
"brand": metadata["brand"],
"description": metadata["description"],
"material": metadata["material"],
"color_name": metadata["color_name"],
"color_code": metadata["color_code"],
"density": metadata.get("properties", {}).get("density", ""),
"diameter": metadata.get("properties", {}).get("diameter", ""),
"approximate_diameter": metadata["approximate_diameter"],
"adhesion_info": metadata["adhesion_info"],
"is_read_only": self._container_registry.isReadOnly(metadata["id"]),
"container_node": container_node,
"is_favorite": root_material_id in favorites
"adhesion_info": metadata["adhesion_info"],
"is_read_only": self._container_registry.isReadOnly(metadata["id"]),
"container_node": container_node,
"is_favorite": root_material_id in favorites
}
brand_group_dict[brand][material_type].append(item)

View file

@ -56,6 +56,7 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
item = {
"root_material_id": root_material_id,
"id": metadata["id"],
"GUID": metadata["GUID"],
"name": metadata["name"],
"brand": metadata["brand"],
"material": metadata["material"],

View file

@ -55,6 +55,7 @@ class GenericMaterialsModel(BaseMaterialsModel):
item = {
"root_material_id": root_material_id,
"id": metadata["id"],
"GUID": metadata["GUID"],
"name": metadata["name"],
"brand": metadata["brand"],
"material": metadata["material"],

View file

@ -21,7 +21,7 @@ Rectangle
width: parent.width
color: base.currentItem == model ? UM.Theme.getColor("favorites_row_selected") : "transparent"
Row
Item
{
height: parent.height
width: parent.width

View file

@ -38,7 +38,7 @@ TabView
if (!base.containerId || !base.editingEnabled) {
return ""
}
var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentMaterialNode, true);
var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentItem.container_node, true);
if (linkedMaterials.length == 0) {
return ""
}

View file

@ -13,25 +13,24 @@ Item
{
id: detailsPanel
property var currentItem: base.currentItem
onCurrentItemChanged: { updateMaterialPropertiesObject(currentItem) }
function updateMaterialPropertiesObject( currentItem )
{
// var currentItem = materialsModel.getItem(materialListView.currentIndex);
materialProperties.name = currentItem.name ? currentItem.name : "Unknown";
materialProperties.guid = currentItem.guid;
materialProperties.container_id = currentItem.container_id;
materialProperties.brand = currentItem.brand ? currentItem.brand : "Unknown";
materialProperties.material = currentItem.material ? currentItem.material : "Unknown";
materialProperties.color_name = currentItem.color_name ? currentItem.color_name : "Yellow";
materialProperties.color_code = currentItem.color_code ? currentItem.color_code : "yellow";
materialProperties.description = currentItem.description ? currentItem.description : "";
materialProperties.adhesion_info = currentItem.adhesion_info ? currentItem.adhesion_info : "";
materialProperties.density = currentItem.density ? currentItem.density : 0.0;
materialProperties.diameter = currentItem.diameter ? currentItem.diameter : 0.0;
materialProperties.approximate_diameter = currentItem.approximate_diameter ? currentItem.approximate_diameter : "0";
materialProperties.name = currentItem.name || "Unknown"
materialProperties.guid = currentItem.GUID;
materialProperties.container_id = currentItem.id
materialProperties.brand = currentItem.brand || "Unknown"
materialProperties.material = currentItem.material || "Unknown"
materialProperties.color_name = currentItem.color_name || "Yellow"
materialProperties.color_code = currentItem.color_code || "yellow"
materialProperties.description = currentItem.description || ""
materialProperties.adhesion_info = currentItem.adhesion_info || "";
materialProperties.density = currentItem.density || 0.0
materialProperties.diameter = currentItem.diameter || 0.0
materialProperties.approximate_diameter = currentItem.approximate_diameter || "0"
}
Item
@ -66,7 +65,7 @@ Item
editingEnabled: base.currentItem != null && !base.currentItem.is_read_only
properties: materialProperties
containerId: base.currentItem != null ? base.currentItem.container_id : ""
containerId: base.currentItem != null ? base.currentItem.id : ""
currentMaterialNode: base.currentItem.container_node

View file

@ -57,7 +57,7 @@ Item
// materialListView.currentIndex = itemIndex;
// }
// This connection makes sure that we will switch to the new
onCurrentItemChanged: { MaterialsDetailsPanel.currentItem = currentItem }
Connections
{
target: materialsModel
@ -284,17 +284,17 @@ Item
MaterialsList {}
}
// MaterialsDetailsPanel
// {
// anchors
// {
// left: materialScrollView.right
// leftMargin: UM.Theme.getSize("default_margin").width
// top: parent.top
// bottom: parent.bottom
// right: parent.right
// }
// }
MaterialsDetailsPanel
{
anchors
{
left: materialScrollView.right
leftMargin: UM.Theme.getSize("default_margin").width
top: parent.top
bottom: parent.bottom
right: parent.right
}
}
}
// Dialogs