mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
No longer update all material models when favourites change
The MaterialManager.materialsUpdated signal was only called once upon init and for the rest when a favourite was added or removed. So only the FavoriteMaterialsModel would need to listen to it. Because the MaterialManager is being deprecated, the favourite materials model now just listens to the preferences changing instead, as it was supposed to be doing anyway. Contributes to issue CURA-6600.
This commit is contained in:
parent
dcf7ed9969
commit
5abb03e269
2 changed files with 9 additions and 3 deletions
|
@ -35,9 +35,6 @@ class BaseMaterialsModel(ListModel):
|
||||||
# Update this model when switching machines
|
# Update this model when switching machines
|
||||||
self._machine_manager.activeStackChanged.connect(self._update)
|
self._machine_manager.activeStackChanged.connect(self._update)
|
||||||
|
|
||||||
# Update this model when list of materials changes
|
|
||||||
self._material_manager.materialsUpdated.connect(self._update)
|
|
||||||
|
|
||||||
self.addRoleName(Qt.UserRole + 1, "root_material_id")
|
self.addRoleName(Qt.UserRole + 1, "root_material_id")
|
||||||
self.addRoleName(Qt.UserRole + 2, "id")
|
self.addRoleName(Qt.UserRole + 2, "id")
|
||||||
self.addRoleName(Qt.UserRole + 3, "GUID")
|
self.addRoleName(Qt.UserRole + 3, "GUID")
|
||||||
|
|
|
@ -2,11 +2,20 @@
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel
|
from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel
|
||||||
|
import cura.CuraApplication # To listen to changes to the preferences.
|
||||||
|
|
||||||
## Model that shows the list of favorite materials.
|
## Model that shows the list of favorite materials.
|
||||||
class FavoriteMaterialsModel(BaseMaterialsModel):
|
class FavoriteMaterialsModel(BaseMaterialsModel):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
cura.CuraApplication.CuraApplication.getInstance().getPreferences().preferenceChanged.connect(self._onFavoritesChanged)
|
||||||
|
self._update()
|
||||||
|
|
||||||
|
## Triggered when any preference changes, but only handles it when the list
|
||||||
|
# of favourites is changed.
|
||||||
|
def _onFavoritesChanged(self, preference_key: str) -> None:
|
||||||
|
if preference_key != "cura/favorite_materials":
|
||||||
|
return
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue