Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorc.lamboo <casperlamboo@gmail.com>2022-08-26 11:45:45 +0300
committerc.lamboo <casperlamboo@gmail.com>2022-08-26 11:45:45 +0300
commit8b84db705943217072003bec7d97439506a91eb0 (patch)
tree305c4c53f6489063964d7dad4792dec8ba07b7f7 /cura/Machines
parentd843921c7a0b483ba37cf868e811e831e8ef5a22 (diff)
Remove AbstractMachine
Having a separate class for the AbstractMachine complicated things; it's behaviour was extremely similar to the GlobalStack so adding one more stack container type in addition to the many similar setting container types we already have adds complexity to the system. Having these different classes for machines and abstract machines also add complexity to the update script as the abstract machines were stored in a separate folder from the machine types. Because of these reasons we decided to replace the AbstractMachine by a GlobalStack where the is_abstract_machine property metadata property is set to True. CURA-9514, CURA-9277 Co-authored-by: joeydelarago <joeydelarago@gmail.com>
Diffstat (limited to 'cura/Machines')
-rw-r--r--cura/Machines/Models/MachineListModel.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py
index f3781cfd60..4b80410018 100644
--- a/cura/Machines/Models/MachineListModel.py
+++ b/cura/Machines/Models/MachineListModel.py
@@ -8,9 +8,8 @@ from UM.Settings.ContainerStack import ContainerStack
from UM.i18n import i18nCatalog
from UM.Util import parseBool
-from cura.Settings.AbstractMachine import AbstractMachine
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
-from cura.Settings.GlobalStack import GlobalStack
+from cura.Settings.GlobalStack import GlobalStack, getMachinesWithDefinition
class MachineListModel(ListModel):
@@ -19,8 +18,8 @@ class MachineListModel(ListModel):
HasRemoteConnectionRole = Qt.ItemDataRole.UserRole + 3
MetaDataRole = Qt.ItemDataRole.UserRole + 4
IsOnlineRole = Qt.ItemDataRole.UserRole + 5
- MachineTypeRole = Qt.ItemDataRole.UserRole + 6
- MachineCountRole = Qt.ItemDataRole.UserRole + 7
+ MachineCountRole = Qt.ItemDataRole.UserRole + 6
+ IsAbstractMachine = Qt.ItemDataRole.UserRole + 7
def __init__(self, parent=None) -> None:
super().__init__(parent)
@@ -32,8 +31,8 @@ class MachineListModel(ListModel):
self.addRoleName(self.HasRemoteConnectionRole, "hasRemoteConnection")
self.addRoleName(self.MetaDataRole, "metadata")
self.addRoleName(self.IsOnlineRole, "isOnline")
- self.addRoleName(self.MachineTypeRole, "machineType")
self.addRoleName(self.MachineCountRole, "machineCount")
+ self.addRoleName(self.IsAbstractMachine, "isAbstractMachine")
self._change_timer = QTimer()
self._change_timer.setInterval(200)
@@ -61,14 +60,16 @@ class MachineListModel(ListModel):
other_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine")
- abstract_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type = "abstract_machine")
+ abstract_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(is_abstract_machine = "True")
abstract_machine_stacks.sort(key = lambda machine: machine.getName(), reverse = True)
for abstract_machine in abstract_machine_stacks:
- online_machine_stacks = AbstractMachine.getMachines(abstract_machine, online_only = True)
+ definition_id = abstract_machine.definition.getId()
+ online_machine_stacks = getMachinesWithDefinition(definition_id, online_only = True)
# Create a list item for abstract machine
self.addItem(abstract_machine, len(online_machine_stacks))
+ other_machine_stacks.remove(abstract_machine)
# Create list of machines that are children of the abstract machine
for stack in online_machine_stacks:
@@ -87,6 +88,6 @@ class MachineListModel(ListModel):
"id": container_stack.getId(),
"metadata": container_stack.getMetaData().copy(),
"isOnline": parseBool(container_stack.getMetaDataEntry("is_online", False)),
- "machineType": container_stack.getMetaDataEntry("type"),
+ "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)),
"machineCount": machine_count,
})