5import QGroundControl.Controls
8 property Fact fact: Fact { }
9 property bool indexModel: fact ? fact.enumValues.length === 0 : true // true: Fact values are indices, false: Fact values are FactMetadata.enumValues
11 model: fact ? fact.enumStrings : null
13 currentIndex: fact ? (indexModel ? fact.value : fact.enumIndex) : 0
15 function _updateCurrentIndex() {
16 Qt.callLater(function() {
17 currentIndex = Qt.binding(function() {
18 return fact ? (indexModel ? fact.value : fact.enumIndex) : 0
24 // When the model changes, the index gets reset to 0, so re-establish
25 // the declarative currentIndex binding. callLater() avoids a binding
26 // loop since enumIndex could trigger a model change.
31 // When the fact changes to a different Fact object with the same
32 // enumStrings, modelChanged does not fire, so the binding must be
33 // re-established here to point at the new Fact.
37 onActivated: (index) => {
41 fact.value = fact.enumValues[index]