|
@@ -21,6 +21,111 @@ Item
|
|
|
Cura.MaterialBrandsModel { id: materialsModel }
|
|
|
Cura.FavoriteMaterialsModel { id: favoriteMaterialsModel }
|
|
|
Cura.GenericMaterialsModel { id: genericMaterialsModel }
|
|
|
+
|
|
|
+ property var currentType: null
|
|
|
+ property var currentBrand: null
|
|
|
+ property var expandedBrands: UM.Preferences.getValue("cura/expanded_brands").split(";")
|
|
|
+ property var expandedTypes: UM.Preferences.getValue("cura/expanded_types").split(";")
|
|
|
+
|
|
|
+ function expandActiveMaterial(search_root_id)
|
|
|
+ {
|
|
|
+ for (var n = 0; n < genericMaterialsModel.rowCount(); n++)
|
|
|
+ {
|
|
|
+ var material = genericMaterialsModel.getItem(n);
|
|
|
+ if (material.root_material_id == search_root_id)
|
|
|
+ {
|
|
|
+ if (materialList.expandedBrands.indexOf("Generic") == -1)
|
|
|
+ {
|
|
|
+ materialList.expandedBrands.push("Generic");
|
|
|
+ materialList.currentBrand = "Generic"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var i = 0; i < materialsModel.rowCount(); i++)
|
|
|
+ {
|
|
|
+ var brand = materialsModel.getItem(i);
|
|
|
+ var types_model = brand.material_types;
|
|
|
+
|
|
|
+ for (var j = 0; j < types_model.rowCount(); j++)
|
|
|
+ {
|
|
|
+ var type = types_model.getItem(j);
|
|
|
+ var colors_model = type.colors;
|
|
|
+ for (var k = 0; k < colors_model.rowCount(); k++)
|
|
|
+ {
|
|
|
+ var material = colors_model.getItem(k);
|
|
|
+ if (material.root_material_id == search_root_id)
|
|
|
+ {
|
|
|
+ if (materialList.expandedBrands.indexOf(brand.name) == -1)
|
|
|
+ {
|
|
|
+ materialList.expandedBrands.push(brand.name);
|
|
|
+ materialList.currentBrand = brand.name
|
|
|
+ }
|
|
|
+ if (materialList.expandedTypes.indexOf(brand.name + "_" + type.name) == -1)
|
|
|
+ {
|
|
|
+ materialList.expandedTypes.push(brand.name + "_" + type.name)
|
|
|
+ materialList.currentType = brand.name + "_" + type.name
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UM.Preferences.setValue("cura/expanded_brands", materialList.expandedBrands.join(";"));
|
|
|
+ UM.Preferences.setValue("cura/expanded_types", materialList.expandedTypes.join(";"));
|
|
|
+ }
|
|
|
+
|
|
|
+// Connections
|
|
|
+// {
|
|
|
+// target: materialsModel
|
|
|
+// onItemsChanged:
|
|
|
+// {
|
|
|
+// var currentItemId = base.hasCurrentItem ? base.currentItem.root_material_id : ""
|
|
|
+// var position = Cura.ExtruderManager.activeExtruderIndex
|
|
|
+// console.log("!!!!!!!!!!!!!!!!!!! on items changed:", base.newRootMaterialIdToSwitchTo)
|
|
|
+//
|
|
|
+// // try to pick the currently selected item; it may have been moved
|
|
|
+// if (base.newRootMaterialIdToSwitchTo == "")
|
|
|
+// {
|
|
|
+// console.log("material id is empty, setting to ", currentItemId)
|
|
|
+// base.newRootMaterialIdToSwitchTo = currentItemId
|
|
|
+// }
|
|
|
+//
|
|
|
+// console.log("PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP", materialsModel.rowCount())
|
|
|
+// for (var brand_idx = 0; brand_idx < materialsModel.rowCount(); ++brand_idx)
|
|
|
+// {
|
|
|
+// var brand = materialsModel.getItem(brand_idx)
|
|
|
+// console.log(item.root_material_id, "=", base.newRootMaterialIdToSwitchTo)
|
|
|
+//
|
|
|
+// for (var type_idx = 0; type_idx < brand.material_types.rowCount(); ++type_idx)
|
|
|
+// {
|
|
|
+// var type = brand.material_types.getItem(type_idx)
|
|
|
+// if (type.root_material_id == base.newRootMaterialIdToSwitchTo)
|
|
|
+// {
|
|
|
+// // Switch to the newly created profile if needed
|
|
|
+// base.currentItem = item
|
|
|
+// // materialDetailsPanel.activateDetailsWithIndex(materialListView.currentIndex)
|
|
|
+// // if (base.toActivateNewMaterial)
|
|
|
+// // {
|
|
|
+// // Cura.MachineManager.setMaterial(position, item.container_node)
|
|
|
+// // }
|
|
|
+// base.newRootMaterialIdToSwitchTo = ""
|
|
|
+// base.toActivateNewMaterial = false
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // If the new id can't be found, then do nothing
|
|
|
+//// materialListView.currentIndex = 0
|
|
|
+//// materialListView.activateDetailsWithIndex(materialListView.currentIndex)
|
|
|
+//// if (base.toActivateNewMaterial)
|
|
|
+//// {
|
|
|
+//// Cura.MachineManager.setMaterial(position, materialsModel.getItem(0).container_node)
|
|
|
+//// }
|
|
|
+// base.newRootMaterialIdToSwitchTo = ""
|
|
|
+// base.toActivateNewMaterial = false
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
Column
|
|
|
{
|
|
|
Rectangle
|
|
@@ -102,7 +207,7 @@ Item
|
|
|
}
|
|
|
Rectangle
|
|
|
{
|
|
|
- property var expanded: base.expanded_brands.indexOf("Generic") > -1
|
|
|
+ property var expanded: materialList.expandedBrands.indexOf("Generic") > -1
|
|
|
|
|
|
id: generic_section
|
|
|
height: childrenRect.height
|
|
@@ -158,18 +263,18 @@ Item
|
|
|
anchors.fill: generic_header
|
|
|
onPressed:
|
|
|
{
|
|
|
- const index = base.expanded_brands.indexOf("Generic")
|
|
|
+ const index = materialList.expandedBrands.indexOf("Generic")
|
|
|
|
|
|
if (index > -1)
|
|
|
{
|
|
|
// Remove it
|
|
|
- base.expanded_brands.splice(index, 1)
|
|
|
+ materialList.expandedBrands.splice(index, 1)
|
|
|
generic_section.expanded = false
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// Add it
|
|
|
- base.expanded_brands.push("Generic")
|
|
|
+ materialList.expandedBrands.push("Generic")
|
|
|
generic_section.expanded = true
|
|
|
}
|
|
|
}
|