From 8162bdcfa82a9b39e4ede12dfa37179cb8710735 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 30 Nov 2021 14:42:12 +0100 Subject: [PATCH] Don't show download count for bundled plug-ins I considered rewriting the section title property to be QML-only and translate it from the QML, but this is a bit simpler in the end, even though there is data duplication now. Contributes to issue CURA-8565. --- plugins/Marketplace/PackageModel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/Marketplace/PackageModel.py b/plugins/Marketplace/PackageModel.py index 4a4973a2dc..62558a51b8 100644 --- a/plugins/Marketplace/PackageModel.py +++ b/plugins/Marketplace/PackageModel.py @@ -17,10 +17,11 @@ class PackageModel(QObject): QML. The model can also be constructed directly from a response received by the API. """ - def __init__(self, package_data: Dict[str, Any], section_title: Optional[str] = None, parent: Optional[QObject] = None) -> None: + def __init__(self, package_data: Dict[str, Any], installation_status: str, section_title: Optional[str] = None, parent: Optional[QObject] = None) -> None: """ Constructs a new model for a single package. :param package_data: The data received from the Marketplace API about the package to create. + :param installation_status: Whether the package is `not_installed`, `installed` or `bundled`. :param section_title: If the packages are to be categorized per section provide the section_title :param parent: The parent QML object that controls the lifetime of this model (normally a PackageList). """ @@ -48,6 +49,7 @@ class PackageModel(QObject): if not self._icon_url or self._icon_url == "": self._icon_url = author_data.get("icon_url", "") + self._installation_status = installation_status self._section_title = section_title # Note that there's a lot more info in the package_data than just these specified here. @@ -95,6 +97,10 @@ class PackageModel(QObject): def authorInfoUrl(self): return self._author_info_url + @pyqtProperty(str, constant = True) + def installationStatus(self) -> str: + return self._installation_status + @pyqtProperty(str, constant = True) def sectionTitle(self) -> Optional[str]: return self._section_title