QML was attempting to fetch variables that were emtpy. Using self.clear() properly removed unused items when the list is resized to be smaller.

Also add some dummy variables inside cloud printer expand and contract buttons.

CURA-9514
This commit is contained in:
joeydelarago 2022-08-31 10:05:41 +02:00
parent aa1c09591f
commit daab1aae71

View file

@ -77,7 +77,7 @@ class MachineListModel(ListModel):
self._change_timer.start() self._change_timer.start()
def _update(self) -> None: def _update(self) -> None:
self.setItems([]) # Clear items self.clear()
other_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") other_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine")
@ -105,14 +105,19 @@ class MachineListModel(ListModel):
if self._show_cloud_printers: if self._show_cloud_printers:
self.appendItem({ "listType": "HIDE_BUTTON", self.appendItem({ "listType": "HIDE_BUTTON",
"isOnline": True, "isOnline": True,
"isAbstractMachine": False,
"machineCount": 0
}) })
else: else:
self.appendItem({ "listType": "SHOW_BUTTON", self.appendItem({"listType": "SHOW_BUTTON",
"isOnline": True, "isOnline": True,
"isAbstractMachine": False,
"machineCount": 0
}) })
for stack in other_machine_stacks: for stack in other_machine_stacks:
self.addItem(stack) self.addItem(stack)
print(self.items)
def addItem(self, container_stack: ContainerStack, machine_count: int = 0) -> None: def addItem(self, container_stack: ContainerStack, machine_count: int = 0) -> None:
if parseBool(container_stack.getMetaDataEntry("hidden", False)): if parseBool(container_stack.getMetaDataEntry("hidden", False)):