mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 05:56:00 +08: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
@ -31,10 +31,11 @@ class PackageList(ListModel):
|
||||
def __init__(self, parent: "QObject" = None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._packages: List[PackageModel] = []
|
||||
self._is_loading = True
|
||||
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
|
||||
|
||||
self.addRoleName(self.PackageRole, "package")
|
||||
|
||||
self.requestFirst()
|
||||
|
||||
def requestFirst(self) -> None:
|
||||
@ -82,8 +83,7 @@ class PackageList(ListModel):
|
||||
|
||||
for package_data in response_data["data"]:
|
||||
package = PackageModel(package_data, parent = self)
|
||||
self._packages.append(package)
|
||||
self._update()
|
||||
self.appendItem({"package": package}) # Add it to this list model.
|
||||
|
||||
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.
|
||||
"""
|
||||
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 Cura 1.7 as Cura
|
||||
|
||||
Item
|
||||
Column
|
||||
{
|
||||
Repeater
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user