From 44537c4ef46d9ad2730faca8eb19cfbf2782b170 Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Mon, 4 Dec 2017 11:11:57 +0100 Subject: [PATCH] Added sorting by brand to MaterialsModel. Contributes to issue CURA-4243. --- cura/Settings/MaterialsModel.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cura/Settings/MaterialsModel.py b/cura/Settings/MaterialsModel.py index bab8929765..e3d56c2f86 100644 --- a/cura/Settings/MaterialsModel.py +++ b/cura/Settings/MaterialsModel.py @@ -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