2 ******************************************************************************
4 * @file uavobjectbrowserwidget.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
6 * Tau Labs, http://taulabs.org, Copyright (C) 2013
7 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
8 * @addtogroup GCSPlugins GCS Plugins
10 * @addtogroup UAVObjectBrowserPlugin UAVObject Browser Plugin
12 * @brief The UAVObject Browser gadget plugin
13 *****************************************************************************/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #ifndef UAVOBJECTBROWSERWIDGET_H_
31 #define UAVOBJECTBROWSERWIDGET_H_
33 #include "uavobjecttreemodel.h"
35 #include "objectpersistence.h"
38 #include <QSortFilterProxyModel>
42 class Ui_UAVObjectBrowser
;
45 class TreeSortFilterProxyModel
: public QSortFilterProxyModel
{
47 TreeSortFilterProxyModel(QObject
*parent
);
50 QModelIndexList
getPersistentIndexList() const
52 return persistentIndexList();
56 bool filterAcceptsRow(int source_row
, const QModelIndex
&source_parent
) const;
57 bool filterAcceptsRowItself(int source_row
, const QModelIndex
&source_parent
) const;
58 bool hasAcceptedChildren(int source_row
, const QModelIndex
&source_parent
) const;
61 class UAVObjectBrowserWidget
: public QWidget
{
65 UAVObjectBrowserWidget(QWidget
*parent
= 0);
66 ~UAVObjectBrowserWidget();
68 void setUnknownObjectColor(QColor color
)
70 m_unknownObjectColor
= color
;
71 m_model
->setUnknownObjectColor(color
);
73 void setRecentlyUpdatedColor(QColor color
)
75 m_recentlyUpdatedColor
= color
;
76 m_model
->setRecentlyUpdatedColor(color
);
78 void setManuallyChangedColor(QColor color
)
80 m_manuallyChangedColor
= color
;
81 m_model
->setManuallyChangedColor(color
);
83 void setRecentlyUpdatedTimeout(int timeout
)
85 m_recentlyUpdatedTimeout
= timeout
;
86 m_model
->setRecentlyUpdatedTimeout(timeout
);
88 void setOnlyHighlightChangedValues(bool highlight
)
90 m_onlyHighlightChangedValues
= highlight
;
91 m_model
->setOnlyHighlightChangedValues(highlight
);
93 void setViewOptions(bool showCategories
, bool showMetadata
, bool useScientificNotation
, bool showDescription
);
94 void setSplitterState(QByteArray state
);
96 void saveState(QSettings
&settings
) const;
97 void restoreState(QSettings
&settings
);
99 QString
indexToPath(const QModelIndex
&index
) const;
100 QModelIndex
indexFromPath(const QString
&path
) const;
103 void showDescription(bool show
);
107 void requestUpdate();
111 void currentChanged(const QModelIndex
¤t
, const QModelIndex
&previous
);
113 void updateViewOptions();
114 void searchLineChanged(QString searchText
);
115 void searchTextCleared();
116 void splitterMoved();
117 QString
createObjectDescription(UAVObject
*object
);
120 void viewOptionsChanged(bool categorized
, bool scientific
, bool metadata
, bool description
);
121 void splitterChanged(QByteArray state
);
124 Ui_UAVObjectBrowser
*m_browser
;
125 Ui_viewoptions
*m_viewoptions
;
126 QDialog
*m_viewoptionsDialog
;
127 UAVObjectTreeModel
*m_model
;
128 TreeSortFilterProxyModel
*m_modelProxy
;
130 int m_recentlyUpdatedTimeout
;
131 QColor m_unknownObjectColor
;
132 QColor m_recentlyUpdatedColor
;
133 QColor m_manuallyChangedColor
;
134 bool m_onlyHighlightChangedValues
;
135 QString m_mustacheTemplate
;
137 UAVObjectTreeModel
*createTreeModel();
139 void updateObjectPersistence(ObjectPersistence::OperationOptions op
, UAVObject
*obj
);
140 void enableSendRequest(bool enable
);
141 void updateDescription();
142 ObjectTreeItem
*findCurrentObjectTreeItem();
143 QString
loadFileIntoString(QString fileName
);
146 #endif /* UAVOBJECTBROWSERWIDGET_H_ */