Move GlobalStackModel into cura.UI module

This commit is contained in:
Lipu Fei 2019-03-20 09:09:48 +01:00
parent b6216bf4a3
commit 8c0cb2b7b8
2 changed files with 7 additions and 6 deletions

View file

@ -48,7 +48,7 @@ from cura.Arranging.Arrange import Arrange
from cura.Arranging.ArrangeObjectsJob import ArrangeObjectsJob
from cura.Arranging.ArrangeObjectsAllBuildPlatesJob import ArrangeObjectsAllBuildPlatesJob
from cura.Arranging.ShapeArray import ShapeArray
from cura.GlobalStacksModel import GlobalStacksModel
from cura.UI.GlobalStacksModel import GlobalStacksModel
from cura.Scene.ConvexHullDecorator import ConvexHullDecorator
from cura.Operations.SetParentOperation import SetParentOperation
from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator

View file

@ -19,7 +19,7 @@ class GlobalStacksModel(ListModel):
MetaDataRole = Qt.UserRole + 5
SectionNameRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page
def __init__(self, parent = None):
def __init__(self, parent = None) -> None:
super().__init__(parent)
self._catalog = i18nCatalog("cura")
@ -44,12 +44,12 @@ class GlobalStacksModel(ListModel):
self._updateDelayed()
## Handler for container added/removed events from registry
def _onContainerChanged(self, container):
def _onContainerChanged(self, container) -> None:
# We only need to update when the added / removed container GlobalStack
if isinstance(container, GlobalStack):
self._updateDelayed()
def _updateDelayed(self):
def _updateDelayed(self) -> None:
self._change_timer.start()
def _update(self) -> None:
@ -61,7 +61,8 @@ class GlobalStacksModel(ListModel):
has_remote_connection = False
for connection_type in container_stack.configuredConnectionTypes:
has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]
has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value,
ConnectionType.CloudConnection.value]
if container_stack.getMetaDataEntry("hidden", False) in ["True", True]:
continue
@ -74,5 +75,5 @@ class GlobalStacksModel(ListModel):
"hasRemoteConnection": has_remote_connection,
"metadata": container_stack.getMetaData().copy(),
"sectionName": section_name})
items.sort(key=lambda i: not i["hasRemoteConnection"])
items.sort(key = lambda i: not i["hasRemoteConnection"])
self.setItems(items)