Fix favorite materials without material manager

We just track it via the preference value itself rather than duplicating that in any other data structure. It's simple enough.

Contributes to issue CURA-6776.
This commit is contained in:
Ghostkeeper 2019-09-20 09:34:40 +02:00
parent 12043df367
commit 4a68e7ec95
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
3 changed files with 45 additions and 6 deletions

View file

@ -45,6 +45,7 @@ class BaseMaterialsModel(ListModel):
# Update this model when switching machines, when adding materials or changing their metadata.
self._machine_manager.activeStackChanged.connect(self._update)
ContainerTree.getInstance().materialsChanged.connect(self._materialsListChanged)
self._application.getMaterialManagementModel().favoritesChanged.connect(self._update)
self.addRoleName(Qt.UserRole + 1, "root_material_id")
self.addRoleName(Qt.UserRole + 2, "id")
@ -115,6 +116,11 @@ class BaseMaterialsModel(ListModel):
return
self._update()
## Triggered when the list of favorite materials is changed.
def _favoritesChanged(self, material_base_file: str) -> None:
if material_base_file in self._available_materials:
self._update()
## This is an abstract method that needs to be implemented by the specific
# models themselves.
def _update(self):