mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
CURA-4400 added function to find model index by extruder position in SettingExtruder
This commit is contained in:
parent
d70cc072e9
commit
552618fcd4
2 changed files with 16 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 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 Qt, pyqtSignal, pyqtProperty, QTimer
|
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot, pyqtProperty, QTimer
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
|
|
@ -26,6 +26,20 @@ SettingItem
|
||||||
|
|
||||||
textRole: "name"
|
textRole: "name"
|
||||||
|
|
||||||
|
// knowing the extruder position, try to find the item index in the model
|
||||||
|
function getIndexByPosition(position)
|
||||||
|
{
|
||||||
|
for (var item_index in model.items)
|
||||||
|
{
|
||||||
|
var item = model.getItem(item_index)
|
||||||
|
if (item.index == position)
|
||||||
|
{
|
||||||
|
return item_index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
onActivated:
|
onActivated:
|
||||||
{
|
{
|
||||||
if (model.getItem(index).enabled)
|
if (model.getItem(index).enabled)
|
||||||
|
@ -83,8 +97,7 @@ SettingItem
|
||||||
{
|
{
|
||||||
if(propertyProvider.properties.value == -1)
|
if(propertyProvider.properties.value == -1)
|
||||||
{
|
{
|
||||||
// TODO: accidently the extruder position is also the index. fix it
|
return control.getIndexByPosition(Cura.MachineManager.defaultExtruderPosition);
|
||||||
return Cura.MachineManager.defaultExtruderPosition;
|
|
||||||
}
|
}
|
||||||
return propertyProvider.properties.value
|
return propertyProvider.properties.value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue