mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-16 13:25:53 +08:00
Add MaterialsModel to make material list update upon metadata change
This new model inherits from InstanceContainersModel. The only change is that it updates when the metadata of a material container changes. This is needed to make the list of materials update when the material diameter changes. Contributes to issue CURA-2822.
This commit is contained in:
parent
0e23930bfe
commit
bc219a06fe
@ -48,6 +48,7 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
|
|||||||
from UM.Settings.SettingFunction import SettingFunction
|
from UM.Settings.SettingFunction import SettingFunction
|
||||||
from cura.Settings.MachineNameValidator import MachineNameValidator
|
from cura.Settings.MachineNameValidator import MachineNameValidator
|
||||||
from cura.Settings.ProfilesModel import ProfilesModel
|
from cura.Settings.ProfilesModel import ProfilesModel
|
||||||
|
from cura.Settings.MaterialsModel import MaterialsModel
|
||||||
from cura.Settings.QualityAndUserProfilesModel import QualityAndUserProfilesModel
|
from cura.Settings.QualityAndUserProfilesModel import QualityAndUserProfilesModel
|
||||||
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
||||||
from cura.Settings.UserProfilesModel import UserProfilesModel
|
from cura.Settings.UserProfilesModel import UserProfilesModel
|
||||||
@ -717,6 +718,7 @@ class CuraApplication(QtApplication):
|
|||||||
|
|
||||||
qmlRegisterType(ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
|
qmlRegisterType(ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
|
||||||
qmlRegisterSingletonType(ProfilesModel, "Cura", 1, 0, "ProfilesModel", ProfilesModel.createProfilesModel)
|
qmlRegisterSingletonType(ProfilesModel, "Cura", 1, 0, "ProfilesModel", ProfilesModel.createProfilesModel)
|
||||||
|
qmlRegisterType(MaterialsModel, "Cura", 1, 0, "MaterialsModel")
|
||||||
qmlRegisterType(QualityAndUserProfilesModel, "Cura", 1, 0, "QualityAndUserProfilesModel")
|
qmlRegisterType(QualityAndUserProfilesModel, "Cura", 1, 0, "QualityAndUserProfilesModel")
|
||||||
qmlRegisterType(UserProfilesModel, "Cura", 1, 0, "UserProfilesModel")
|
qmlRegisterType(UserProfilesModel, "Cura", 1, 0, "UserProfilesModel")
|
||||||
qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
||||||
|
21
cura/Settings/MaterialsModel.py
Normal file
21
cura/Settings/MaterialsModel.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Copyright (c) 2017 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
from UM.Settings.ContainerRegistry import ContainerRegistry #To listen for changes to the materials.
|
||||||
|
from UM.Settings.Models.InstanceContainersModel import InstanceContainersModel #We're extending this class.
|
||||||
|
|
||||||
|
## A model that shows a list of currently valid materials.
|
||||||
|
class MaterialsModel(InstanceContainersModel):
|
||||||
|
def __init__(self, parent = None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
ContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerMetaDataChanged)
|
||||||
|
|
||||||
|
## Called when the metadata of the container was changed.
|
||||||
|
#
|
||||||
|
# This makes sure that we only update when it was a material that changed.
|
||||||
|
#
|
||||||
|
# \param container The container whose metadata was changed.
|
||||||
|
def _onContainerMetaDataChanged(self, container):
|
||||||
|
if container.getMetaDataEntry("type") == "material": #Only need to update if a material was changed.
|
||||||
|
self._update()
|
@ -20,7 +20,7 @@ UM.ManagementPage
|
|||||||
objectList.positionViewAtBeginning();
|
objectList.positionViewAtBeginning();
|
||||||
}
|
}
|
||||||
|
|
||||||
model: UM.InstanceContainersModel
|
model: Cura.MaterialsModel
|
||||||
{
|
{
|
||||||
filter:
|
filter:
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user