Commit 62e45635 authored by Don Gagne's avatar Don Gagne

Show enumStringValue if available

parent 140c572f
...@@ -35,6 +35,8 @@ import QGroundControl.FactControls 1.0 ...@@ -35,6 +35,8 @@ import QGroundControl.FactControls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
QGCViewDialog { QGCViewDialog {
id: root
property Fact fact property Fact fact
property bool validate: false property bool validate: false
property string validateValue property string validateValue
...@@ -42,14 +44,19 @@ QGCViewDialog { ...@@ -42,14 +44,19 @@ QGCViewDialog {
ParameterEditorController { id: controller; factPanel: parent } ParameterEditorController { id: controller; factPanel: parent }
function accept() { function accept() {
var errorString = fact.validate(valueField.text, forceSave.checked) if (factCombo.visible) {
if (errorString == "") { fact.enumIndex = factCombo.currentIndex
fact.value = valueField.text
fact.valueChanged(fact.value)
hideDialog() hideDialog()
} else { } else {
validationError.text = errorString var errorString = fact.validate(valueField.text, forceSave.checked)
forceSave.visible = true if (errorString == "") {
fact.value = valueField.text
fact.valueChanged(fact.value)
hideDialog()
} else {
validationError.text = errorString
forceSave.visible = true
}
} }
} }
...@@ -80,14 +87,30 @@ QGCViewDialog { ...@@ -80,14 +87,30 @@ QGCViewDialog {
} }
QGCTextField { QGCTextField {
id: valueField id: valueField
text: validate ? validateValue : fact.valueString text: validate ? validateValue : fact.valueString
visible: fact.enumStrings.length == 0 || validate
//focus: true //focus: true
// At this point all Facts are numeric // At this point all Facts are numeric
inputMethodHints: Qt.ImhFormattedNumbersOnly inputMethodHints: Qt.ImhFormattedNumbersOnly
} }
QGCComboBox {
id: factCombo
width: valueField.width
visible: fact.enumStrings.length != 0 && !validate
model: fact.enumStrings
Component.onCompleted: {
// We can't bind directly to fact.enumIndex since that would add an unknown value
// if there are no enum strings.
if (visible) {
currentIndex = fact.enumIndex
}
}
}
QGCLabel { text: fact.name } QGCLabel { text: fact.name }
Row { Row {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment