mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 22:13:58 -06:00
Moved SettingVisibilityPreset loading to it's own class
Since there was so much debate regarding the unit testing of the visiblity presets, i had another look at it. The old version was almost untestable because all functionalities were mushed together into a single class. CURA-5734
This commit is contained in:
parent
3e7021d729
commit
fc9f05fc8b
5 changed files with 154 additions and 90 deletions
|
@ -110,24 +110,23 @@ UM.PreferencesPage
|
|||
right: parent.right
|
||||
}
|
||||
|
||||
model: settingVisibilityPresetsModel
|
||||
model: settingVisibilityPresetsModel.items
|
||||
textRole: "name"
|
||||
|
||||
currentIndex:
|
||||
{
|
||||
// Load previously selected preset.
|
||||
var index = settingVisibilityPresetsModel.find("id", settingVisibilityPresetsModel.activePreset)
|
||||
if (index == -1)
|
||||
{
|
||||
return 0
|
||||
for(var i = 0; i < settingVisibilityPresetsModel.items.length; ++i) {
|
||||
if(settingVisibilityPresetsModel.items[i].id == settingVisibilityPresetsModel.activePreset) {
|
||||
currentIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return index
|
||||
return -1
|
||||
}
|
||||
|
||||
onActivated:
|
||||
{
|
||||
var preset_id = settingVisibilityPresetsModel.getItem(index).id;
|
||||
var preset_id = settingVisibilityPresetsModel.items[index].id;
|
||||
settingVisibilityPresetsModel.setActivePreset(preset_id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue