Put override logic in Python instead of QML

Contributes to CL-1259
This commit is contained in:
Ian Paschal 2019-05-20 10:59:34 +02:00
parent d70acc793f
commit 3cf2e19692

View file

@ -3,11 +3,16 @@
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot
BLOCKING_CHANGE_TYPES = [
"material_insert", "buildplate_change"
]
class ConfigurationChangeModel(QObject): class ConfigurationChangeModel(QObject):
def __init__(self, type_of_change: str, index: int, target_name: str, origin_name: str) -> None: def __init__(self, type_of_change: str, index: int, target_name: str, origin_name: str) -> None:
super().__init__() super().__init__()
self._type_of_change = type_of_change self._type_of_change = type_of_change
# enum = ["material", "print_core_change"] # enum = ["material", "print_core_change"]
self._can_override = False if self._type_of_change in BLOCKING_CHANGE_TYPES else True
self._index = index self._index = index
self._target_name = target_name self._target_name = target_name
self._origin_name = origin_name self._origin_name = origin_name
@ -27,3 +32,7 @@ class ConfigurationChangeModel(QObject):
@pyqtProperty(str, constant = True) @pyqtProperty(str, constant = True)
def originName(self) -> str: def originName(self) -> str:
return self._origin_name return self._origin_name
@pyqtProperty(bool, constant = True)
def canOverride(self) -> bool:
return self._can_override