Allow setting Definition and setting Definition by ID

To match the other properties
This commit is contained in:
Arjen Hiemstra 2017-03-28 17:46:28 +02:00
parent 123c8bae45
commit 75931192f6

View file

@ -106,7 +106,17 @@ class GlobalStack(ContainerStack):
def definitionChanges(self) -> InstanceContainer:
return self._containers[_ContainerIndexes.DefinitionChanges]
@pyqtProperty(DefinitionContainer)
def setDefinition(self, new_definition: DefinitionContainer) -> None:
self.replaceContainer(_ContainerIndexes.Definition, new_definition)
def setDefinitionById(self, new_definition_id: str) -> None:
new_definition = ContainerRegistry.getInstance().findDefinitionContainers(id = new_definition_id)
if new_definition:
self.setDefinition(new_definition[0])
else:
raise Exceptions.InvalidContainerError("Could not find container with id {id}".format(id = new_definition_id))
@pyqtProperty(DefinitionContainer, fset = setDefinition, notify = pyqtContainersChanged)
def definition(self) -> DefinitionContainer:
return self._containers[_ContainerIndexes.Definition]