1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-26 15:54:15 +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; 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 // Find index of selected value
int index = options.indexOf(val); int index = options.indexOf(val);
if (index >= 0) 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 // Check that the index is valid
if (index < options.length()) if (index < options.length())
{ {
setValue(index); setValue(index, arrayIndex);
} }
} }

View File

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