Move removeQualityChangesGroup() into QualityManager

This commit is contained in:
Lipu Fei 2018-03-02 16:47:25 +01:00
parent 6cae82a64e
commit 8324f4f44e
3 changed files with 23 additions and 12 deletions

View File

@ -1,7 +1,8 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import QObject, QTimer, pyqtSignal from typing import TYPE_CHECKING
from PyQt5.QtCore import QObject, QTimer, pyqtSignal, pyqtSlot
from UM.Application import Application from UM.Application import Application
from UM.Logger import Logger from UM.Logger import Logger
@ -10,6 +11,10 @@ from UM.Util import parseBool
from .QualityGroup import QualityGroup from .QualityGroup import QualityGroup
from .QualityNode import QualityNode from .QualityNode import QualityNode
if TYPE_CHECKING:
from cura.Settings.GlobalStack import GlobalStack
from .QualityChangesGroup import QualityChangesGroup
# #
# Quality lookup tree structure: # Quality lookup tree structure:
# #
@ -332,6 +337,19 @@ class QualityManager(QObject):
return quality_group_dict return quality_group_dict
#
# Methods for GUI
#
#
# Remove the given quality changes group.
#
@pyqtSlot(QObject)
def removeQualityChangesGroup(self, quality_changes_group: "QualityChangesGroup"):
Logger.log("i", "Removing quality changes group [%s]", quality_changes_group.name)
for node in quality_changes_group.getAllNodes():
self._container_registry.removeContainer(node.metadata["id"])
# #
# Gets the machine definition ID that can be used to search for Quality containers that are suitable for the given # Gets the machine definition ID that can be used to search for Quality containers that are suitable for the given

View File

@ -382,15 +382,6 @@ class ContainerManager(QObject):
self._container_registry.addContainer(new_changes) self._container_registry.addContainer(new_changes)
#
# Remove the given quality changes group
#
@pyqtSlot(QObject)
def removeQualityChangesGroup(self, quality_changes_group):
Logger.log("i", "Removing quality changes group [%s]", quality_changes_group.name)
for node in quality_changes_group.getAllNodes():
self._container_registry.removeContainer(node.metadata["id"])
# #
# Rename a set of quality changes containers. Returns the new name. # Rename a set of quality changes containers. Returns the new name.
# #

View File

@ -13,6 +13,8 @@ import Cura 1.0 as Cura
Item Item
{ {
id: base id: base
property QtObject qualityManager: CuraApplication.getQualityManager()
property var resetEnabled: false // Keep PreferencesDialog happy property var resetEnabled: false // Keep PreferencesDialog happy
property var extrudersModel: Cura.ExtrudersModel {} property var extrudersModel: Cura.ExtrudersModel {}
@ -239,9 +241,9 @@ Item
onYes: onYes:
{ {
Cura.ContainerManager.removeQualityChangesGroup(base.currentItem.quality_changes_group); base.qualityManager.removeQualityChangesGroup(base.currentItem.quality_changes_group);
// reset current item to the first if available // reset current item to the first if available
qualityListView.currentIndex = -1; // TODO: Reset selection. qualityListView.currentIndex = -1; // Reset selection.
} }
} }