mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 11:47:50 -06:00
Searching container registry returns ContainerStacks.
Made typing more generic to work with an ContainerStack to compensate. Made AbstractMachine getMachines a classmethod so it can be called with ContainerStacks. CURA-9514
This commit is contained in:
parent
d1ae3136aa
commit
7ffa770fb4
4 changed files with 22 additions and 6 deletions
|
@ -115,6 +115,7 @@ from . import CuraActions
|
|||
from . import PlatformPhysics
|
||||
from . import PrintJobPreviewImageProvider
|
||||
from .AutoSave import AutoSave
|
||||
from .Machines.Models.AbstractStacksModel import AbstractStacksModel
|
||||
from .Machines.Models.ActiveIntentQualitiesModel import ActiveIntentQualitiesModel
|
||||
from .Machines.Models.IntentSelectionModel import IntentSelectionModel
|
||||
from .SingleInstance import SingleInstance
|
||||
|
@ -1194,6 +1195,7 @@ class CuraApplication(QtApplication):
|
|||
qmlRegisterType(InstanceContainer, "Cura", 1, 0, "InstanceContainer")
|
||||
qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
|
||||
qmlRegisterType(GlobalStacksModel, "Cura", 1, 0, "GlobalStacksModel")
|
||||
qmlRegisterType(AbstractStacksModel, "Cura", 1, 0, "AbstractStacksModel")
|
||||
|
||||
self.processEvents()
|
||||
qmlRegisterType(FavoriteMaterialsModel, "Cura", 1, 0, "FavoriteMaterialsModel")
|
||||
|
|
|
@ -5,10 +5,12 @@ from PyQt6.QtCore import Qt, QTimer
|
|||
from typing import Optional, Dict
|
||||
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Util import parseBool
|
||||
|
||||
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
|
||||
from cura.Settings.AbstractMachine import AbstractMachine
|
||||
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
|
||||
from cura.Settings.GlobalStack import GlobalStack
|
||||
|
||||
|
@ -62,8 +64,11 @@ class AbstractStacksModel(ListModel):
|
|||
|
||||
abstract_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="abstract_machine")
|
||||
|
||||
abstract_machine_stacks.sort(key=lambda machine: machine.getName(), reverse=True)
|
||||
|
||||
for abstract_machine in abstract_machine_stacks:
|
||||
machine_stacks = container_stacks # FIXME: This should point to abstract_machine.getPrinters()
|
||||
machine_stacks = AbstractMachine.getMachines(abstract_machine)
|
||||
|
||||
|
||||
# Create item for abstract printer
|
||||
items.append(self.createItem(abstract_machine))
|
||||
|
@ -76,7 +81,7 @@ class AbstractStacksModel(ListModel):
|
|||
|
||||
self.setItems(items)
|
||||
|
||||
def createItem(self, container_stack: GlobalStack) -> Optional[Dict]:
|
||||
def createItem(self, container_stack: ContainerStack) -> Optional[Dict]:
|
||||
if parseBool(container_stack.getMetaDataEntry("hidden", False)):
|
||||
return
|
||||
|
||||
|
|
|
@ -14,13 +14,22 @@ class AbstractMachine(GlobalStack):
|
|||
super().__init__(container_id)
|
||||
self.setMetaDataEntry("type", "abstract_machine")
|
||||
|
||||
def getMachines(self) -> List[ContainerStack]:
|
||||
from cura.CuraApplication import CuraApplication
|
||||
@classmethod
|
||||
def getMachines(cls, abstract_machine: ContainerStack) -> List[ContainerStack]:
|
||||
""" Fetches containers for all machines that match definition with an abstract machine.
|
||||
|
||||
:param abstractMachine: The abstract machine stack.
|
||||
:return: A list of Containers or an empty list if stack is not an "abstract_machine"
|
||||
"""
|
||||
if not abstract_machine.getMetaDataEntry("type") == "abstract_machine":
|
||||
return []
|
||||
|
||||
from cura.CuraApplication import CuraApplication # In function to avoid circular import
|
||||
application = CuraApplication.getInstance()
|
||||
registry = application.getContainerRegistry()
|
||||
|
||||
printer_type = self.definition.getId()
|
||||
printer_type = abstract_machine.definition.getId()
|
||||
|
||||
return [machine for machine in registry.findContainerStacks(type="machine") if machine.definition.id == printer_type and ConnectionType.CloudConnection in machine.configuredConnectionTypes]
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import Cura 1.0 as Cura
|
|||
ListView
|
||||
{
|
||||
id: listView
|
||||
model: Cura.GlobalStacksModel {}
|
||||
model: Cura.AbstractStacksModel {}
|
||||
section.property: "hasRemoteConnection"
|
||||
property real contentHeight: childrenRect.height
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue