Commit cea599b9 authored by Jacob Walser's avatar Jacob Walser

Add manual entry option for enumerated and bitmask parameters

parent 6b10539a
...@@ -34,18 +34,11 @@ QGCViewDialog { ...@@ -34,18 +34,11 @@ QGCViewDialog {
QGCPalette { id: qgcPal; colorGroupEnabled: true } QGCPalette { id: qgcPal; colorGroupEnabled: true }
function accept() { function accept() {
if (bitmaskColumn.visible) { if (bitmaskColumn.visible && !manualEntry.checked) {
var value = 0; fact.value = bitmaskValue();
for (var i = 0; i < fact.bitmaskValues.length; ++i) {
var checkbox = bitmaskRepeater.itemAt(i)
if (checkbox.checked) {
value |= fact.bitmaskValues[i];
}
}
fact.value = value;
fact.valueChanged(fact.value) fact.valueChanged(fact.value)
hideDialog(); hideDialog();
} else if (factCombo.visible) { } else if (factCombo.visible && !manualEntry.checked) {
fact.enumIndex = factCombo.currentIndex fact.enumIndex = factCombo.currentIndex
hideDialog() hideDialog()
} else { } else {
...@@ -61,6 +54,17 @@ QGCViewDialog { ...@@ -61,6 +54,17 @@ QGCViewDialog {
} }
} }
function bitmaskValue() {
var value = 0;
for (var i = 0; i < fact.bitmaskValues.length; ++i) {
var checkbox = bitmaskRepeater.itemAt(i)
if (checkbox.checked) {
value |= fact.bitmaskValues[i];
}
}
return value
}
Component.onCompleted: { Component.onCompleted: {
if (validate) { if (validate) {
validationError.text = fact.validate(validateValue, false /* convertOnly */) validationError.text = fact.validate(validateValue, false /* convertOnly */)
...@@ -79,6 +83,17 @@ QGCViewDialog { ...@@ -79,6 +83,17 @@ QGCViewDialog {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
// Checkbox to allow manual entry of enumerated or bitmask parameters
QGCCheckBox {
id: manualEntry
visible: factCombo.visible || bitmaskColumn.visible
text: qsTr("Manual Entry (Advanced User)")
onClicked: {
valueField.text = fact.valueString
}
}
QGCLabel { QGCLabel {
id: validationError id: validationError
width: parent.width width: parent.width
...@@ -94,7 +109,7 @@ QGCViewDialog { ...@@ -94,7 +109,7 @@ QGCViewDialog {
QGCTextField { QGCTextField {
id: valueField id: valueField
text: validate ? validateValue : fact.valueString text: validate ? validateValue : fact.valueString
visible: fact.enumStrings.length == 0 || validate visible: fact.enumStrings.length == 0 || validate || manualEntry.checked
unitsLabel: fact.units unitsLabel: fact.units
showUnits: fact.units != "" showUnits: fact.units != ""
Layout.fillWidth: true Layout.fillWidth: true
...@@ -132,6 +147,10 @@ QGCViewDialog { ...@@ -132,6 +147,10 @@ QGCViewDialog {
currentIndex = fact.enumIndex currentIndex = fact.enumIndex
} }
} }
onCurrentIndexChanged: {
valueField.text = fact.enumValues[currentIndex]
}
} }
Column { Column {
...@@ -146,6 +165,10 @@ QGCViewDialog { ...@@ -146,6 +165,10 @@ QGCViewDialog {
delegate : QGCCheckBox { delegate : QGCCheckBox {
text : modelData text : modelData
checked : fact.value & fact.bitmaskValues[index] checked : fact.value & fact.bitmaskValues[index]
onClicked: {
valueField.text = bitmaskValue()
}
} }
} }
} }
......
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