CURA-5035 Don't show authors with 0 packages

This commit is contained in:
Ian Paschal 2018-04-13 17:27:57 +02:00
parent 523518020c
commit 85ebe741a8
4 changed files with 36 additions and 19 deletions

View file

@ -10,20 +10,16 @@ from UM.Qt.ListModel import ListModel
## Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
class AuthorsModel(ListModel):
NameRole = Qt.UserRole + 1
EmailRole = Qt.UserRole + 2
WebsiteRole = Qt.UserRole + 3
TypeRole = Qt.UserRole + 4
def __init__(self, parent = None):
super().__init__(parent)
self._metadata = None
self.addRoleName(AuthorsModel.NameRole, "name")
self.addRoleName(AuthorsModel.EmailRole, "email")
self.addRoleName(AuthorsModel.WebsiteRole, "website")
self.addRoleName(AuthorsModel.TypeRole, "type")
self.addRoleName(Qt.UserRole + 1, "name")
self.addRoleName(Qt.UserRole + 2, "email")
self.addRoleName(Qt.UserRole + 3, "website")
self.addRoleName(Qt.UserRole + 4, "type")
self.addRoleName(Qt.UserRole + 5, "packages_count")
# List of filters for queries. The result is the union of the each list of results.
self._filter = {} # type: Dict[str,str]
@ -40,7 +36,8 @@ class AuthorsModel(ListModel):
"name": author["name"],
"email": author["email"],
"website": author["website"],
"type": author["type"]
"type": author["type"],
"packages_count": author["packages_count"]
})
# Filter on all the key-word arguments.

View file

@ -74,19 +74,22 @@ class Toolbox(QObject, Extension):
"name": "Ultimaker",
"email": "ian.paschal@gmail.com",
"website": "ultimaker.com",
"type": "material"
"type": "material",
"packages_count": 7
},
{
"name": "DSM",
"email": "contact@dsm.nl",
"website": "www.dsm.nl",
"type": "material"
"type": "material",
"packages_count": 0
},
{
"name": "BASF",
"email": "contact@basf.de",
"website": "www.basf.de",
"type": "material"
"type": "material",
"packages_count": 0
}
],
"materials_installed": []
@ -225,19 +228,16 @@ class Toolbox(QObject, Extension):
self._package_manager.installPackage(file_path)
self.installChanged.emit()
self.metadataChanged.emit()
# TODO: Stuff
self.openRestartDialog("TODO")
self._restart_required = True
self.restartRequiredChanged.emit()
@pyqtSlot(str)
def uninstall(self, plugin_id):
self._package_manager.removePackage(plugin_id)
self.installChanged.emit()
self.metadataChanged.emit()
self._restart_required = True
self.restartRequiredChanged.emit()
# TODO: Stuff
Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Plugin browser"), "TODO")
@pyqtSlot(str)
def enable(self, plugin_id):
@ -261,6 +261,7 @@ class Toolbox(QObject, Extension):
@pyqtSlot()
def restart(self):
self._package_manager._removeAllScheduledPackages()
CuraApplication.getInstance().windowClosed()
@ -394,6 +395,7 @@ class Toolbox(QObject, Extension):
# TODO: Replace this with a proper API call:
for package in self._metadata["packages"]:
package["author"]["type"] = package["package_type"]
package["author"]["packages_count"] = 1
if package["author"] not in self._metadata["authors"]:
self._metadata["authors"].append(package["author"])
self._models["authors"].setMetadata(self._metadata["authors"])