mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-9 GCS/uavobjectbrowser: Small random changes.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@490 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
052791620e
commit
1e36b88811
@ -1,155 +1,155 @@
|
||||
<?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>476</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>Read from SD Card</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Read</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>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>
|
||||
|
@ -49,6 +49,7 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
BrowserItemDelegate *m_delegate = new BrowserItemDelegate();
|
||||
m_browser->treeView->setItemDelegate(m_delegate);
|
||||
m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
|
||||
m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
showMetaData(m_browser->metaCheckBox->isChecked());
|
||||
connect(m_browser->metaCheckBox, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool)));
|
||||
connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveSettings()));
|
||||
|
@ -38,7 +38,10 @@
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent) :
|
||||
QAbstractItemModel(parent)
|
||||
QAbstractItemModel(parent),
|
||||
m_recentlyUpdatedTimeout(500), // ms
|
||||
m_recentlyUpdatedColor(QColor(255, 230, 230)),
|
||||
m_manuallyChangedColor(QColor(230, 230, 255))
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
@ -56,12 +59,12 @@ void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager)
|
||||
// root
|
||||
QList<QVariant> rootData;
|
||||
rootData << tr("Property") << tr("Value") << tr("Unit");
|
||||
rootItem = new TreeItem(rootData);
|
||||
m_rootItem = new TreeItem(rootData);
|
||||
|
||||
m_settingsTree = new TopTreeItem(tr("Settings"), rootItem);
|
||||
rootItem->appendChild(m_settingsTree);
|
||||
m_nonSettingsTree = new TopTreeItem(tr("Data Objects"), rootItem);
|
||||
rootItem->appendChild(m_nonSettingsTree);
|
||||
m_settingsTree = new TopTreeItem(tr("Settings"), m_rootItem);
|
||||
m_rootItem->appendChild(m_settingsTree);
|
||||
m_nonSettingsTree = new TopTreeItem(tr("Data Objects"), m_rootItem);
|
||||
m_rootItem->appendChild(m_nonSettingsTree);
|
||||
|
||||
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
|
||||
foreach (QList<UAVDataObject*> list, objList) {
|
||||
@ -206,7 +209,7 @@ QModelIndex UAVObjectTreeModel::index(int row, int column, const QModelIndex &pa
|
||||
TreeItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
parentItem = m_rootItem;
|
||||
else
|
||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||
|
||||
@ -225,7 +228,7 @@ QModelIndex UAVObjectTreeModel::parent(const QModelIndex &index) const
|
||||
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
||||
TreeItem *parentItem = childItem->parent();
|
||||
|
||||
if (parentItem == rootItem)
|
||||
if (parentItem == m_rootItem)
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
@ -238,7 +241,7 @@ int UAVObjectTreeModel::rowCount(const QModelIndex &parent) const
|
||||
return 0;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = rootItem;
|
||||
parentItem = m_rootItem;
|
||||
else
|
||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||
|
||||
@ -250,7 +253,7 @@ int UAVObjectTreeModel::columnCount(const QModelIndex &parent) const
|
||||
if (parent.isValid())
|
||||
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
|
||||
else
|
||||
return rootItem->columnCount();
|
||||
return m_rootItem->columnCount();
|
||||
}
|
||||
|
||||
QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
|
||||
@ -268,14 +271,14 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
|
||||
if (index.column() == 0 && role == Qt::BackgroundRole) {
|
||||
DataObjectTreeItem *dataItem = dynamic_cast<DataObjectTreeItem*>(item);
|
||||
if (dataItem && dataItem->highlight())
|
||||
return QVariant(QColor(255, 230, 230));
|
||||
return QVariant(m_recentlyUpdatedColor);
|
||||
}
|
||||
if (index.column() == 1 && role == Qt::BackgroundRole) {
|
||||
FieldTreeItem *fieldItem = dynamic_cast<FieldTreeItem*>(item);
|
||||
if (fieldItem && fieldItem->highlight())
|
||||
return QVariant(QColor(255, 230, 230));
|
||||
return QVariant(m_recentlyUpdatedColor);
|
||||
if (fieldItem && fieldItem->isChanged())
|
||||
return QVariant(QColor(230, 230, 255));
|
||||
return QVariant(m_manuallyChangedColor);
|
||||
}
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
@ -318,7 +321,7 @@ QVariant UAVObjectTreeModel::headerData(int section, Qt::Orientation orientation
|
||||
int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||
return rootItem->data(section);
|
||||
return m_rootItem->data(section);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
@ -345,7 +348,7 @@ void UAVObjectTreeModel::highlightUpdatedObject(UAVObject *object)
|
||||
m_timerMap.insert(obj, timer);
|
||||
connect(timer, SIGNAL(timeout()), m_signalMapper, SLOT(map()));
|
||||
m_signalMapper->setMapping(timer, obj);
|
||||
timer->start(500);
|
||||
timer->start(m_recentlyUpdatedTimeout);
|
||||
}
|
||||
|
||||
void UAVObjectTreeModel::resetHighlightObject(QObject *object)
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
class TreeItem;
|
||||
class TopTreeItem;
|
||||
@ -81,12 +82,14 @@ private:
|
||||
void setupModelData(UAVObjectManager *objManager);
|
||||
DataObjectTreeItem *findDataObjectTreeItem(UAVDataObject *obj);
|
||||
|
||||
TreeItem *rootItem;
|
||||
TreeItem *m_rootItem;
|
||||
TopTreeItem *m_settingsTree;
|
||||
TopTreeItem *m_nonSettingsTree;
|
||||
QSignalMapper *m_signalMapper;
|
||||
QMap<UAVObject*,QTimer*> m_timerMap;
|
||||
|
||||
int m_recentlyUpdatedTimeout;
|
||||
QColor m_recentlyUpdatedColor;
|
||||
QColor m_manuallyChangedColor;
|
||||
};
|
||||
|
||||
#endif // UAVOBJECTTREEMODEL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user