mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-137 Bargraph dials now also support multivalued fields.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1904 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
e32ddd5230
commit
f9c41caaf3
@ -86,10 +86,7 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
// Now load the object field values:
|
// Now load the object field values:
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(m_config->getSourceDataObject()) );
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(m_config->getSourceDataObject()) );
|
||||||
if (obj != NULL ) {
|
if (obj != NULL ) {
|
||||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
on_objectName_currentIndexChanged(m_config->getSourceDataObject());
|
||||||
foreach (UAVObjectField* field, fieldList) {
|
|
||||||
options_page->objectField->addItem(field->getName());
|
|
||||||
}
|
|
||||||
// And set the highlighed value from the settings:
|
// And set the highlighed value from the settings:
|
||||||
options_page->objectField->setCurrentIndex(options_page->objectField->findText(m_config->getSourceObjectField()));
|
options_page->objectField->setCurrentIndex(options_page->objectField->findText(m_config->getSourceObjectField()));
|
||||||
}
|
}
|
||||||
@ -143,7 +140,15 @@ void LineardialGadgetOptionsPage::on_objectName_currentIndexChanged(QString val)
|
|||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
||||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||||
foreach (UAVObjectField* field, fieldList) {
|
foreach (UAVObjectField* field, fieldList) {
|
||||||
options_page->objectField->addItem(field->getName());
|
if(field->getElementNames().count() > 1)
|
||||||
|
{
|
||||||
|
foreach(QString elemName , field->getElementNames())
|
||||||
|
{
|
||||||
|
options_page->objectField->addItem(field->getName() + "-" + elemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
options_page->objectField->addItem(field->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,18 @@ void LineardialGadgetWidget::connectInput(QString object1, QString nfield1) {
|
|||||||
obj1 = dynamic_cast<UAVDataObject*>( objManager->getObject(object1) );
|
obj1 = dynamic_cast<UAVDataObject*>( objManager->getObject(object1) );
|
||||||
if (obj1 != NULL ) {
|
if (obj1 != NULL ) {
|
||||||
connect(obj1, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateIndex(UAVObject*)));
|
connect(obj1, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateIndex(UAVObject*)));
|
||||||
field1 = nfield1;
|
if(nfield1.contains("-"))
|
||||||
|
{
|
||||||
|
QStringList fieldSubfield = nfield1.split("-", QString::SkipEmptyParts);
|
||||||
|
field1 = fieldSubfield.at(0);
|
||||||
|
subfield1 = fieldSubfield.at(1);
|
||||||
|
haveSubField1 = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
field1= nfield1;
|
||||||
|
haveSubField1 = false;
|
||||||
|
}
|
||||||
if (fieldName)
|
if (fieldName)
|
||||||
fieldName->setPlainText(nfield1);
|
fieldName->setPlainText(nfield1);
|
||||||
updateIndex(obj1);
|
updateIndex(obj1);
|
||||||
@ -99,7 +110,12 @@ void LineardialGadgetWidget::updateIndex(UAVObject *object1) {
|
|||||||
if (field) {
|
if (field) {
|
||||||
QString s;
|
QString s;
|
||||||
if (field->isNumeric()) {
|
if (field->isNumeric()) {
|
||||||
double v = field->getDouble()*factor;
|
double v;
|
||||||
|
if(haveSubField1){
|
||||||
|
int indexOfSubField = field->getElementNames().indexOf(QRegExp(subfield1, Qt::CaseSensitive, QRegExp::FixedString));
|
||||||
|
v = field->getDouble(indexOfSubField)*factor;
|
||||||
|
}else
|
||||||
|
v = field->getDouble()*factor;
|
||||||
setIndex(v);
|
setIndex(v);
|
||||||
s.sprintf("%.*f",places,v);
|
s.sprintf("%.*f",places,v);
|
||||||
}
|
}
|
||||||
@ -115,6 +131,7 @@ void LineardialGadgetWidget::updateIndex(UAVObject *object1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldValue)
|
if (fieldValue)
|
||||||
fieldValue->setPlainText(s);
|
fieldValue->setPlainText(s);
|
||||||
|
|
||||||
|
@ -116,6 +116,8 @@ private:
|
|||||||
// Name of the fields to read when an update is received:
|
// Name of the fields to read when an update is received:
|
||||||
UAVDataObject* obj1;
|
UAVDataObject* obj1;
|
||||||
QString field1;
|
QString field1;
|
||||||
|
QString subfield1;
|
||||||
|
bool haveSubField1;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif /* LINEARDIALGADGETWIDGET_H_ */
|
#endif /* LINEARDIALGADGETWIDGET_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user