mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-137 Support field with multiple element for analog dial gadget.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1901 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ecf4e74a71
commit
5a6795b6cb
@ -106,13 +106,10 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
//select saved UAV Object field values
|
||||
if(options_page->uavObject1->findText(m_config->getN1DataObject())!=-1){
|
||||
options_page->uavObject1->setCurrentIndex(options_page->uavObject1->findText(m_config->getN1DataObject()));
|
||||
// Now load the object field values:
|
||||
// Now load the object field values - 1st check that the object saved in the config still exists
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(m_config->getN1DataObject()) );
|
||||
if (obj != NULL ) {
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->objectField1->addItem(field->getName());
|
||||
}
|
||||
on_uavObject1_currentIndexChanged(m_config->getN1DataObject());
|
||||
// And set the highlighed value from the settings:
|
||||
options_page->objectField1->setCurrentIndex(options_page->objectField1->findText(m_config->getN1ObjField()));
|
||||
}
|
||||
@ -124,10 +121,7 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
// Now load the object field values:
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(m_config->getN2DataObject()));
|
||||
if (obj != NULL ) {
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->objectField2->addItem(field->getName());
|
||||
}
|
||||
on_uavObject2_currentIndexChanged(m_config->getN2DataObject());
|
||||
options_page->objectField2->setCurrentIndex(options_page->objectField2->findText(m_config->getN2ObjField()));
|
||||
}
|
||||
}
|
||||
@ -138,10 +132,7 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
// Now load the object field values:
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(m_config->getN3DataObject()));
|
||||
if (obj != NULL ) {
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->objectField3->addItem(field->getName());
|
||||
}
|
||||
on_uavObject3_currentIndexChanged(m_config->getN3DataObject());
|
||||
options_page->objectField3->setCurrentIndex(options_page->objectField3->findText(m_config->getN3ObjField()));
|
||||
}
|
||||
}
|
||||
@ -210,6 +201,16 @@ void DialGadgetOptionsPage::on_uavObject1_currentIndexChanged(QString val) {
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
if(field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM )
|
||||
continue;
|
||||
if(field->getElementNames().count() > 1)
|
||||
{
|
||||
foreach(QString elemName , field->getElementNames())
|
||||
{
|
||||
options_page->objectField1->addItem(field->getName() + "-" + elemName);
|
||||
}
|
||||
}
|
||||
else
|
||||
options_page->objectField1->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
@ -225,6 +226,16 @@ void DialGadgetOptionsPage::on_uavObject2_currentIndexChanged(QString val) {
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
if(field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM )
|
||||
continue;
|
||||
if(field->getElementNames().count() > 1)
|
||||
{
|
||||
foreach(QString elemName , field->getElementNames())
|
||||
{
|
||||
options_page->objectField2->addItem(field->getName() + "-" + elemName);
|
||||
}
|
||||
}
|
||||
else
|
||||
options_page->objectField2->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
@ -240,6 +251,16 @@ void DialGadgetOptionsPage::on_uavObject3_currentIndexChanged(QString val) {
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
if(field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM )
|
||||
continue;
|
||||
if(field->getElementNames().count() > 1)
|
||||
{
|
||||
foreach(QString elemName , field->getElementNames())
|
||||
{
|
||||
options_page->objectField3->addItem(field->getName() + "-" + elemName);
|
||||
}
|
||||
}
|
||||
else
|
||||
options_page->objectField3->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,18 @@ void DialGadgetWidget::connectNeedles(QString object1, QString nfield1,
|
||||
if (obj1 != NULL ) {
|
||||
// qDebug() << "Connected Object 1 (" << object1 << ").";
|
||||
connect(obj1, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateNeedle1(UAVObject*)));
|
||||
if(nfield1.contains("-"))
|
||||
{
|
||||
QStringList fieldSubfield = nfield1.split("-", QString::SkipEmptyParts);
|
||||
field1 = fieldSubfield.at(0);
|
||||
subfield1 = fieldSubfield.at(1);
|
||||
haveSubField1 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
field1= nfield1;
|
||||
haveSubField1 = false;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Error: Object is unknown (" << object1 << ").";
|
||||
}
|
||||
@ -98,7 +109,18 @@ void DialGadgetWidget::connectNeedles(QString object1, QString nfield1,
|
||||
if (obj2 != NULL ) {
|
||||
// qDebug() << "Connected Object 2 (" << object2 << ").";
|
||||
connect(obj2, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateNeedle2(UAVObject*)));
|
||||
if(nfield2.contains("-"))
|
||||
{
|
||||
QStringList fieldSubfield = nfield2.split("-", QString::SkipEmptyParts);
|
||||
field2 = fieldSubfield.at(0);
|
||||
subfield2 = fieldSubfield.at(1);
|
||||
haveSubField2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
field2= nfield2;
|
||||
haveSubField2 = false;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Error: Object is unknown (" << object2 << ").";
|
||||
}
|
||||
@ -110,7 +132,18 @@ void DialGadgetWidget::connectNeedles(QString object1, QString nfield1,
|
||||
if (obj3 != NULL ) {
|
||||
// qDebug() << "Connected Object 3 (" << object3 << ").";
|
||||
connect(obj3, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateNeedle3(UAVObject*)));
|
||||
if(nfield3.contains("-"))
|
||||
{
|
||||
QStringList fieldSubfield = nfield3.split("-", QString::SkipEmptyParts);
|
||||
field3 = fieldSubfield.at(0);
|
||||
subfield3 = fieldSubfield.at(1);
|
||||
haveSubField3 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
field3= nfield3;
|
||||
haveSubField3 = false;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Error: Object is unknown (" << object3 << ").";
|
||||
}
|
||||
@ -122,9 +155,15 @@ void DialGadgetWidget::connectNeedles(QString object1, QString nfield1,
|
||||
*/
|
||||
void DialGadgetWidget::updateNeedle1(UAVObject *object1) {
|
||||
// Double check that the field exists:
|
||||
double value;
|
||||
UAVObjectField* field = object1->getField(field1);
|
||||
if (field) {
|
||||
setNeedle1(field->getDouble());
|
||||
if(haveSubField1){
|
||||
int indexOfSubField = field->getElementNames().indexOf(QRegExp(subfield1, Qt::CaseSensitive, QRegExp::FixedString));
|
||||
value = field->getDouble(indexOfSubField);
|
||||
}else
|
||||
value = field->getDouble();
|
||||
setNeedle1(value);
|
||||
} else {
|
||||
qDebug() << "Wrong field, maybe an issue with object disconnection ?";
|
||||
}
|
||||
@ -134,9 +173,15 @@ void DialGadgetWidget::updateNeedle1(UAVObject *object1) {
|
||||
\brief Called by the UAVObject which got updated
|
||||
*/
|
||||
void DialGadgetWidget::updateNeedle2(UAVObject *object2) {
|
||||
double value;
|
||||
UAVObjectField* field = object2->getField(field2);
|
||||
if (field) {
|
||||
setNeedle2(field->getDouble());
|
||||
if(haveSubField2){
|
||||
int indexOfSubField = field->getElementNames().indexOf(QRegExp(subfield2, Qt::CaseSensitive, QRegExp::FixedString));
|
||||
value = field->getDouble(indexOfSubField);
|
||||
}else
|
||||
value = field->getDouble();
|
||||
setNeedle2(value);
|
||||
} else {
|
||||
qDebug() << "Wrong field, maybe an issue with object disconnection ?";
|
||||
}
|
||||
@ -146,9 +191,15 @@ void DialGadgetWidget::updateNeedle2(UAVObject *object2) {
|
||||
\brief Called by the UAVObject which got updated
|
||||
*/
|
||||
void DialGadgetWidget::updateNeedle3(UAVObject *object3) {
|
||||
double value;
|
||||
UAVObjectField* field = object3->getField(field3);
|
||||
if (field) {
|
||||
setNeedle3(field->getDouble());
|
||||
if(haveSubField3){
|
||||
int indexOfSubField = field->getElementNames().indexOf(QRegExp(subfield3, Qt::CaseSensitive, QRegExp::FixedString));
|
||||
value = field->getDouble(indexOfSubField);
|
||||
}else
|
||||
value = field->getDouble();
|
||||
setNeedle3(value);
|
||||
} else {
|
||||
qDebug() << "Wrong field, maybe an issue with object disconnection ?";
|
||||
}
|
||||
|
@ -134,8 +134,14 @@ private:
|
||||
UAVDataObject* obj2;
|
||||
UAVDataObject* obj3;
|
||||
QString field1;
|
||||
QString subfield1;
|
||||
bool haveSubField1;
|
||||
QString field2;
|
||||
QString subfield2;
|
||||
bool haveSubField2;
|
||||
QString field3;
|
||||
QString subfield3;
|
||||
bool haveSubField3;
|
||||
|
||||
// Rotation timer
|
||||
QTimer dialTimer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user