Commit 7f920895 authored by Tomaz Canabrava's avatar Tomaz Canabrava

Parameter Edit: Handle bitfields as ComboBoxes

This makes it possible to select more than one value
to be used in the parameter configuration, and since
the parameter is actually a bitfield - this is the
correct thing to do.

one of the drawbacks is that in the parameter listing
the value of the Fact will not be displayed as string
anymore, but with 'undefined: numerical-value', that is
the OR combination of the applied values.
Signed-off-by: 's avatarTomaz Canabrava <tomaz.canabrava@intel.com>
parent 50ab2ed9
...@@ -47,7 +47,18 @@ QGCViewDialog { ...@@ -47,7 +47,18 @@ QGCViewDialog {
QGCPalette { id: qgcPal; colorGroupEnabled: true } QGCPalette { id: qgcPal; colorGroupEnabled: true }
function accept() { function accept() {
if (factCombo.visible) { if (bitmaskEditor.visible) {
var value = 0;
for (var i = 0; i < fact.bitmaskValues.length; ++i) {
var checkbox = bitmaskEditor.itemAt(i)
if (checkbox.checked) {
value |= fact.bitmaskValues[i];
}
}
fact.value = value;
fact.valueChanged(fact.value)
}
else if (factCombo.visible) {
fact.enumIndex = factCombo.currentIndex fact.enumIndex = factCombo.currentIndex
hideDialog() hideDialog()
} else { } else {
...@@ -127,7 +138,7 @@ QGCViewDialog { ...@@ -127,7 +138,7 @@ QGCViewDialog {
visible: _showCombo visible: _showCombo
model: fact.enumStrings model: fact.enumStrings
property bool _showCombo: fact.enumStrings.length != 0 && !validate property bool _showCombo: fact.enumStrings.length != 0 && fact.bitmaskStrings.length == 0 && !validate
Component.onCompleted: { Component.onCompleted: {
// We can't bind directly to fact.enumIndex since that would add an unknown value // We can't bind directly to fact.enumIndex since that would add an unknown value
...@@ -138,6 +149,17 @@ QGCViewDialog { ...@@ -138,6 +149,17 @@ QGCViewDialog {
} }
} }
Column {
Repeater {
id: bitmaskEditor
model: fact.bitmaskStrings
delegate : QGCCheckBox {
text : modelData
checked : fact.value & fact.bitmaskValues[index]
}
}
}
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