Removed unnecessary function and a call to it. Added some typing.

CURA-7090
This commit is contained in:
Dimitriovski 2020-01-14 11:50:47 +01:00
parent 7359492e11
commit e8f22beb27
No known key found for this signature in database
GPG key ID: 4E62757E2B0D304D
2 changed files with 4 additions and 13 deletions

View file

@ -5,7 +5,7 @@ from PyQt5.QtCore import Qt
from UM.Qt.ListModel import ListModel
from cura import ApplicationMetadata
from UM.Logger import Logger
from typing import List
from typing import List, Dict, Any
class SubscribedPackagesModel(ListModel):
@ -23,12 +23,12 @@ class SubscribedPackagesModel(ListModel):
self.addRoleName(Qt.UserRole + 4, "is_compatible")
self.addRoleName(Qt.UserRole + 5, "is_dismissed")
def setMetadata(self, data) -> None:
def setMetadata(self, data: List[Dict[str, List[Any]]]) -> None:
if self._metadata != data:
self._metadata = data
def addDiscrepancies(self, discrepancy: List[str]) -> None:
if self._discrepancies != discrepancy:
if set(self._discrepancies) != set(discrepancy): # convert to set() to check if they are same list, regardless of list order
self._discrepancies = discrepancy
def initialize(self) -> None:
@ -73,10 +73,3 @@ class SubscribedPackagesModel(ListModel):
if package != -1:
self.setProperty(package, property="is_dismissed", value=True)
Logger.debug("Package {} has been dismissed".format(package_id))
# Reads the dismissed_packages from user config file and applies them so they won't be shown in the Compatibility Dialog
def applyDismissedPackages(self, dismissed_packages: List[str]) -> None:
for package in dismissed_packages:
exists = self.find(key="package_id", value=package)
if exists != -1:
self.setProperty(exists, property="is_dismissed", value=True)

View file

@ -676,8 +676,7 @@ class Toolbox(QObject, Extension):
if package_discrepancy:
self._models["subscribed_packages"].addDiscrepancies(package_discrepancy)
self._models["subscribed_packages"].initialize()
self._models["subscribed_packages"].applyDismissedPackages(user_dismissed_packages)
Logger.log("d", "Discrepancy found between Cloud subscribed packages and Cura installed packages")
Logger.debug("Discrepancy found between Cloud subscribed packages and Cura installed packages")
sync_message = Message(i18n_catalog.i18nc(
"@info:generic",
"\nDo you want to sync material and software packages with your account?"),
@ -688,7 +687,6 @@ class Toolbox(QObject, Extension):
icon="",
description="Sync your Cloud subscribed packages to your local environment.",
button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)
sync_message.actionTriggered.connect(self._onSyncButtonClicked)
sync_message.show()