mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Prevent crash when setting non default intent category
This commit is contained in:
parent
f456c1a885
commit
fe8a3fc61d
2 changed files with 13 additions and 2 deletions
|
@ -106,11 +106,15 @@ class IntentCategoryModel(ListModel):
|
|||
for category in available_categories:
|
||||
qualities = IntentModel()
|
||||
qualities.setIntentCategory(category)
|
||||
try:
|
||||
weight = list(IntentCategoryModel._get_translations().keys()).index(category)
|
||||
except ValueError:
|
||||
weight = 99
|
||||
result.append({
|
||||
"name": IntentCategoryModel.translation(category, "name", category),
|
||||
"description": IntentCategoryModel.translation(category, "description", None),
|
||||
"intent_category": category,
|
||||
"weight": list(IntentCategoryModel._get_translations().keys()).index(category),
|
||||
"weight": weight,
|
||||
"qualities": qualities
|
||||
})
|
||||
result.sort(key = lambda k: k["weight"])
|
||||
|
|
|
@ -361,8 +361,15 @@ class QualityManagementModel(ListModel):
|
|||
"section_name": catalog.i18nc("@label", intent_translations.get(intent_category, {}).get("name", catalog.i18nc("@label", "Unknown"))),
|
||||
})
|
||||
# Sort by quality_type for each intent category
|
||||
intent_translations_list = list(intent_translations)
|
||||
|
||||
result = sorted(result, key = lambda x: (list(intent_translations).index(x["intent_category"]), x["quality_type"]))
|
||||
def getIntentWeight(intent_category):
|
||||
try:
|
||||
return intent_translations_list.index(intent_category)
|
||||
except ValueError:
|
||||
return 99
|
||||
|
||||
result = sorted(result, key = lambda x: (getIntentWeight(x["intent_category"]), x["quality_type"]))
|
||||
item_list += result
|
||||
|
||||
# Create quality_changes group items
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue