mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00
WIP: Cleanup MaterialsModel
This commit is contained in:
parent
62c31c2f6c
commit
6cc65e97f2
3 changed files with 4 additions and 37 deletions
|
@ -60,7 +60,7 @@ from cura.Machines.Models.CustomQualityProfilesModel import CustomQualityProfile
|
||||||
|
|
||||||
from cura.Machines.Models.Other.MultiBuildPlateModel import MultiBuildPlateModel
|
from cura.Machines.Models.Other.MultiBuildPlateModel import MultiBuildPlateModel
|
||||||
|
|
||||||
from cura.Settings.MaterialsModel import MaterialsModel, BrandMaterialsModel, GenericMaterialsModel, NewMaterialsModel
|
from cura.Machines.Models.MaterialsModel import BrandMaterialsModel, GenericMaterialsModel, MaterialsModel
|
||||||
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
||||||
from cura.Settings.SimpleModeSettingsManager import SimpleModeSettingsManager
|
from cura.Settings.SimpleModeSettingsManager import SimpleModeSettingsManager
|
||||||
|
|
||||||
|
@ -944,7 +944,7 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
qmlRegisterType(GenericMaterialsModel, "Cura", 1, 0, "GenericMaterialsModel")
|
qmlRegisterType(GenericMaterialsModel, "Cura", 1, 0, "GenericMaterialsModel")
|
||||||
qmlRegisterType(BrandMaterialsModel, "Cura", 1, 0, "BrandMaterialsModel")
|
qmlRegisterType(BrandMaterialsModel, "Cura", 1, 0, "BrandMaterialsModel")
|
||||||
qmlRegisterType(NewMaterialsModel, "Cura", 1, 0, "NewMaterialsModel")
|
qmlRegisterType(MaterialsModel, "Cura", 1, 0, "MaterialsModel")
|
||||||
|
|
||||||
# TODO: make this singleton?
|
# TODO: make this singleton?
|
||||||
qmlRegisterType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel")
|
qmlRegisterType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel")
|
||||||
|
@ -953,7 +953,6 @@ class CuraApplication(QtApplication):
|
||||||
qmlRegisterSingletonType(CustomQualityProfilesModel, "Cura", 1, 0, "CustomQualityProfilesModel", self.getCustomQualityProfilesModel)
|
qmlRegisterSingletonType(CustomQualityProfilesModel, "Cura", 1, 0, "CustomQualityProfilesModel", self.getCustomQualityProfilesModel)
|
||||||
qmlRegisterType(NozzleModel, "Cura", 1, 0, "NozzleModel")
|
qmlRegisterType(NozzleModel, "Cura", 1, 0, "NozzleModel")
|
||||||
|
|
||||||
qmlRegisterType(MaterialsModel, "Cura", 1, 0, "MaterialsModel")
|
|
||||||
qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
qmlRegisterType(MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
||||||
qmlRegisterType(QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel")
|
qmlRegisterType(QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel")
|
||||||
qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
|
qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
|
||||||
|
|
|
@ -189,7 +189,7 @@ class BrandMaterialsModel(ListModel):
|
||||||
#
|
#
|
||||||
# This model is for the Material management page.
|
# This model is for the Material management page.
|
||||||
#
|
#
|
||||||
class NewMaterialsModel(ListModel):
|
class MaterialsModel(ListModel):
|
||||||
RootMaterialIdRole = Qt.UserRole + 1
|
RootMaterialIdRole = Qt.UserRole + 1
|
||||||
DisplayNameRole = Qt.UserRole + 2
|
DisplayNameRole = Qt.UserRole + 2
|
||||||
BrandRole = Qt.UserRole + 3
|
BrandRole = Qt.UserRole + 3
|
||||||
|
@ -272,35 +272,3 @@ class NewMaterialsModel(ListModel):
|
||||||
|
|
||||||
material_list = sorted(material_list, key = lambda k: (k["brand"], k["name"]))
|
material_list = sorted(material_list, key = lambda k: (k["brand"], k["name"]))
|
||||||
self.setItems(material_list)
|
self.setItems(material_list)
|
||||||
|
|
||||||
|
|
||||||
## A model that shows a list of currently valid materials. Used by management page.
|
|
||||||
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._container_change_timer.start()
|
|
||||||
|
|
||||||
def _onContainerChanged(self, container):
|
|
||||||
if container.getMetaDataEntry("type", "") == "material":
|
|
||||||
super()._onContainerChanged(container)
|
|
||||||
|
|
||||||
## Group brand together
|
|
||||||
def _sortKey(self, item) -> List[Any]:
|
|
||||||
result = []
|
|
||||||
result.append(item["metadata"]["brand"])
|
|
||||||
result.append(item["metadata"]["material"])
|
|
||||||
result.append(item["metadata"]["name"])
|
|
||||||
result.append(item["metadata"]["color_name"])
|
|
||||||
result.append(item["metadata"]["id"])
|
|
||||||
result.extend(super()._sortKey(item))
|
|
||||||
return result
|
|
|
@ -17,7 +17,7 @@ Item
|
||||||
|
|
||||||
UM.I18nCatalog { id: catalog; name: "cura"; }
|
UM.I18nCatalog { id: catalog; name: "cura"; }
|
||||||
|
|
||||||
Cura.NewMaterialsModel {
|
Cura.MaterialsModel {
|
||||||
id: materialsModel
|
id: materialsModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue