Add comments

CURA-7022
This commit is contained in:
Kostas Karmas 2020-04-29 14:19:28 +02:00
parent 4a49c1cc8d
commit b459895589
2 changed files with 26 additions and 0 deletions

View file

@ -9,6 +9,9 @@ if TYPE_CHECKING:
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
DeviceNameRole = Qt.UserRole + 2
DeviceTypeRole = Qt.UserRole + 3
@ -28,6 +31,18 @@ class DiscoveredCloudPrintersModel(ListModel):
self._application = application # type: CuraApplication
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._update()
@ -36,11 +51,21 @@ class DiscoveredCloudPrintersModel(ListModel):
@pyqtSlot()
def clear(self) -> None:
"""
Clears the contents of the DiscoveredCloudPrintersModel.
:return: None
"""
self._discovered_ultimaker_cloud_printers_list = []
self._update()
self.cloudPrintersDetectedChanged.emit(False)
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.sort(key = lambda k: k["name"])
self.setItems(items)

View file

@ -22,6 +22,7 @@ Item
property bool searchingForCloudPrinters: true
property var discoveredCloudPrintersModel: CuraApplication.getDiscoveredCloudPrintersModel()
// The area where either the discoveredCloudPrintersScrollView or the busyIndicator will be displayed
Rectangle
{
id: cloudPrintersContent