mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-03 03:54:01 -06:00
Added sorting by brand to MaterialsModel.
Contributes to issue CURA-4243.
This commit is contained in:
parent
72c7d2bd76
commit
44537c4ef4
1 changed files with 8 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from typing import Any, List
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry #To listen for changes to the materials.
|
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.
|
from UM.Settings.Models.InstanceContainersModel import InstanceContainersModel #We're extending this class.
|
||||||
|
|
||||||
|
@ -23,3 +24,10 @@ class MaterialsModel(InstanceContainersModel):
|
||||||
def _onContainerChanged(self, container):
|
def _onContainerChanged(self, container):
|
||||||
if container.getMetaDataEntry("type", "") == "material":
|
if container.getMetaDataEntry("type", "") == "material":
|
||||||
super()._onContainerChanged(container)
|
super()._onContainerChanged(container)
|
||||||
|
|
||||||
|
## Group brand together
|
||||||
|
def _sortKey(self, item) -> List[Any]:
|
||||||
|
result = []
|
||||||
|
result.append(item["metadata"]["brand"])
|
||||||
|
result.extend(super()._sortKey(item))
|
||||||
|
return result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue