mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-20 21:27:50 -06:00
Store items directly in listModel when parsing them
No need to use a custom list in Python and update the ListModel from that. This is much simpler and more efficient. Contributes to issue CURA-8556.
This commit is contained in:
parent
6415a2649e
commit
38038b3752
2 changed files with 4 additions and 8 deletions
|
@ -31,10 +31,11 @@ class PackageList(ListModel):
|
||||||
def __init__(self, parent: "QObject" = None):
|
def __init__(self, parent: "QObject" = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self._packages: List[PackageModel] = []
|
|
||||||
self._is_loading = True
|
self._is_loading = True
|
||||||
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
|
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
|
||||||
|
|
||||||
|
self.addRoleName(self.PackageRole, "package")
|
||||||
|
|
||||||
self.requestFirst()
|
self.requestFirst()
|
||||||
|
|
||||||
def requestFirst(self) -> None:
|
def requestFirst(self) -> None:
|
||||||
|
@ -82,8 +83,7 @@ class PackageList(ListModel):
|
||||||
|
|
||||||
for package_data in response_data["data"]:
|
for package_data in response_data["data"]:
|
||||||
package = PackageModel(package_data, parent = self)
|
package = PackageModel(package_data, parent = self)
|
||||||
self._packages.append(package)
|
self.appendItem({"package": package}) # Add it to this list model.
|
||||||
self._update()
|
|
||||||
|
|
||||||
def _onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]) -> None:
|
def _onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -92,7 +92,3 @@ class PackageList(ListModel):
|
||||||
:param error: The error status of the request.
|
:param error: The error status of the request.
|
||||||
"""
|
"""
|
||||||
pass # TODO: Handle errors.
|
pass # TODO: Handle errors.
|
||||||
|
|
||||||
def _update(self) -> None:
|
|
||||||
# TODO: Get list of packages from Marketplace class.
|
|
||||||
pass
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import QtQuick 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import Cura 1.7 as Cura
|
import Cura 1.7 as Cura
|
||||||
|
|
||||||
Item
|
Column
|
||||||
{
|
{
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue