diff options
author | Jelle Spijker <spijker.jelle@gmail.com> | 2021-12-01 19:35:56 +0300 |
---|---|---|
committer | Jelle Spijker <spijker.jelle@gmail.com> | 2021-12-03 15:25:46 +0300 |
commit | 02e2e0a1c6bf71b29a3198a9beb78266ea241c64 (patch) | |
tree | 82e2cc5b169256e0c054afa54612f97811849e26 | |
parent | 09bc28d840165649e7e1b5e0ae41d5df25cc42b5 (diff) |
Filter already installed packages from the install listviews
Contributes to: CURA-8587
-rw-r--r-- | cura/CuraPackageManager.py | 5 | ||||
-rw-r--r-- | plugins/Marketplace/LocalPackageList.py | 3 | ||||
-rw-r--r-- | plugins/Marketplace/PackageList.py | 1 | ||||
-rw-r--r-- | plugins/Marketplace/RemotePackageList.py | 3 |
4 files changed, 6 insertions, 6 deletions
diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index 4199375608..a8400bfae7 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -1,8 +1,7 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import Any, Dict, List, Tuple, TYPE_CHECKING, Optional -from collections import Generator +from typing import Any, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator from cura.CuraApplication import CuraApplication #To find some resource types. from cura.Settings.GlobalStack import GlobalStack @@ -63,7 +62,7 @@ class CuraPackageManager(PackageManager): return machine_with_materials, machine_with_qualities - def iterateAllLocalPackages(self) -> Generator[Dict[str, Any]]: + def iterateAllLocalPackages(self) -> Generator[Dict[str, Any], None, None]: """ A generator which returns an unordered list of all the PackageModels""" # Get all the installed packages, add a section_title depending on package_type and user installed diff --git a/plugins/Marketplace/LocalPackageList.py b/plugins/Marketplace/LocalPackageList.py index d93ed87ba0..bbe74a9056 100644 --- a/plugins/Marketplace/LocalPackageList.py +++ b/plugins/Marketplace/LocalPackageList.py @@ -13,8 +13,6 @@ from UM.i18n import i18nCatalog from UM.TaskManagement.HttpRequestManager import HttpRequestManager from UM.Logger import Logger -from cura.CuraApplication import CuraApplication - from .PackageList import PackageList from .PackageModel import PackageModel from . import Marketplace @@ -38,7 +36,6 @@ class LocalPackageList(PackageList): def __init__(self, parent: Optional["QObject"] = None) -> None: super().__init__(parent) - self._manager = CuraApplication.getInstance().getPackageManager() self._has_footer = False @pyqtSlot() diff --git a/plugins/Marketplace/PackageList.py b/plugins/Marketplace/PackageList.py index d3da8c826a..798a15324e 100644 --- a/plugins/Marketplace/PackageList.py +++ b/plugins/Marketplace/PackageList.py @@ -26,6 +26,7 @@ class PackageList(ListModel): def __init__(self, parent: Optional["QObject"] = None) -> None: super().__init__(parent) + self._manager = CuraApplication.getInstance().getPackageManager() self._error_message = "" self.addRoleName(self.PackageRole, "package") self._is_loading = False diff --git a/plugins/Marketplace/RemotePackageList.py b/plugins/Marketplace/RemotePackageList.py index 4fedde9ff0..d5c0763609 100644 --- a/plugins/Marketplace/RemotePackageList.py +++ b/plugins/Marketplace/RemotePackageList.py @@ -31,6 +31,7 @@ class RemotePackageList(PackageList): self._request_url = self._initialRequestUrl() self.isLoadingChanged.connect(self._onLoadingChanged) self.isLoadingChanged.emit() + self._locally_installed = { p["package_id"] for p in self._manager.locally_installed_packages } def __del__(self) -> None: """ @@ -128,6 +129,8 @@ class RemotePackageList(PackageList): return for package_data in response_data["data"]: + if package_data["package_id"] in self._locally_installed: + continue # We should only show packages which are not already installed try: package = PackageModel(package_data, parent = self) self.appendItem({"package": package}) # Add it to this list model. |