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

LP-567 simplify highlight management

it is now the HighlightManager that will emit the highlight related signals
TreeItem don't need to be QObjects anymore

also fix crashes after changing display options and rebuilding the tree model
This commit is contained in:
Philippe Renon 2018-03-22 09:03:14 +01:00
parent 3f7dcab185
commit a02bea9aed
10 changed files with 382 additions and 331 deletions

View File

@ -29,12 +29,14 @@
#define FIELDTREEITEM_H
#include "treeitem.h"
#include <QtCore/QStringList>
#include <QStringList>
#include <QWidget>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <qscispinbox/QScienceSpinBox.h>
#include <QComboBox>
#include <limits>
#define QINT8MIN std::numeric_limits<qint8>::min()
@ -49,15 +51,13 @@
#define QUINT32MAX std::numeric_limits<qint32>::max()
class FieldTreeItem : public TreeItem {
Q_OBJECT
public:
FieldTreeItem(int index, const QList<QVariant> &data, UAVObjectField *field, TreeItem *parent = 0) :
TreeItem(data, parent), m_index(index), m_field(field)
FieldTreeItem(int index, const QList<QVariant> &data, UAVObjectField *field, TreeItem *parentItem) :
TreeItem(data, parentItem), m_index(index), m_field(field)
{}
FieldTreeItem(int index, const QVariant &data, UAVObjectField *field, TreeItem *parent = 0) :
TreeItem(data, parent), m_index(index), m_field(field)
FieldTreeItem(int index, const QVariant &data, UAVObjectField *field, TreeItem *parentItem) :
TreeItem(data, parentItem), m_index(index), m_field(field)
{}
bool isEditable() const
@ -68,10 +68,6 @@ public:
virtual QWidget *createEditor(QWidget *parent) const = 0;
virtual QVariant getEditorValue(QWidget *editor) const = 0;
virtual void setEditorValue(QWidget *editor, QVariant value) const = 0;
virtual bool isKnown() const
{
return parent()->isKnown();
}
void setData(QVariant value, int column)
{
@ -93,7 +89,7 @@ public:
}
}
if (changed() || updated) {
setHighlight(true);
setHighlighted(true);
}
}
@ -112,14 +108,13 @@ protected:
};
class EnumFieldTreeItem : public FieldTreeItem {
Q_OBJECT
public:
EnumFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent), m_enumOptions(field->getOptions())
EnumFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem), m_enumOptions(field->getOptions())
{}
EnumFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent), m_enumOptions(field->getOptions())
EnumFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem), m_enumOptions(field->getOptions())
{}
QString enumOptions(int index)
@ -178,16 +173,14 @@ private:
};
class IntFieldTreeItem : public FieldTreeItem {
Q_OBJECT
public:
IntFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent)
IntFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem)
{
setMinMaxValues();
}
IntFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent)
IntFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem)
{
setMinMaxValues();
}
@ -265,13 +258,12 @@ private:
};
class FloatFieldTreeItem : public FieldTreeItem {
Q_OBJECT
public:
FloatFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, bool scientific = false, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent), m_useScientificNotation(scientific) {}
FloatFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, bool scientific, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem), m_useScientificNotation(scientific) {}
FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, bool scientific = false, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent), m_useScientificNotation(scientific) {}
FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, bool scientific, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem), m_useScientificNotation(scientific) {}
QVariant fieldToData() const
{
@ -329,14 +321,13 @@ private:
};
class HexFieldTreeItem : public FieldTreeItem {
Q_OBJECT
public:
HexFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent)
HexFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem)
{}
HexFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent)
HexFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem)
{}
QVariant fieldToData() const
@ -390,14 +381,13 @@ private:
};
class CharFieldTreeItem : public FieldTreeItem {
Q_OBJECT
public:
CharFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent)
CharFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem)
{}
CharFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
FieldTreeItem(index, data, field, parent)
CharFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parentItem) :
FieldTreeItem(index, data, field, parentItem)
{}
QVariant fieldToData() const

View File

@ -27,20 +27,22 @@
#include "treeitem.h"
#include <QDebug>
/* Constructor */
HighLightManager::HighLightManager()
HighlightManager::HighlightManager()
{
// Initialize the timer and connect it to the callback
m_expirationTimer.setTimerType(Qt::PreciseTimer);
m_expirationTimer.setSingleShot(true);
connect(&m_expirationTimer, &QTimer::timeout, this, &HighLightManager::checkItemsExpired);
connect(&m_expirationTimer, &QTimer::timeout, this, &HighlightManager::checkItemsExpired);
}
/*
* Called to add item to list. Item is only added if absent.
* Returns true if item was added, otherwise false.
*/
bool HighLightManager::add(TreeItem *itemToAdd)
bool HighlightManager::add(TreeItem *itemToAdd)
{
// Lock to ensure thread safety
QMutexLocker locker(&m_mutex);
@ -48,12 +50,31 @@ bool HighLightManager::add(TreeItem *itemToAdd)
// Check so that the item isn't already in the list
if (!m_items.contains(itemToAdd)) {
m_items.insert(itemToAdd);
emit updateHighlight(itemToAdd);
return true;
}
return false;
}
bool HighLightManager::startTimer(QTime expirationTime)
/*
* Called to remove item from list.
* Returns true if item was removed, otherwise false.
*/
bool HighlightManager::remove(TreeItem *itemToRemove)
{
// Lock to ensure thread safety
QMutexLocker locker(&m_mutex);
// Remove item and return result
const bool removed = m_items.remove(itemToRemove);
if (removed) {
emit updateHighlight(itemToRemove);
}
return removed;
}
bool HighlightManager::startTimer(QTime expirationTime)
{
// Lock to ensure thread safety
QMutexLocker locker(&m_mutex);
@ -67,17 +88,15 @@ bool HighLightManager::startTimer(QTime expirationTime)
return false;
}
/*
* Called to remove item from list.
* Returns true if item was removed, otherwise false.
*/
bool HighLightManager::remove(TreeItem *itemToRemove)
void HighlightManager::reset()
{
// Lock to ensure thread safety
QMutexLocker locker(&m_mutex);
// Remove item and return result
return m_items.remove(itemToRemove);
m_expirationTimer.stop();
m_items.clear();
}
/*
@ -86,7 +105,7 @@ bool HighLightManager::remove(TreeItem *itemToRemove)
* removes them if they are expired.
* Expired highlights are restored.
*/
void HighLightManager::checkItemsExpired()
void HighlightManager::checkItemsExpired()
{
// Lock to ensure thread safety
QMutexLocker locker(&m_mutex);
@ -101,16 +120,18 @@ void HighLightManager::checkItemsExpired()
// Loop over all items, check if they expired.
while (iter.hasNext()) {
TreeItem *item = iter.next();
if (item->getHiglightExpires() <= now) {
if (item->getHighlightExpires() <= now) {
// expired, call removeHighlight
item->removeHighlight();
item->resetHighlight();
// Remove from list since it is restored.
iter.remove();
emit updateHighlight(item);
} else {
// not expired, check if next to expire
if (!next.isValid() || (next > item->getHiglightExpires())) {
next = item->getHiglightExpires();
if (!next.isValid() || (next > item->getHighlightExpires())) {
next = item->getHighlightExpires();
}
}
}
@ -123,58 +144,54 @@ void HighLightManager::checkItemsExpired()
int TreeItem::m_highlightTimeMs = 300;
TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent) :
QObject(0),
m_data(data),
m_parent(parent),
m_highlight(false),
TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parentItem) :
m_itemData(data),
m_parentItem(parentItem),
m_changed(false),
m_highlighted(false),
m_highlightManager(0)
{}
TreeItem::TreeItem(const QVariant &data, TreeItem *parent) :
QObject(0),
m_parent(parent),
m_highlight(false),
TreeItem::TreeItem(const QVariant &data, TreeItem *parentItem) :
m_parentItem(parentItem),
m_changed(false),
m_highlighted(false),
m_highlightManager(0)
{
m_data << data << "" << "";
m_itemData << data << "" << "";
}
TreeItem::~TreeItem()
{
qDeleteAll(m_children);
qDeleteAll(m_childItems);
}
void TreeItem::appendChild(TreeItem *child)
{
m_children.append(child);
child->setParentTree(this);
m_childItems.append(child);
}
void TreeItem::insertChild(TreeItem *child)
{
int index = nameIndex(child->data(0).toString());
m_children.insert(index, child);
child->setParentTree(this);
m_childItems.insert(index, child);
}
TreeItem *TreeItem::getChild(int index) const
TreeItem *TreeItem::child(int index) const
{
return m_children.value(index);
return m_childItems.value(index);
}
int TreeItem::childCount() const
{
return m_children.count();
return m_childItems.count();
}
int TreeItem::row() const
{
if (m_parent) {
return m_parent->m_children.indexOf(const_cast<TreeItem *>(this));
if (m_parentItem) {
return m_parentItem->m_childItems.indexOf(const_cast<TreeItem *>(this));
}
return 0;
@ -182,84 +199,77 @@ int TreeItem::row() const
int TreeItem::columnCount() const
{
return m_data.count();
return m_itemData.count();
}
QVariant TreeItem::data(int column) const
{
return m_data.value(column);
return m_itemData.value(column);
}
void TreeItem::setData(QVariant value, int column)
{
m_data.replace(column, value);
m_itemData.replace(column, value);
}
void TreeItem::update()
{
foreach(TreeItem * child, treeChildren())
child->update();
foreach(TreeItem * child, children()) {
child->update();
}
}
void TreeItem::apply()
{
foreach(TreeItem * child, treeChildren())
child->apply();
foreach(TreeItem * child, children()) {
child->apply();
}
}
/*
* Called after a value has changed to trigger highlighting of tree item.
*/
void TreeItem::setHighlight(bool highlight)
void TreeItem::setHighlighted(bool highlighted)
{
m_changed = false;
if (m_highlight != highlight) {
m_highlight = highlight;
if (highlight) {
if (m_highlighted != highlighted) {
m_highlighted = highlighted;
if (highlighted) {
// Add to highlight manager
if (m_highlightManager->add(this)) {
// Only emit signal if it was added
emit updateHighlight(this);
}
m_highlightManager->add(this);
// Update expiration timeout
m_highlightExpires = QTime::currentTime().addMSecs(m_highlightTimeMs);
// start expiration timer if necessary
m_highlightManager->startTimer(m_highlightExpires);
} else if (m_highlightManager->remove(this)) {
// Only emit signal if it was removed
emit updateHighlight(this);
} else {
m_highlightManager->remove(this);
}
}
// If we have a parent, call recursively to update highlight status of parents.
// This will ensure that the root of a leaf that is changed also is highlighted.
// Only updates that really changes values will trigger highlight of parents.
if (m_parent) {
m_parent->setHighlight(highlight);
if (m_parentItem) {
// FIXME: need to pass m_highlightExpires
m_parentItem->setHighlighted(highlighted);
}
}
void TreeItem::removeHighlight()
void TreeItem::resetHighlight()
{
m_highlight = false;
emit updateHighlight(this);
m_highlighted = false;
}
void TreeItem::setHighlightManager(HighLightManager *mgr)
void TreeItem::setHighlightManager(HighlightManager *mgr)
{
m_highlightManager = mgr;
}
QTime TreeItem::getHiglightExpires() const
QTime TreeItem::getHighlightExpires() const
{
return m_highlightExpires;
}
QList<MetaObjectTreeItem *> TopTreeItem::getMetaObjectItems()
{
return m_metaObjectTreeItemsPerObjectIds.values();
}
QVariant ArrayFieldTreeItem::data(int column) const
{
if (column == 1) {

View File

@ -31,14 +31,13 @@
#include "uavobject.h"
#include "uavmetaobject.h"
#include "uavobjectfield.h"
#include <QtCore/QList>
#include <QtCore/QLinkedList>
#include <QtCore/QMap>
#include <QtCore/QVariant>
#include <QtCore/QTime>
#include <QtCore/QTimer>
#include <QtCore/QObject>
#include <QtCore/QDebug>
#include <QList>
#include <QMap>
#include <QVariant>
#include <QTime>
#include <QTimer>
#include <QObject>
class TreeItem;
@ -57,10 +56,10 @@ class TreeItem;
* left untouched in the list. This reduces unwanted emits
* of signals to the repaint/update function.
*/
class HighLightManager : public QObject {
class HighlightManager : public QObject {
Q_OBJECT
public:
HighLightManager();
HighlightManager();
// This is called when an item has been set to
// highlighted = true.
@ -71,6 +70,11 @@ public:
bool startTimer(QTime time);
void reset();
signals:
void updateHighlight(TreeItem *item);
private slots:
// Timer callback method.
void checkItemsExpired();
@ -86,23 +90,22 @@ private:
QMutex m_mutex;
};
class TreeItem : public QObject {
Q_OBJECT
class TreeItem {
public:
static const int TITLE_COLUMN = 0;
static const int DATA_COLUMN = 1;
static const int DATA_COLUMN = 1;
TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
TreeItem(const QVariant &data, TreeItem *parent = 0);
TreeItem(const QList<QVariant> &data, TreeItem *parentItem = 0);
TreeItem(const QVariant &data, TreeItem *parentItem = 0);
virtual ~TreeItem();
void appendChild(TreeItem *child);
void insertChild(TreeItem *child);
TreeItem *getChild(int index) const;
inline QList<TreeItem *> treeChildren() const
TreeItem *child(int index) const;
QList<TreeItem *> children() const
{
return m_children;
return m_childItems;
}
int childCount() const;
int columnCount() const;
@ -124,50 +127,57 @@ public:
// other columns are initialized in constructor
virtual void setData(QVariant value, int column = 1);
int row() const;
TreeItem *parent() const
TreeItem *parentItem() const
{
return m_parent;
return m_parentItem;
}
void setParentTree(TreeItem *parent)
{
m_parent = parent;
}
inline virtual bool isEditable() const
virtual bool isEditable() const
{
return false;
}
virtual void update();
virtual void apply();
inline bool highlighted() const
bool changed() const
{
return m_highlight;
return m_changed;
}
void setHighlight(bool highlight);
void setChanged(bool changed)
{
m_changed = changed;
}
bool isHighlighted() const
{
return m_highlighted;
}
void setHighlighted(bool highlighted);
static void setHighlightTime(int time)
{
m_highlightTimeMs = time;
}
inline bool changed() const
QTime getHighlightExpires() const;
void resetHighlight();
void setHighlightManager(HighlightManager *mgr);
virtual bool isKnown() const
{
return m_changed;
if (m_parentItem) {
return m_parentItem->isKnown();
}
return true;
}
inline void setChanged(bool changed)
{
m_changed = changed;
}
virtual void setHighlightManager(HighLightManager *mgr);
QTime getHiglightExpires() const;
virtual void removeHighlight();
int nameIndex(QString name) const
{
for (int i = 0; i < childCount(); ++i) {
if (name < getChild(i)->data(0).toString()) {
if (name < child(i)->data(0).toString()) {
return i;
}
}
@ -176,7 +186,7 @@ public:
TreeItem *findChildByName(QString name) const
{
foreach(TreeItem * child, m_children) {
foreach(TreeItem * child, m_childItems) {
if (name == child->data(0).toString()) {
return child;
}
@ -210,49 +220,35 @@ public:
}
return 0;
}
void updateIsKnown(bool isKnown)
{
if (isKnown != this->isKnown()) {
m_changed = false;
foreach(TreeItem * child, m_children) {
child->updateIsKnown(isKnown);
}
emit updateIsKnown(this);
}
}
virtual bool isKnown() const
{
return true;
}
signals:
void updateHighlight(TreeItem *item);
void updateIsKnown(TreeItem *item);
private slots:
private:
static int m_highlightTimeMs;
QList<TreeItem *> m_children;
QList<TreeItem *> m_childItems;
// m_data contains: [0] property name, [1] value, [2] unit
QList<QVariant> m_data;
QList<QVariant> m_itemData;
TreeItem *m_parentItem;
QString m_description;
TreeItem *m_parent;
bool m_highlight;
bool m_changed;
bool m_highlighted;
QTime m_highlightExpires;
HighLightManager *m_highlightManager;
HighlightManager *m_highlightManager;
};
class DataObjectTreeItem;
class MetaObjectTreeItem;
class TopTreeItem : public TreeItem {
Q_OBJECT
public:
TopTreeItem(const QList<QVariant> &data, TreeItem *parent = 0) : TreeItem(data, parent) {}
TopTreeItem(const QVariant &data, TreeItem *parent = 0) : TreeItem(data, parent) {}
TopTreeItem(const QList<QVariant> &data, TreeItem *parentItem) :
TreeItem(data, parentItem)
{}
TopTreeItem(const QVariant &data, TreeItem *parentItem) :
TreeItem(data, parentItem)
{}
void addObjectTreeItem(quint32 objectId, DataObjectTreeItem *oti)
{
@ -274,65 +270,55 @@ public:
return m_metaObjectTreeItemsPerObjectIds.value(objectId, 0);
}
QList<MetaObjectTreeItem *> getMetaObjectItems();
private:
QHash<quint32, DataObjectTreeItem *> m_objectTreeItemsPerObjectIds;
QHash<quint32, MetaObjectTreeItem *> m_metaObjectTreeItemsPerObjectIds;
};
class ObjectTreeItem : public TreeItem {
Q_OBJECT
public:
ObjectTreeItem(const QList<QVariant> &data, UAVObject *object, TreeItem *parent = 0) :
TreeItem(data, parent), m_obj(object)
ObjectTreeItem(const QList<QVariant> &data, UAVObject *object, TreeItem *parentItem) :
TreeItem(data, parentItem), m_obj(object)
{
setDescription(m_obj->getDescription());
}
ObjectTreeItem(const QVariant &data, UAVObject *object, TreeItem *parent = 0) :
TreeItem(data, parent), m_obj(object)
ObjectTreeItem(const QVariant &data, UAVObject *object, TreeItem *parentItem) :
TreeItem(data, parentItem), m_obj(object)
{
setDescription(m_obj->getDescription());
}
inline UAVObject *object()
UAVObject *object() const
{
return m_obj;
}
bool isKnown()
{
return !m_obj->isSettingsObject() || m_obj->isKnown();
}
private:
UAVObject *m_obj;
};
class MetaObjectTreeItem : public ObjectTreeItem {
Q_OBJECT
public:
MetaObjectTreeItem(UAVObject *object, const QList<QVariant> &data, TreeItem *parent = 0) :
ObjectTreeItem(data, object, parent)
MetaObjectTreeItem(UAVObject *object, const QList<QVariant> &data, TreeItem *parentItem) :
ObjectTreeItem(data, object, parentItem)
{}
MetaObjectTreeItem(UAVObject *object, const QVariant &data, TreeItem *parent = 0) :
ObjectTreeItem(data, object, parent)
MetaObjectTreeItem(UAVObject *object, const QVariant &data, TreeItem *parentItem) :
ObjectTreeItem(data, object, parentItem)
{}
bool isKnown()
{
return parent()->isKnown();
}
};
class DataObjectTreeItem : public ObjectTreeItem {
Q_OBJECT
public:
DataObjectTreeItem(const QList<QVariant> &data, UAVObject *object, TreeItem *parent = 0) :
ObjectTreeItem(data, object, parent) {}
DataObjectTreeItem(const QVariant &data, UAVObject *object, TreeItem *parent = 0) :
ObjectTreeItem(data, object, parent) {}
DataObjectTreeItem(const QList<QVariant> &data, UAVObject *object, TreeItem *parentItem) :
ObjectTreeItem(data, object, parentItem)
{}
DataObjectTreeItem(const QVariant &data, UAVObject *object, TreeItem *parentItem) :
ObjectTreeItem(data, object, parentItem)
{}
virtual void apply()
{
foreach(TreeItem * child, treeChildren()) {
foreach(TreeItem * child, children()) {
MetaObjectTreeItem *metaChild = dynamic_cast<MetaObjectTreeItem *>(child);
if (!metaChild) {
@ -340,9 +326,10 @@ public:
}
}
}
virtual void update()
{
foreach(TreeItem * child, treeChildren()) {
foreach(TreeItem * child, children()) {
MetaObjectTreeItem *metaChild = dynamic_cast<MetaObjectTreeItem *>(child);
if (!metaChild) {
@ -350,21 +337,27 @@ public:
}
}
}
virtual bool isKnown() const
{
return !object()->isSettingsObject() || object()->isKnown();
}
};
class InstanceTreeItem : public DataObjectTreeItem {
Q_OBJECT
public:
InstanceTreeItem(UAVObject *object, const QList<QVariant> &data, TreeItem *parent = 0) :
DataObjectTreeItem(data, object, parent)
InstanceTreeItem(UAVObject *object, const QList<QVariant> &data, TreeItem *parentItem) :
DataObjectTreeItem(data, object, parentItem)
{}
InstanceTreeItem(UAVObject *object, const QVariant &data, TreeItem *parent = 0) :
DataObjectTreeItem(data, object, parent)
InstanceTreeItem(UAVObject *object, const QVariant &data, TreeItem *parentItem) :
DataObjectTreeItem(data, object, parentItem)
{}
virtual void apply()
{
TreeItem::apply();
}
virtual void update()
{
TreeItem::update();
@ -372,17 +365,15 @@ public:
};
class ArrayFieldTreeItem : public TreeItem {
Q_OBJECT
public:
ArrayFieldTreeItem(UAVObjectField *field, const QList<QVariant> &data, TreeItem *parent = 0) : TreeItem(data, parent), m_field(field)
ArrayFieldTreeItem(UAVObjectField *field, const QList<QVariant> &data, TreeItem *parentItem) :
TreeItem(data, parentItem), m_field(field)
{}
ArrayFieldTreeItem(UAVObjectField *field, const QVariant &data, TreeItem *parent = 0) : TreeItem(data, parent), m_field(field)
ArrayFieldTreeItem(UAVObjectField *field, const QVariant &data, TreeItem *parentItem) :
TreeItem(data, parentItem), m_field(field)
{}
QVariant data(int column) const;
bool isKnown()
{
return parent()->isKnown();
}
private:
UAVObjectField *m_field;

View File

@ -50,7 +50,7 @@ void UAVObjectBrowser::loadConfiguration(IUAVGadgetConfiguration *config)
m_widget->setRecentlyUpdatedColor(m->recentlyUpdatedColor());
m_widget->setManuallyChangedColor(m->manuallyChangedColor());
m_widget->setRecentlyUpdatedTimeout(m->recentlyUpdatedTimeout());
m_widget->setOnlyHilightChangedValues(m->onlyHighlightChangedValues());
m_widget->setOnlyHighlightChangedValues(m->onlyHighlightChangedValues());
m_widget->setViewOptions(m->categorizedView(), m->scientificView(), m->showMetaData(), m->showDescription());
m_widget->setSplitterState(m->splitterState());
}

View File

@ -38,6 +38,7 @@
#include "extensionsystem/pluginmanager.h"
#include "utils/mustache.h"
#include <QTextStream>
#include <QDebug>
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent)
@ -47,10 +48,7 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
m_viewoptions = new Ui_viewoptions();
m_viewoptions->setupUi(m_viewoptionsDialog);
m_model = new UAVObjectTreeModel(this,
m_viewoptions->cbCategorized->isChecked(),
m_viewoptions->cbMetaData->isChecked(),
m_viewoptions->cbScientific->isChecked());
m_model = createTreeModel();
m_modelProxy = new TreeSortFilterProxyModel(this);
m_modelProxy->setSourceModel(m_model);
@ -156,7 +154,7 @@ ObjectTreeItem *UAVObjectBrowserWidget::findCurrentObjectTreeItem()
if (objItem) {
break;
}
item = item->parent();
item = item->parentItem();
}
return objItem;
}
@ -186,7 +184,7 @@ void UAVObjectBrowserWidget::saveObject()
if (objItem != NULL) {
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj);
updateObjectPersistence(ObjectPersistence::OPERATION_SAVE, obj);
}
}
@ -198,7 +196,7 @@ void UAVObjectBrowserWidget::loadObject()
if (objItem != NULL) {
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_LOAD, obj);
updateObjectPersistence(ObjectPersistence::OPERATION_LOAD, obj);
// Retrieve object so that latest value is displayed
requestUpdate();
}
@ -211,13 +209,13 @@ void UAVObjectBrowserWidget::eraseObject()
if (objItem != NULL) {
UAVObject *obj = objItem->object();
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_DELETE, obj);
updateObjectPersistence(ObjectPersistence::OPERATION_DELETE, obj);
// Retrieve object so that correct default value is displayed
requestUpdate();
}
}
void UAVObjectBrowserWidget::updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj)
void UAVObjectBrowserWidget::updateObjectPersistence(ObjectPersistence::OperationOptions op, UAVObject *obj)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
@ -238,11 +236,11 @@ void UAVObjectBrowserWidget::currentChanged(const QModelIndex &current, const QM
{
Q_UNUSED(previous);
TreeItem *item = static_cast<TreeItem *>(current.data(Qt::UserRole).value<void *>());
bool enable = true;
bool enable = true;
if (!current.isValid()) {
enable = false;
}
TreeItem *item = static_cast<TreeItem *>(current.data(Qt::UserRole).value<void *>());
TopTreeItem *top = dynamic_cast<TopTreeItem *>(item);
ObjectTreeItem *data = dynamic_cast<ObjectTreeItem *>(item);
if (top || (data && !data->object())) {
@ -264,25 +262,33 @@ void UAVObjectBrowserWidget::viewSlot()
}
}
void UAVObjectBrowserWidget::updateViewOptions()
UAVObjectTreeModel *UAVObjectBrowserWidget::createTreeModel()
{
// TODO we should update the model instead of rebuilding it
// a side effect of rebuilding is that some state is lost (expand state, ...)
UAVObjectTreeModel *model = new UAVObjectTreeModel(this,
m_viewoptions->cbCategorized->isChecked(),
m_viewoptions->cbMetaData->isChecked(),
m_viewoptions->cbScientific->isChecked());
model->setUnknowObjectColor(m_unknownObjectColor);
model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
model->setManuallyChangedColor(m_manuallyChangedColor);
model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
model->setOnlyHilightChangedValues(m_onlyHilightChangedValues);
model->setUnknowObjectColor(m_unknownObjectColor);
model->setOnlyHighlightChangedValues(m_onlyHighlightChangedValues);
UAVObjectTreeModel *tmpModel = m_model;
m_model = model;
m_modelProxy->setSourceModel(m_model);
delete tmpModel;
return model;
}
void UAVObjectBrowserWidget::updateViewOptions()
{
bool categorize = m_viewoptions->cbCategorized->isChecked();
bool useScientificNotation = m_viewoptions->cbScientific->isChecked();
bool showMetadata = m_viewoptions->cbMetaData->isChecked();
bool showDesc = m_viewoptions->cbDescription->isChecked();
m_model->setShowCategories(categorize);
m_model->setShowMetadata(showMetadata);
m_model->setShowScientificNotation(useScientificNotation);
m_model->resetModelData();
// force an expand all if search text is not empty
if (!m_browser->searchLine->text().isEmpty()) {
@ -290,8 +296,7 @@ void UAVObjectBrowserWidget::updateViewOptions()
}
// persist options
emit viewOptionsChanged(m_viewoptions->cbCategorized->isChecked(), m_viewoptions->cbScientific->isChecked(),
m_viewoptions->cbMetaData->isChecked(), m_viewoptions->cbDescription->isChecked());
emit viewOptionsChanged(categorize, useScientificNotation, showMetadata, showDesc);
}
void UAVObjectBrowserWidget::splitterMoved()

View File

@ -79,10 +79,10 @@ public:
m_recentlyUpdatedTimeout = timeout;
m_model->setRecentlyUpdatedTimeout(timeout);
}
void setOnlyHilightChangedValues(bool hilight)
void setOnlyHighlightChangedValues(bool hilight)
{
m_onlyHilightChangedValues = hilight;
m_model->setOnlyHilightChangedValues(hilight);
m_onlyHighlightChangedValues = hilight;
m_model->setOnlyHighlightChangedValues(hilight);
}
void setViewOptions(bool categorized, bool scientific, bool metadata, bool description);
void setSplitterState(QByteArray state);
@ -119,10 +119,12 @@ private:
QColor m_unknownObjectColor;
QColor m_recentlyUpdatedColor;
QColor m_manuallyChangedColor;
bool m_onlyHilightChangedValues;
bool m_onlyHighlightChangedValues;
QString m_mustacheTemplate;
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
UAVObjectTreeModel *createTreeModel();
void updateObjectPersistence(ObjectPersistence::OperationOptions op, UAVObject *obj);
void enableSendRequest(bool enable);
void updateDescription();
ObjectTreeItem *findCurrentObjectTreeItem();

View File

@ -26,16 +26,15 @@
*/
#include "uavobjecttreemodel.h"
#include "fieldtreeitem.h"
#include "uavobjectmanager.h"
#include "uavdataobject.h"
#include "uavmetaobject.h"
#include "uavobjectfield.h"
#include "extensionsystem/pluginmanager.h"
#include <QColor>
#include <QtCore/QTimer>
#include <QtCore/QSignalMapper>
#include <QtCore/QDebug>
UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize, bool showMetadata, bool useScientificNotation) :
QAbstractItemModel(parent),
@ -52,36 +51,78 @@ UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize, bool sh
Q_ASSERT(objManager);
m_highlightManager = new HighLightManager();
connect(objManager, SIGNAL(newObject(UAVObject *)), this, SLOT(newObject(UAVObject *)));
connect(objManager, SIGNAL(newInstance(UAVObject *)), this, SLOT(newObject(UAVObject *)));
m_highlightManager = new HighlightManager();
connect(m_highlightManager, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
TreeItem::setHighlightTime(m_recentlyUpdatedTimeout);
setupModelData(objManager);
}
UAVObjectTreeModel::~UAVObjectTreeModel()
{
delete m_highlightManager;
delete m_rootItem;
delete m_highlightManager;
}
void UAVObjectTreeModel::resetModelData()
{
m_highlightManager->reset();
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
Q_ASSERT(objManager);
emit beginResetModel();
delete m_rootItem;
m_rootItem = NULL;
setupModelData(objManager);
emit endResetModel();
}
void UAVObjectTreeModel::setShowCategories(bool showCategories)
{
if (showCategories == m_categorize) {
return;
}
m_categorize = showCategories;
}
void UAVObjectTreeModel::setShowMetadata(bool showMetadata)
{
if (showMetadata == m_showMetadata) {
return;
}
m_showMetadata = showMetadata;
}
void UAVObjectTreeModel::setShowScientificNotation(bool showScientificNotation)
{
if (showScientificNotation == m_useScientificFloatNotation) {
return;
}
m_useScientificFloatNotation = showScientificNotation;
}
void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager)
{
m_settingsTree = new TopTreeItem(tr("Settings"));
m_settingsTree->setHighlightManager(m_highlightManager);
connect(m_settingsTree, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
m_nonSettingsTree = new TopTreeItem(tr("Data Objects"));
m_nonSettingsTree->setHighlightManager(m_highlightManager);
connect(m_nonSettingsTree, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
// root
QList<QVariant> rootData;
rootData << tr("Property") << tr("Value") << tr("Unit");
m_rootItem = new TreeItem(rootData);
m_rootItem = new TreeItem(rootData);
m_rootItem->setHighlightManager(m_highlightManager);
m_settingsTree = new TopTreeItem(tr("Settings"), m_rootItem);
m_settingsTree->setHighlightManager(m_highlightManager);
m_nonSettingsTree = new TopTreeItem(tr("Data Objects"), m_rootItem);
m_nonSettingsTree->setHighlightManager(m_highlightManager);
// tree item takes ownership of its children
m_rootItem->appendChild(m_settingsTree);
m_rootItem->appendChild(m_nonSettingsTree);
@ -89,6 +130,7 @@ void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager)
QList< QList<UAVDataObject *> > objList = objManager->getDataObjects();
foreach(QList<UAVDataObject *> list, objList) {
foreach(UAVDataObject * obj, list) {
disconnect(obj, 0, this, 0);
addDataObject(obj);
}
}
@ -118,10 +160,9 @@ void UAVObjectTreeModel::addDataObject(UAVDataObject *obj)
if (existing) {
addInstance(obj, existing);
} else {
DataObjectTreeItem *dataTreeItem = new DataObjectTreeItem(obj->getName(), obj);
DataObjectTreeItem *dataTreeItem = new DataObjectTreeItem(obj->getName(), obj, parent);
dataTreeItem->setHighlightManager(m_highlightManager);
connect(dataTreeItem, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
connect(dataTreeItem, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
parent->insertChild(dataTreeItem);
root->addObjectTreeItem(obj->getObjID(), dataTreeItem);
if (m_showMetadata) {
@ -141,9 +182,9 @@ TreeItem *UAVObjectTreeModel::createCategoryItems(QStringList categoryPath, Tree
TreeItem *existing = parent->findChildByName(category);
if (!existing) {
TreeItem *categoryItem = new TopTreeItem(category);
connect(categoryItem, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
TreeItem *categoryItem = new TopTreeItem(category, parent);
categoryItem->setHighlightManager(m_highlightManager);
parent->insertChild(categoryItem);
parent = categoryItem;
} else {
@ -155,11 +196,11 @@ TreeItem *UAVObjectTreeModel::createCategoryItems(QStringList categoryPath, Tree
MetaObjectTreeItem *UAVObjectTreeModel::addMetaObject(UAVMetaObject *obj, TreeItem *parent)
{
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(highlightUpdatedObject(UAVObject *)));
MetaObjectTreeItem *meta = new MetaObjectTreeItem(obj, tr("Meta Data"));
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateObject(UAVObject *)));
MetaObjectTreeItem *meta = new MetaObjectTreeItem(obj, tr("Meta Data"), parent);
meta->setHighlightManager(m_highlightManager);
connect(meta, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
foreach(UAVObjectField * field, obj->getFields()) {
if (field->getNumElements() > 1) {
addArrayField(field, meta);
@ -173,19 +214,16 @@ MetaObjectTreeItem *UAVObjectTreeModel::addMetaObject(UAVMetaObject *obj, TreeIt
void UAVObjectTreeModel::addInstance(UAVObject *obj, TreeItem *parent)
{
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(highlightUpdatedObject(UAVObject *)));
connect(obj, SIGNAL(isKnownChanged(UAVObject *, bool)), this, SLOT(isKnownChanged(UAVObject *, bool)));
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateObject(UAVObject *)));
connect(obj, SIGNAL(isKnownChanged(UAVObject *)), this, SLOT(updateIsKnown(UAVObject *)));
TreeItem *item;
if (obj->isSingleInstance()) {
item = parent;
DataObjectTreeItem *objectItem = static_cast<DataObjectTreeItem *>(parent);
connect(objectItem, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
} else {
QString name = tr("Instance") + " " + QString::number(obj->getInstID());
item = new InstanceTreeItem(obj, name);
item = new InstanceTreeItem(obj, name, parent);
item->setHighlightManager(m_highlightManager);
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
connect(item, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
parent->appendChild(item);
}
foreach(UAVObjectField * field, obj->getFields()) {
@ -199,15 +237,14 @@ void UAVObjectTreeModel::addInstance(UAVObject *obj, TreeItem *parent)
void UAVObjectTreeModel::addArrayField(UAVObjectField *field, TreeItem *parent)
{
TreeItem *item = new ArrayFieldTreeItem(field, field->getName());
TreeItem *item = new ArrayFieldTreeItem(field, field->getName(), parent);
item->setHighlightManager(m_highlightManager);
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
connect(item, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
for (uint i = 0; i < field->getNumElements(); ++i) {
parent->appendChild(item);
for (int i = 0; i < (int)field->getNumElements(); ++i) {
addSingleField(i, field, item);
}
parent->appendChild(item);
}
void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeItem *parent)
@ -229,7 +266,7 @@ void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeIt
QVariant value = field->getValue(index);
data.append(options.indexOf(value.toString()));
data.append(field->getUnits());
item = new EnumFieldTreeItem(field, index, data);
item = new EnumFieldTreeItem(field, index, data, parent);
break;
}
case UAVObjectField::INT8:
@ -241,25 +278,25 @@ void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeIt
data.append(field->getValue(index));
data.append(field->getUnits());
if (field->getUnits().toLower() == "hex") {
item = new HexFieldTreeItem(field, index, data);
item = new HexFieldTreeItem(field, index, data, parent);
} else if (field->getUnits().toLower() == "char") {
item = new CharFieldTreeItem(field, index, data);
item = new CharFieldTreeItem(field, index, data, parent);
} else {
item = new IntFieldTreeItem(field, index, data);
item = new IntFieldTreeItem(field, index, data, parent);
}
break;
case UAVObjectField::FLOAT32:
data.append(field->getValue(index));
data.append(field->getUnits());
item = new FloatFieldTreeItem(field, index, data, m_useScientificFloatNotation);
item = new FloatFieldTreeItem(field, index, data, m_useScientificFloatNotation, parent);
break;
default:
Q_ASSERT(false);
}
item->setHighlightManager(m_highlightManager);
item->setDescription(field->getDescription());
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
connect(item, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
parent->appendChild(item);
}
@ -270,14 +307,13 @@ QModelIndex UAVObjectTreeModel::index(int row, int column, const QModelIndex &pa
}
TreeItem *parentItem;
if (!parent.isValid()) {
parentItem = m_rootItem;
} else {
parentItem = static_cast<TreeItem *>(parent.internalPointer());
}
TreeItem *childItem = parentItem->getChild(row);
TreeItem *childItem = parentItem->child(row);
if (childItem) {
return createIndex(row, column, childItem);
}
@ -286,6 +322,10 @@ QModelIndex UAVObjectTreeModel::index(int row, int column, const QModelIndex &pa
QModelIndex UAVObjectTreeModel::index(TreeItem *item, int column)
{
if (item == m_rootItem) {
return QModelIndex();
}
return createIndex(item->row(), column, item);
}
@ -296,7 +336,7 @@ QModelIndex UAVObjectTreeModel::parent(const QModelIndex &index) const
}
TreeItem *childItem = static_cast<TreeItem *>(index.internalPointer());
TreeItem *parentItem = childItem->parent();
TreeItem *parentItem = childItem->parentItem();
if (parentItem == m_rootItem) {
return QModelIndex();
@ -324,24 +364,15 @@ int UAVObjectTreeModel::rowCount(const QModelIndex &parent) const
int UAVObjectTreeModel::columnCount(const QModelIndex &parent) const
{
TreeItem *parentItem;
if (parent.isValid()) {
return static_cast<TreeItem *>(parent.internalPointer())->columnCount();
parentItem = static_cast<TreeItem *>(parent.internalPointer());
} else {
return m_rootItem->columnCount();
}
}
QList<QModelIndex> UAVObjectTreeModel::getMetaDataIndexes()
{
QList<QModelIndex> metaIndexes;
foreach(MetaObjectTreeItem * metaItem, m_settingsTree->getMetaObjectItems()) {
metaIndexes.append(index(metaItem));
parentItem = m_rootItem;
}
foreach(MetaObjectTreeItem * metaItem, m_nonSettingsTree->getMetaObjectItems()) {
metaIndexes.append(index(metaItem));
}
return metaIndexes;
return parentItem->columnCount();
}
QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
@ -380,12 +411,12 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
case Qt::BackgroundRole:
if (index.column() == TreeItem::TITLE_COLUMN) {
if (!dynamic_cast<TopTreeItem *>(item) && item->highlighted()) {
if (!dynamic_cast<TopTreeItem *>(item) && item->isHighlighted()) {
return m_recentlyUpdatedColor;
}
} else if (index.column() == TreeItem::DATA_COLUMN) {
FieldTreeItem *fieldItem = dynamic_cast<FieldTreeItem *>(item);
if (fieldItem && fieldItem->highlighted()) {
if (fieldItem && fieldItem->isHighlighted()) {
return m_recentlyUpdatedColor;
}
if (fieldItem && fieldItem->changed()) {
@ -435,19 +466,18 @@ QVariant UAVObjectTreeModel::headerData(int section, Qt::Orientation orientation
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
return m_rootItem->data(section);
}
return QVariant();
}
void UAVObjectTreeModel::highlightUpdatedObject(UAVObject *obj)
void UAVObjectTreeModel::updateObject(UAVObject *obj)
{
Q_ASSERT(obj);
ObjectTreeItem *item = findObjectTreeItem(obj);
Q_ASSERT(item);
if (!m_onlyHilightChangedValues) {
item->setHighlight(true);
}
item->update();
if (!m_onlyHighlightChangedValues) {
item->setHighlighted(true);
}
}
ObjectTreeItem *UAVObjectTreeModel::findObjectTreeItem(UAVObject *object)
@ -498,6 +528,15 @@ void UAVObjectTreeModel::updateHighlight(TreeItem *item)
emit dataChanged(itemIndex, itemIndex);
}
void UAVObjectTreeModel::updateIsKnown(UAVObject *object)
{
ObjectTreeItem *item = findObjectTreeItem(object);
if (item) {
updateIsKnown(item);
}
}
void UAVObjectTreeModel::updateIsKnown(TreeItem *item)
{
QModelIndex itemIndex;
@ -505,13 +544,8 @@ void UAVObjectTreeModel::updateIsKnown(TreeItem *item)
itemIndex = index(item, TreeItem::TITLE_COLUMN);
Q_ASSERT(itemIndex != QModelIndex());
emit dataChanged(itemIndex, itemIndex);
}
void UAVObjectTreeModel::isKnownChanged(UAVObject *object, bool isKnown)
{
Q_UNUSED(isKnown);
ObjectTreeItem *item = findObjectTreeItem(object);
if (item) {
item->updateIsKnown(isKnown);
foreach(TreeItem * child, item->children()) {
updateIsKnown(child);
}
}

View File

@ -29,9 +29,10 @@
#define UAVOBJECTTREEMODEL_H
#include "treeitem.h"
#include <QAbstractItemModel>
#include <QtCore/QMap>
#include <QtCore/QList>
#include <QMap>
#include <QList>
#include <QColor>
class TopTreeItem;
@ -49,7 +50,6 @@ class UAVObjectTreeModel : public QAbstractItemModel {
Q_OBJECT
public:
explicit UAVObjectTreeModel(QObject *parent, bool categorize, bool showMetadata, bool useScientificNotation);
explicit UAVObjectTreeModel(bool categorize, bool showMetadata, bool useScientificNotation);
~UAVObjectTreeModel();
QVariant data(const QModelIndex &index, int role) const;
@ -63,6 +63,29 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void resetModelData();
bool showCategories()
{
return m_categorize;
}
void setShowCategories(bool showCategories);
bool showMetadata()
{
return m_showMetadata;
}
void setShowMetadata(bool showMetadata);
bool showScientificNotation()
{
return m_useScientificFloatNotation;
}
void setShowScientificNotation(bool showScientificNotation);
void setUnknowObjectColor(QColor color)
{
m_unknownObjectColor = color;
@ -80,27 +103,23 @@ public:
m_recentlyUpdatedTimeout = timeout;
TreeItem::setHighlightTime(timeout);
}
void setOnlyHilightChangedValues(bool hilight)
void setOnlyHighlightChangedValues(bool hilight)
{
m_onlyHilightChangedValues = hilight;
m_onlyHighlightChangedValues = hilight;
}
QList<QModelIndex> getMetaDataIndexes();
signals:
public slots:
void newObject(UAVObject *obj);
private slots:
void updateObject(UAVObject *obj);
void updateIsKnown(UAVObject *obj);
void updateHighlight(TreeItem *item);
void updateIsKnown(TreeItem *item);
void highlightUpdatedObject(UAVObject *obj);
void isKnownChanged(UAVObject *object, bool isKnown);
private:
void setupModelData(UAVObjectManager *objManager);
QModelIndex index(TreeItem *item, int column = 0);
void setupModelData(UAVObjectManager *objManager);
void addDataObject(UAVDataObject *obj);
MetaObjectTreeItem *addMetaObject(UAVMetaObject *obj, TreeItem *parent);
void addArrayField(UAVObjectField *field, TreeItem *parent);
@ -124,10 +143,10 @@ private:
QColor m_recentlyUpdatedColor;
QColor m_manuallyChangedColor;
QColor m_unknownObjectColor;
bool m_onlyHilightChangedValues;
bool m_onlyHighlightChangedValues;
// Highlight manager to handle highlighting of tree items.
HighLightManager *m_highlightManager;
HighlightManager *m_highlightManager;
};
#endif // UAVOBJECTTREEMODEL_H

View File

@ -622,7 +622,7 @@ void UAVObject::setIsKnown(bool isKnown)
unlock();
if (changed) {
emit isKnownChanged(this, isKnown);
emit isKnownChanged(this);
}
}

View File

@ -181,7 +181,7 @@ signals:
void updateRequested(UAVObject *obj, bool all = false);
void transactionCompleted(UAVObject *obj, bool success);
void newInstance(UAVObject *obj);
void isKnownChanged(UAVObject *obj, bool isKnown);
void isKnownChanged(UAVObject *obj);
protected:
quint32 objID;