mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Add comments
CURA-7022
This commit is contained in:
parent
4a49c1cc8d
commit
b459895589
2 changed files with 26 additions and 0 deletions
|
@ -9,6 +9,9 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
|
|
||||||
class DiscoveredCloudPrintersModel(ListModel):
|
class DiscoveredCloudPrintersModel(ListModel):
|
||||||
|
"""
|
||||||
|
Model used to inform the application about newly added cloud printers, which are discovered from the user's account
|
||||||
|
"""
|
||||||
DeviceKeyRole = Qt.UserRole + 1
|
DeviceKeyRole = Qt.UserRole + 1
|
||||||
DeviceNameRole = Qt.UserRole + 2
|
DeviceNameRole = Qt.UserRole + 2
|
||||||
DeviceTypeRole = Qt.UserRole + 3
|
DeviceTypeRole = Qt.UserRole + 3
|
||||||
|
@ -28,6 +31,18 @@ class DiscoveredCloudPrintersModel(ListModel):
|
||||||
self._application = application # type: CuraApplication
|
self._application = application # type: CuraApplication
|
||||||
|
|
||||||
def addDiscoveredCloudPrinters(self, new_devices: List[Dict[str, str]]) -> None:
|
def addDiscoveredCloudPrinters(self, new_devices: List[Dict[str, str]]) -> None:
|
||||||
|
"""
|
||||||
|
Adds all the newly discovered cloud printers into the DiscoveredCloudPrintersModel.
|
||||||
|
|
||||||
|
:param new_devices: List of dictionaries which contain information about added cloud printers. Example:
|
||||||
|
{
|
||||||
|
"key": "YjW8pwGYcaUvaa0YgVyWeFkX3z",
|
||||||
|
"name": "NG 001",
|
||||||
|
"machine_type": "Ultimaker S5",
|
||||||
|
"firmware_version": "5.5.12.202001"
|
||||||
|
}
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
self._discovered_ultimaker_cloud_printers_list.extend(new_devices)
|
self._discovered_ultimaker_cloud_printers_list.extend(new_devices)
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
@ -36,11 +51,21 @@ class DiscoveredCloudPrintersModel(ListModel):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def clear(self) -> None:
|
def clear(self) -> None:
|
||||||
|
"""
|
||||||
|
Clears the contents of the DiscoveredCloudPrintersModel.
|
||||||
|
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
self._discovered_ultimaker_cloud_printers_list = []
|
self._discovered_ultimaker_cloud_printers_list = []
|
||||||
self._update()
|
self._update()
|
||||||
self.cloudPrintersDetectedChanged.emit(False)
|
self.cloudPrintersDetectedChanged.emit(False)
|
||||||
|
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
|
"""
|
||||||
|
Sorts the newly discovered cloud printers by name and then updates the ListModel.
|
||||||
|
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
items = self._discovered_ultimaker_cloud_printers_list[:]
|
items = self._discovered_ultimaker_cloud_printers_list[:]
|
||||||
items.sort(key = lambda k: k["name"])
|
items.sort(key = lambda k: k["name"])
|
||||||
self.setItems(items)
|
self.setItems(items)
|
||||||
|
|
|
@ -22,6 +22,7 @@ Item
|
||||||
property bool searchingForCloudPrinters: true
|
property bool searchingForCloudPrinters: true
|
||||||
property var discoveredCloudPrintersModel: CuraApplication.getDiscoveredCloudPrintersModel()
|
property var discoveredCloudPrintersModel: CuraApplication.getDiscoveredCloudPrintersModel()
|
||||||
|
|
||||||
|
// The area where either the discoveredCloudPrintersScrollView or the busyIndicator will be displayed
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
id: cloudPrintersContent
|
id: cloudPrintersContent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue