2 ******************************************************************************
4 * @file uavobjecttreemodel.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
8 * @addtogroup UAVObjectBrowserPlugin UAVObject Browser Plugin
10 * @brief The UAVObject Browser gadget plugin
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef UAVOBJECTTREEMODEL_H
29 #define UAVOBJECTTREEMODEL_H
33 #include <QAbstractItemModel>
41 class DataObjectTreeItem
;
46 class UAVObjectManager
;
50 class UAVObjectTreeModel
: public QAbstractItemModel
{
53 explicit UAVObjectTreeModel(QObject
*parent
);
54 ~UAVObjectTreeModel();
56 QVariant
data(const QModelIndex
&index
, int role
) const;
57 bool setData(const QModelIndex
&index
, const QVariant
& value
, int role
);
58 Qt::ItemFlags
flags(const QModelIndex
&index
) const;
59 QVariant
headerData(int section
, Qt::Orientation orientation
,
60 int role
= Qt::DisplayRole
) const;
61 QModelIndex
index(int row
, int column
,
62 const QModelIndex
&parent
= QModelIndex()) const;
63 QModelIndex
parent(const QModelIndex
&index
) const;
64 int rowCount(const QModelIndex
&parent
= QModelIndex()) const;
65 int columnCount(const QModelIndex
&parent
= QModelIndex()) const;
67 bool showCategories() const;
68 void setShowCategories(bool show
);
70 bool showMetadata() const;
71 void setShowMetadata(bool show
);
73 bool useScientificNotation();
74 void setUseScientificNotation(bool useScientificNotation
);
76 QColor
unknownObjectColor() const;
77 void setUnknownObjectColor(QColor color
);
79 QColor
recentlyUpdatedColor() const;
80 void setRecentlyUpdatedColor(QColor color
);
82 QColor
manuallyChangedColor() const;
83 void setManuallyChangedColor(QColor color
);
85 int recentlyUpdatedTimeout() const;
86 void setRecentlyUpdatedTimeout(int timeout
);
88 bool onlyHighlightChangedValues() const;
89 void setOnlyHighlightChangedValues(bool highlight
);
91 bool highlightTopTreeItems() const;
92 void setHighlightTopTreeItems(bool highlight
);
95 void newObject(UAVObject
*obj
);
96 void updateObject(UAVObject
*obj
);
97 void updateIsKnown(UAVObject
*obj
);
98 void refreshHighlight(TreeItem
*item
);
99 void refreshIsKnown(TreeItem
*item
);
102 QSettings m_settings
;
104 HighlightManager
*m_highlightManager
;
106 TreeItem
*m_rootItem
;
107 TopTreeItem
*m_settingsTree
;
108 TopTreeItem
*m_nonSettingsTree
;
110 QHash
<quint32
, ObjectTreeItem
*> m_objectTreeItems
;
112 QModelIndex
index(TreeItem
*item
, int column
= 0) const;
114 void setupModelData();
115 void resetModelData();
117 void addObject(UAVDataObject
*obj
);
118 void addArrayField(UAVObjectField
*field
, TreeItem
*parent
);
119 void addSingleField(int index
, UAVObjectField
*field
, TreeItem
*parent
);
121 DataObjectTreeItem
*createDataObject(UAVDataObject
*obj
);
122 InstanceTreeItem
*createDataObjectInstance(UAVDataObject
*obj
);
123 MetaObjectTreeItem
*createMetaObject(UAVMetaObject
*obj
);
124 TreeItem
*getParentItem(UAVDataObject
*obj
, bool categorize
);
126 void appendItem(TreeItem
*parentItem
, TreeItem
*childItem
);
127 void insertItem(TreeItem
*parentItem
, TreeItem
*childItem
, int row
= -1);
128 void removeItem(TreeItem
*parentItem
, TreeItem
*childItem
);
129 void moveItem(TreeItem
*newParentItem
, TreeItem
*oldParentItem
, TreeItem
*childItem
);
131 void toggleCategoryItems();
132 void toggleMetaItems();
134 void addObjectTreeItem(quint32 objectId
, ObjectTreeItem
*oti
);
135 ObjectTreeItem
*findObjectTreeItem(quint32 objectId
);
137 DataObjectTreeItem
*findDataObjectTreeItem(UAVObject
*obj
);
140 #endif // UAVOBJECTTREEMODEL_H