CURA-5035 Add compatibility chart

This commit is contained in:
Ian Paschal 2018-05-02 18:43:12 +02:00
parent 0c51173bed
commit 0872d499f8
7 changed files with 169 additions and 74 deletions

View file

@ -0,0 +1,37 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import re
from typing import Dict
from PyQt5.QtCore import Qt, pyqtProperty
from UM.Qt.ListModel import ListModel
## Model that holds supported configurations (for material/quality packages).
class ConfigsModel(ListModel):
def __init__(self, parent = None):
super().__init__(parent)
self._configs = None
self.addRoleName(Qt.UserRole + 1, "machine")
self.addRoleName(Qt.UserRole + 2, "print_core")
self.addRoleName(Qt.UserRole + 3, "build_plate")
self.addRoleName(Qt.UserRole + 4, "support_material")
self.addRoleName(Qt.UserRole + 5, "quality")
def setConfigs(self, configs):
self._configs = configs
self._update()
def _update(self):
items = []
for item in self._configs:
items.append({
"machine": item["machine"],
"print_core": item["print_core"],
"build_plate": item["build_plate"],
"support_material": item["support_material"],
"quality": item["quality"]
})
self.setItems(items)

View file

@ -5,9 +5,8 @@ import re
from typing import Dict
from PyQt5.QtCore import Qt, pyqtProperty
from UM.Qt.ListModel import ListModel
from .ConfigsModel import ConfigsModel
## Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
class PackagesModel(ListModel):
@ -29,7 +28,8 @@ class PackagesModel(ListModel):
self.addRoleName(Qt.UserRole + 11, "download_url")
self.addRoleName(Qt.UserRole + 12, "last_updated")
self.addRoleName(Qt.UserRole + 13, "is_bundled")
self.addRoleName(Qt.UserRole + 14, "supported_configs")
self.addRoleName(Qt.UserRole + 14, "has_configs")
self.addRoleName(Qt.UserRole + 15, "supported_configs")
# List of filters for queries. The result is the union of the each list of results.
self._filter = {} # type: Dict[str, str]
@ -42,6 +42,16 @@ class PackagesModel(ListModel):
items = []
for package in self._metadata:
has_configs = False
configs_model = None
if "data" in package:
if "supported_configs" in package["data"]:
if len(package["data"]["supported_configs"]) > 0:
has_configs = True
configs_model = ConfigsModel()
configs_model.setConfigs(package["data"]["supported_configs"])
items.append({
"id": package["package_id"],
"type": package["package_type"],
@ -56,7 +66,8 @@ class PackagesModel(ListModel):
"download_url": package["download_url"] if "download_url" in package else None,
"last_updated": package["last_updated"] if "last_updated" in package else None,
"is_bundled": package["is_bundled"] if "is_bundled" in package else False,
"supported_configs": package["supported_configs"] if "supported_configs" in package else []
"has_configs": has_configs,
"supported_configs": configs_model
})
# Filter on all the key-word arguments.

View file

@ -21,6 +21,7 @@ from UM.Version import Version
from cura.CuraApplication import CuraApplication
from .AuthorsModel import AuthorsModel
from .PackagesModel import PackagesModel
from .ConfigsModel import ConfigsModel
i18n_catalog = i18nCatalog("cura")
@ -373,6 +374,7 @@ class Toolbox(QObject, Extension):
# one is because there are not separate API calls
# for different kinds of showcases.
self._metadata[type] = json_data["data"]
print(json_data["data"])
self._models[type].setMetadata(self._metadata[type])
# Do some auto filtering