1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS/ObjectBrowser Added erase button and modified load and save buttons to act on only the currently selected object

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@581 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-05-04 02:12:50 +00:00 committed by vassilis
parent 7ca10bf5d7
commit 7edfaa5f26
6 changed files with 251 additions and 182 deletions

View File

@ -1,155 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UAVObjectBrowser</class>
<widget class="QWidget" name="UAVObjectBrowser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="requestButton">
<property name="toolTip">
<string>Request update</string>
</property>
<property name="text">
<string>Request</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sendButton">
<property name="toolTip">
<string>Send update</string>
</property>
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="saveSDButton">
<property name="toolTip">
<string>Save to SD Card</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="readSDButton">
<property name="toolTip">
<string>Load from SD Card</string>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="metaCheckBox">
<property name="toolTip">
<string>Show Meta Data</string>
</property>
<property name="text">
<string>Show Meta Data</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="treeView"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UAVObjectBrowser</class>
<widget class="QWidget" name="UAVObjectBrowser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>786</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="requestButton">
<property name="toolTip">
<string>Request update</string>
</property>
<property name="text">
<string>Request</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sendButton">
<property name="toolTip">
<string>Send update</string>
</property>
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="saveSDButton">
<property name="toolTip">
<string>Save to SD Card</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="readSDButton">
<property name="toolTip">
<string>Load from SD Card</string>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="eraseSDButton">
<property name="toolTip">
<string>Erase from SD card</string>
</property>
<property name="text">
<string>Erase</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="metaCheckBox">
<property name="toolTip">
<string>Show Meta Data</string>
</property>
<property name="text">
<string>Show Meta Data</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="treeView"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -54,8 +54,9 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
showMetaData(m_browser->metaCheckBox->isChecked());
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex)));
connect(m_browser->metaCheckBox, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool)));
connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveSettings()));
connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(readSettings()));
connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject()));
connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject()));
connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject()));
connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate()));
enableSendRequest(false);
@ -111,28 +112,53 @@ ObjectTreeItem *UAVObjectBrowserWidget::findCurrentObjectTreeItem()
return objItem;
}
void UAVObjectBrowserWidget::saveSettings()
void UAVObjectBrowserWidget::saveObject()
{
updateSettings(ObjectPersistence::OPERATION_SAVE);
// Send update so that the latest value is saved
sendUpdate();
// Save object
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
Q_ASSERT(objItem);
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj);
}
void UAVObjectBrowserWidget::readSettings()
void UAVObjectBrowserWidget::loadObject()
{
updateSettings(ObjectPersistence::OPERATION_LOAD);
// Load object
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
Q_ASSERT(objItem);
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_LOAD, obj);
// Retrieve object so that latest value is displayed
requestUpdate();
}
void UAVObjectBrowserWidget::updateSettings(ObjectPersistence::OperationOptions op)
void UAVObjectBrowserWidget::eraseObject()
{
ObjectTreeItem *objItem = findCurrentObjectTreeItem();
Q_ASSERT(objItem);
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_DELETE, obj);
}
void UAVObjectBrowserWidget::updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
ObjectPersistence* obj = dynamic_cast<ObjectPersistence*>( objManager->getObject(ObjectPersistence::NAME) );
ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>( objManager->getObject(ObjectPersistence::NAME) );
if (obj != NULL)
{
ObjectPersistence::DataFields data;
data.Operation = op;
data.Objects = ObjectPersistence::OBJECTS_ALL;
obj->setData(data);
obj->updated();
data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT;
data.ObjectID = obj->getObjID();
data.InstanceID = obj->getInstID();
objper->setData(data);
objper->updated();
}
}
@ -153,6 +179,9 @@ void UAVObjectBrowserWidget::enableSendRequest(bool enable)
{
m_browser->sendButton->setEnabled(enable);
m_browser->requestButton->setEnabled(enable);
m_browser->saveSDButton->setEnabled(enable);
m_browser->readSDButton->setEnabled(enable);
m_browser->eraseSDButton->setEnabled(enable);
}

View File

@ -55,8 +55,9 @@ public slots:
private slots:
void sendUpdate();
void requestUpdate();
void saveSettings();
void readSettings();
void saveObject();
void loadObject();
void eraseObject();
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
private:
@ -65,7 +66,7 @@ private:
Ui_UAVObjectBrowser *m_browser;
UAVObjectTreeModel *m_model;
void updateSettings(ObjectPersistence::OperationOptions op);
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
void enableSendRequest(bool enable);
ObjectTreeItem *findCurrentObjectTreeItem();
};

View File

@ -47,13 +47,20 @@ ObjectPersistence::ObjectPersistence(): UAVDataObject(OBJID, ISSINGLEINST, ISSET
OperationEnumOptions.append("Save");
OperationEnumOptions.append("Delete");
fields.append(new UAVObjectFieldEnum(QString("Operation"), QString(""), OperationElemNames, OperationEnumOptions));
QStringList ObjectsElemNames;
ObjectsElemNames.append("0");
QStringList ObjectsEnumOptions;
ObjectsEnumOptions.append("All");
ObjectsEnumOptions.append("Settings");
ObjectsEnumOptions.append("MetaObjects");
fields.append(new UAVObjectFieldEnum(QString("Objects"), QString(""), ObjectsElemNames, ObjectsEnumOptions));
QStringList SelectionElemNames;
SelectionElemNames.append("0");
QStringList SelectionEnumOptions;
SelectionEnumOptions.append("SingleObject");
SelectionEnumOptions.append("AllSettings");
SelectionEnumOptions.append("AllMetaObjects");
SelectionEnumOptions.append("AllObjects");
fields.append(new UAVObjectFieldEnum(QString("Selection"), QString(""), SelectionElemNames, SelectionEnumOptions));
QStringList ObjectIDElemNames;
ObjectIDElemNames.append("0");
fields.append(new UAVObjectFieldUInt32(QString("ObjectID"), QString(""), ObjectIDElemNames));
QStringList InstanceIDElemNames;
InstanceIDElemNames.append("0");
fields.append(new UAVObjectFieldUInt32(QString("InstanceID"), QString(""), InstanceIDElemNames));
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);

View File

@ -42,7 +42,9 @@ public:
// Field structure
typedef struct {
quint8 Operation;
quint8 Objects;
quint8 Selection;
quint32 ObjectID;
quint32 InstanceID;
} __attribute__((packed)) DataFields;
@ -50,13 +52,15 @@ public:
// Field Operation information
/* Enumeration options for field Operation */
typedef enum { OPERATION_LOAD=0, OPERATION_SAVE=1, OPERATION_DELETE=2, } OperationOptions;
// Field Objects information
/* Enumeration options for field Objects */
typedef enum { OBJECTS_ALL=0, OBJECTS_SETTINGS=1, OBJECTS_METAOBJECTS=2, } ObjectsOptions;
// Field Selection information
/* Enumeration options for field Selection */
typedef enum { SELECTION_SINGLEOBJECT=0, SELECTION_ALLSETTINGS=1, SELECTION_ALLMETAOBJECTS=2, SELECTION_ALLOBJECTS=3, } SelectionOptions;
// Field ObjectID information
// Field InstanceID information
// Constants
static const quint32 OBJID = 2407027612U;
static const quint32 OBJID = 572614706U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;

View File

@ -1,7 +1,9 @@
<xml>
<object name="ObjectPersistence" singleinstance="true" settings="false">
<field name="Operation" units="" type="enum" elements="1" options="Load,Save,Delete"/>
<field name="Objects" units="" type="enum" elements="1" options="All,Settings,MetaObjects"/>
<field name="Selection" units="" type="enum" elements="1" options="SingleObject,AllSettings,AllMetaObjects,AllObjects"/>
<field name="ObjectID" units="" type="uint32" elements="1"/>
<field name="InstanceID" units="" type="uint32" elements="1"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="manual" period="0"/>
<logging updatemode="never" period="0"/>