mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-29 07:14:24 +08:00
CURA-5536 Calculate the number of installed packages by author.
This commit is contained in:
parent
1b6c172e6d
commit
96cc1be2ff
@ -63,7 +63,7 @@ Item
|
||||
Label
|
||||
{
|
||||
id: name
|
||||
text: model.name
|
||||
text: toolbox.viewCategory == "material" ? model.name + " (" + toolbox.getNumberOfInstalledPackagesByAuthor(model.id) + "/" + model.package_count + ")" : model.name
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
color: UM.Theme.getColor("text")
|
||||
|
@ -43,7 +43,7 @@ class AuthorsModel(ListModel):
|
||||
"package_count": author["package_count"] if "package_count" in author else 0,
|
||||
"package_types": author["package_types"] if "package_types" in author else [],
|
||||
"icon_url": author["icon_url"] if "icon_url" in author else None,
|
||||
"description": "Material and quality profiles from {author_name}".format( author_name = author["display_name"])
|
||||
"description": "Material and quality profiles from {author_name}".format(author_name = author["display_name"])
|
||||
})
|
||||
|
||||
# Filter on all the key-word arguments.
|
||||
|
@ -501,6 +501,15 @@ class Toolbox(QObject, Extension):
|
||||
def isInstalled(self, package_id: str) -> bool:
|
||||
return self._package_manager.isPackageInstalled(package_id)
|
||||
|
||||
@pyqtSlot(str, result = int)
|
||||
def getNumberOfInstalledPackagesByAuthor(self, author_id: str) -> int:
|
||||
count = 0
|
||||
for package in self._metadata["materials_installed"]:
|
||||
if package["author"]["author_id"] == author_id:
|
||||
if self.isInstalled(package["package_id"]):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isEnabled(self, package_id: str) -> bool:
|
||||
if package_id in self._plugin_registry.getActivePlugins():
|
||||
@ -722,27 +731,27 @@ class Toolbox(QObject, Extension):
|
||||
# --------------------------------------------------------------------------
|
||||
@pyqtProperty(QObject, notify = metadataChanged)
|
||||
def authorsModel(self) -> AuthorsModel:
|
||||
return self._models["authors"]
|
||||
return cast(AuthorsModel, self._models["authors"])
|
||||
|
||||
@pyqtProperty(QObject, notify = metadataChanged)
|
||||
def packagesModel(self) -> PackagesModel:
|
||||
return self._models["packages"]
|
||||
return cast(PackagesModel, self._models["packages"])
|
||||
|
||||
@pyqtProperty(QObject, notify = metadataChanged)
|
||||
def pluginsShowcaseModel(self) -> PackagesModel:
|
||||
return self._models["plugins_showcase"]
|
||||
return cast(PackagesModel, self._models["plugins_showcase"])
|
||||
|
||||
@pyqtProperty(QObject, notify = metadataChanged)
|
||||
def pluginsInstalledModel(self) -> PackagesModel:
|
||||
return self._models["plugins_installed"]
|
||||
return cast(PackagesModel, self._models["plugins_installed"])
|
||||
|
||||
@pyqtProperty(QObject, notify = metadataChanged)
|
||||
def materialsShowcaseModel(self) -> PackagesModel:
|
||||
return self._models["materials_showcase"]
|
||||
def materialsShowcaseModel(self) -> AuthorsModel:
|
||||
return cast(AuthorsModel, self._models["materials_showcase"])
|
||||
|
||||
@pyqtProperty(QObject, notify = metadataChanged)
|
||||
def materialsInstalledModel(self) -> PackagesModel:
|
||||
return self._models["materials_installed"]
|
||||
return cast(PackagesModel, self._models["materials_installed"])
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user