Let _fetchInstanceContainers return containers split by loaded or not

It must now return two dictionaries: One for the profiles that have been completely loaded and one for the profiles that are only metadata. We could probably improve on these a little bit, since all of these (except the material model) will now load all available quality profiles. I'll see if it is necessary to optimise that.

Contributes to issue CURA-4243.
This commit is contained in:
Ghostkeeper 2017-11-28 14:26:14 +01:00
parent e5427eded6
commit eb3981b4e0
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
3 changed files with 17 additions and 15 deletions

View file

@ -18,7 +18,7 @@ class UserProfilesModel(ProfilesModel):
def _fetchInstanceContainers(self):
global_container_stack = Application.getInstance().getGlobalContainerStack()
if not global_container_stack:
return []
return {}, {}
# Fetch the list of quality changes.
quality_manager = QualityManager.getInstance()
@ -27,7 +27,7 @@ class UserProfilesModel(ProfilesModel):
# Detecting if the machine has multiple extrusion
multiple_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
# Get the list of extruders and place the selected extruder at the front of the list.
# Get the list of extruders and place the selected extruder at the front of the list.
extruder_manager = ExtruderManager.getInstance()
active_extruder = extruder_manager.getActiveExtruderStack()
extruder_stacks = extruder_manager.getActiveExtruderStacks()
@ -56,13 +56,13 @@ class UserProfilesModel(ProfilesModel):
if multiple_extrusion:
# If the printer has multiple extruders then quality changes related to the current extruder are kept
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
filtered_quality_changes = {qc.getId():qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
qc.getMetaDataEntry("extruder") is not None and
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())]
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())}
else:
# If not, the quality changes of the global stack are selected
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
qc.getMetaDataEntry("extruder") is None]
filtered_quality_changes = {qc.getId():qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
qc.getMetaDataEntry("extruder") is None}
return filtered_quality_changes
return filtered_quality_changes, {}