mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Improve models
Contributes to CURA-5162, CURA-5378
This commit is contained in:
parent
08b325ee04
commit
cb713eea6a
4 changed files with 23 additions and 13 deletions
|
@ -27,6 +27,7 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
|||
if global_stack is None:
|
||||
self.setItems([])
|
||||
return
|
||||
|
||||
extruder_position = str(self._extruder_position)
|
||||
if extruder_position not in global_stack.extruders:
|
||||
self.setItems([])
|
||||
|
@ -40,8 +41,6 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
|||
|
||||
favorite_ids = self._material_manager.getFavorites()
|
||||
|
||||
print("favorite_ids:", favorite_ids)
|
||||
|
||||
item_list = []
|
||||
for root_material_id, container_node in available_material_dict.items():
|
||||
metadata = container_node.metadata
|
||||
|
@ -61,11 +60,13 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
|||
"brand": metadata["brand"],
|
||||
"material": metadata["material"],
|
||||
"color_name": metadata["color_name"],
|
||||
"container_node": container_node
|
||||
"color_code": metadata["color_code"],
|
||||
"container_node": container_node,
|
||||
"is_favorite": True
|
||||
}
|
||||
item_list.append(item)
|
||||
|
||||
# Sort the item list by material name alphabetically
|
||||
item_list = sorted(item_list, key = lambda d: d["name"].upper())
|
||||
item_list = sorted(item_list, key = lambda d: d["brand"].upper())
|
||||
|
||||
self.setItems(item_list)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue