1# Copyright (c) 2019 Ultimaker B.V.
2# Cura is released under the terms of the LGPLv3 or higher.
3
4from typing import Any, Dict, Optional
5
6from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
7
8
9class QualityChangesGroup(QObject):
10    """Data struct to group several quality changes instance containers together.
11
12    Each group represents one "custom profile" as the user sees it, which contains an instance container for the
13    global stack and one instance container per extruder.
14    """
15
16    def __init__(self, name: str, quality_type: str, intent_category: str, parent: Optional["QObject"] = None) -> None:
17        super().__init__(parent)
18        self._name = name
19        self.quality_type = quality_type
20        self.intent_category = intent_category
21        self.is_available = False
22        self.metadata_for_global = {}    # type: Dict[str, Any]
23        self.metadata_per_extruder = {}  # type: Dict[int, Dict[str, Any]]
24
25    nameChanged = pyqtSignal()
26
27    def setName(self, name: str) -> None:
28        if self._name != name:
29            self._name = name
30            self.nameChanged.emit()
31
32    @pyqtProperty(str, fset = setName, notify = nameChanged)
33    def name(self) -> str:
34        return self._name
35
36    def __str__(self) -> str:
37        return "{class_name}[{name}, available = {is_available}]".format(class_name = self.__class__.__name__, name = self.name, is_available = self.is_available)
38