mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 14:34:01 -06:00
Clean up the code by removing duplicate code. Also try to unify the
MaterialsBrandSection to use the same component for favorites, generic and branded materials. Contributes to CURA-5682.
This commit is contained in:
parent
972f0bef43
commit
f871a89825
3 changed files with 158 additions and 137 deletions
|
@ -15,7 +15,7 @@ Rectangle
|
|||
id: brand_section
|
||||
|
||||
property var sectionName: ""
|
||||
property var elements // This can be a MaterialTypesModel or GenericMaterialsModel
|
||||
property var elementsModel // This can be a MaterialTypesModel or GenericMaterialsModel or FavoriteMaterialsModel
|
||||
property var hasMaterialTypes: true // It indicates wheather it has material types or not
|
||||
property var expanded: materialList.expandedBrands.indexOf(sectionName) > -1
|
||||
|
||||
|
@ -109,22 +109,44 @@ Rectangle
|
|||
|
||||
Repeater
|
||||
{
|
||||
model: elements
|
||||
delegate: MaterialsTypeSection
|
||||
model: elementsModel
|
||||
delegate: Item
|
||||
{
|
||||
visible: hasMaterialTypes
|
||||
materialType: model
|
||||
Loader
|
||||
{
|
||||
id: loader
|
||||
property var element: model
|
||||
sourceComponent: hasMaterialTypes ? materialsTypeSection : materialSlot
|
||||
}
|
||||
}
|
||||
}
|
||||
// In case there are no types, we create a material slot
|
||||
Repeater
|
||||
// Repeater
|
||||
// {
|
||||
// model: elementsModel
|
||||
// delegate: MaterialsSlot
|
||||
// {
|
||||
// visible: !hasMaterialTypes
|
||||
// material: model
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Component
|
||||
{
|
||||
id: materialsTypeSection
|
||||
MaterialsTypeSection
|
||||
{
|
||||
model: elements
|
||||
delegate: MaterialsSlot
|
||||
{
|
||||
visible: !hasMaterialTypes
|
||||
material: model
|
||||
}
|
||||
materialType: element
|
||||
}
|
||||
}
|
||||
|
||||
Component
|
||||
{
|
||||
id: materialSlot
|
||||
MaterialsSlot
|
||||
{
|
||||
material: element
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue