Add model to represent packages and export information to QML

We'll construct a bunch of these when we receive information from the API.

Contributes to issue CURA-8556.
This commit is contained in:
Ghostkeeper 2021-10-21 15:03:41 +02:00
parent cf2b0d2777
commit 0f5c923d93
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
2 changed files with 37 additions and 4 deletions

View file

@ -2,9 +2,14 @@
# Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import Qt
from typing import List, TYPE_CHECKING
from UM.Qt.ListModel import ListModel
from .PackageModel import PackageModel # This list is a list of PackageModels.
if TYPE_CHECKING:
from PyQt5.QtCore import QObject
class PackageList(ListModel):
"""
Represents a list of packages to be displayed in the interface.
@ -13,9 +18,12 @@ class PackageList(ListModel):
paginated.
"""
PackageIDRole = Qt.UserRole + 1
DisplayNameRole = Qt.UserRole + 2
# TODO: Add more roles here when we need to display more information about packages.
PackageRole = Qt.UserRole + 1
def __init__(self, parent: "QObject" = None):
super().__init__(parent)
self._packages: List[PackageModel] = []
def _update(self) -> None:
# TODO: Get list of packages from Marketplace class.