1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

GCS/uavobjects: Fix uavobjectfieldenum array support.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@445 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
ephy 2010-04-09 07:58:09 +00:00 committed by ephy
parent 0668c7e01f
commit 4f37d95aca
2 changed files with 12 additions and 12 deletions

View File

@ -41,32 +41,32 @@ QStringList UAVObjectFieldEnum::getOptions()
return options;
}
QString UAVObjectFieldEnum::getSelected()
QString UAVObjectFieldEnum::getSelected(quint32 arrayIndex)
{
return options[getValue()];
return options[getValue(arrayIndex)];
}
void UAVObjectFieldEnum::setSelected(QString& val)
void UAVObjectFieldEnum::setSelected(QString& val, quint32 arrayIndex)
{
// Find index of selected value
int index = options.indexOf(val);
if (index >= 0)
{
setValue(index);
setValue(index, arrayIndex);
}
}
quint8 UAVObjectFieldEnum::getSelectedIndex()
quint8 UAVObjectFieldEnum::getSelectedIndex(quint32 arrayIndex)
{
return getValue();
return getValue(arrayIndex);
}
void UAVObjectFieldEnum::setSelectedIndex(quint8 index)
void UAVObjectFieldEnum::setSelectedIndex(quint8 index, quint32 arrayIndex)
{
// Check that the index is valid
if (index < options.length())
{
setValue(index);
setValue(index, arrayIndex);
}
}

View File

@ -42,10 +42,10 @@ class UAVOBJECTS_EXPORT UAVObjectFieldEnum: public UAVObjectField
public:
UAVObjectFieldEnum(const QString& name, const QString& units, quint32 numElements, QStringList& options);
QStringList getOptions();
QString getSelected();
void setSelected(QString& val);
quint8 getSelectedIndex();
void setSelectedIndex(quint8 index);
QString getSelected(quint32 arrayIndex);
void setSelected(QString& val, quint32 arrayIndex);
quint8 getSelectedIndex(quint32 arrayIndex);
void setSelectedIndex(quint8 index, quint32 arrayIndex);
void initializeValues();
qint32 pack(quint8* dataOut);
qint32 unpack(const quint8* dataIn);