Rewrite IntentModel to return quality types rather than actual profiles

We don't want the profiles, because that'd be specific to one extruder. We want the quality types and intent categories as tuples again.

Contributes to issue CURA-6597.
This commit is contained in:
Ghostkeeper 2019-07-04 11:04:44 +02:00
parent 49a6161ee8
commit 6ba70f3425
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -7,18 +7,18 @@ from UM.Qt.ListModel import ListModel
from PyQt5.QtCore import Qt, pyqtProperty, pyqtSignal from PyQt5.QtCore import Qt, pyqtProperty, pyqtSignal
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
from cura.Settings.IntentManager import IntentManager
import cura.CuraApplication
class IntentModel(ListModel): class IntentModel(ListModel):
NameRole = Qt.UserRole + 1 NameRole = Qt.UserRole + 1
IdRole = Qt.UserRole + 2 QualityTypeRole = Qt.UserRole + 2
ContainerRole = Qt.UserRole + 3
def __init__(self, parent: Optional[QObject] = None) -> None: def __init__(self, parent: Optional[QObject] = None) -> None:
super().__init__(parent) super().__init__(parent)
self.addRoleName(self.NameRole, "name") self.addRoleName(self.NameRole, "name")
self.addRoleName(self.IdRole, "id") self.addRoleName(self.QualityTypeRole, "quality_type")
self.addRoleName(self.ContainerRole, "container")
self._intent_category = "engineering" self._intent_category = "engineering"
@ -34,7 +34,7 @@ class IntentModel(ListModel):
self._intent_category = new_category self._intent_category = new_category
self._intent_category_changed.emit() self._intent_category_changed.emit()
@pyqtProperty(str, fset=setIntentCategory, notify=_intent_category_changed) @pyqtProperty(str, fset = setIntentCategory, notify = _intent_category_changed)
def intentCategory(self) -> str: def intentCategory(self) -> str:
return self._intent_category return self._intent_category
@ -44,7 +44,12 @@ class IntentModel(ListModel):
def _update(self) -> None: def _update(self) -> None:
new_items = [] new_items = []
for container in ContainerRegistry.getInstance().findInstanceContainers(type = "intent", intent_category = self._intent_category): application = cura.CuraApplication.CuraApplication.getInstance()
new_items.append({"name": container.getName(), "id": container.getId(), "container": container}) quality_manager = application.getQualityManager()
global_stack = application.getGlobalContainerStack()
for intent_category, quality_type in IntentManager.getInstance().currentAvailableIntents():
if intent_category == self._intent_category:
new_items.append({"name": quality_manager.getQualityGroups(global_stack)[quality_type].name, "quality_type": quality_type})
self.setItems(new_items) self.setItems(new_items)