diff options
author | c.lamboo <casperlamboo@gmail.com> | 2022-09-05 12:44:29 +0300 |
---|---|---|
committer | c.lamboo <casperlamboo@gmail.com> | 2022-09-05 12:44:29 +0300 |
commit | 48b8585ce669a1e52bb21968a727acc8268cae3e (patch) | |
tree | 17455ebb0df1a66b0323785db3743c178efe2803 /cura/Machines | |
parent | ce6d7d72bd0194e3146e153450ce7d3fa7045d30 (diff) |
Make sure online printers are always shown in the correct tab
CURA-9277
Diffstat (limited to 'cura/Machines')
-rw-r--r-- | cura/Machines/Models/MachineListModel.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index d3ae8f7acb..ead1061a05 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -89,17 +89,27 @@ class MachineListModel(ListModel): machines_manager = CuraApplication.getInstance().getMachineManager() online_machine_stacks = machines_manager.getMachinesWithDefinition(definition_id, online_only = True) + def online_machines_has_connection_filter(machine_stack): + # This is required because machines loaded from projects have the is_online="True" but no connection type. + # We want to display them the same way as unconnected printers in this case. + has_connection = False + for connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]: + has_connection |= connection_type in machine_stack.configuredConnectionTypes + return has_connection + + online_machine_stacks = list(filter(online_machines_has_connection_filter, online_machine_stacks)) + other_machine_stacks.remove(abstract_machine) if abstract_machine in online_machine_stacks: online_machine_stacks.remove(abstract_machine) # Create a list item for abstract machine - self.addItem(abstract_machine, len(online_machine_stacks)) + self.addItem(abstract_machine, True, len(online_machine_stacks)) # Create list of machines that are children of the abstract machine for stack in online_machine_stacks: if self._show_cloud_printers: - self.addItem(stack) + self.addItem(stack, True) # Remove this machine from the other stack list if stack in other_machine_stacks: other_machine_stacks.remove(stack) @@ -119,25 +129,18 @@ class MachineListModel(ListModel): }) for stack in other_machine_stacks: - self.addItem(stack) + self.addItem(stack, False) - def addItem(self, container_stack: ContainerStack, machine_count: int = 0) -> None: + def addItem(self, container_stack: ContainerStack, is_online, machine_count: int = 0) -> None: if parseBool(container_stack.getMetaDataEntry("hidden", False)): return - # This is required because machines loaded from projects have the is_online="True" but no connection type. - # We want to display them the same way as unconnected printers in this case. - has_connection = False - has_connection |= parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)) - for connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]: - has_connection |= connection_type in container_stack.configuredConnectionTypes - self.appendItem({ "componentType": "MACHINE", "name": container_stack.getName(), "id": container_stack.getId(), "metadata": container_stack.getMetaData().copy(), - "isOnline": parseBool(container_stack.getMetaDataEntry("is_online", False)) and has_connection, + "isOnline": is_online, "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)), "machineCount": machine_count, }) |