Added sorting by brand to MaterialsModel.

Contributes to issue CURA-4243.
This commit is contained in:
Jack Ha 2017-12-04 11:11:57 +01:00
parent 72c7d2bd76
commit 44537c4ef4

View file

@ -1,6 +1,7 @@
# Copyright (c) 2017 Ultimaker B.V.
# 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.Models.InstanceContainersModel import InstanceContainersModel #We're extending this class.
@ -23,3 +24,10 @@ class MaterialsModel(InstanceContainersModel):
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.extend(super()._sortKey(item))
return result