mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Ensure that the intent model gets populated
CURA-6534
This commit is contained in:
parent
266cf52cbc
commit
2e7f8b066a
1 changed files with 20 additions and 1 deletions
|
@ -6,12 +6,31 @@ from PyQt5.QtCore.QObject import QObject
|
|||
from UM.Qt.ListModel import ListModel
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
|
||||
|
||||
class IntentModel(ListModel):
|
||||
NameRole = Qt.UserRole + 1
|
||||
IdRole = Qt.UserRole + 2
|
||||
|
||||
def __init__(self, parent: Optional[QObject] = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self.addRoleName(self.NameRole, "name")
|
||||
self.addRoleName(self.IdRole, "id")
|
||||
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
|
||||
ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
|
||||
|
||||
self._update()
|
||||
|
||||
def _onChanged(self, container):
|
||||
if container.getMetaDataEntry("type") == "intent":
|
||||
self._update()
|
||||
|
||||
def _update(self) -> None:
|
||||
pass
|
||||
new_items = []
|
||||
for container in ContainerRegistry.getInstance().findInstanceContainers(type="intent"):
|
||||
new_items.append({"name": container.getName(), "id": container.getId()})
|
||||
|
||||
self.setItems(new_items)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue