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 bool filterAcceptsRow(int source_row
, const QModelIndex
&source_parent
) const;
51 bool filterAcceptsRowItself(int source_row
, const QModelIndex
&source_parent
) const;
52 bool hasAcceptedChildren(int source_row
, const QModelIndex
&source_parent
) const;
55 class UAVObjectBrowserWidget
: public QWidget
{
59 UAVObjectBrowserWidget(QWidget
*parent
= 0);
60 ~UAVObjectBrowserWidget();
62 void setUnknownObjectColor(QColor color
)
64 m_unknownObjectColor
= color
;
65 m_model
->setUnknowObjectColor(color
);
67 void setRecentlyUpdatedColor(QColor color
)
69 m_recentlyUpdatedColor
= color
;
70 m_model
->setRecentlyUpdatedColor(color
);
72 void setManuallyChangedColor(QColor color
)
74 m_manuallyChangedColor
= color
;
75 m_model
->setManuallyChangedColor(color
);
77 void setRecentlyUpdatedTimeout(int timeout
)
79 m_recentlyUpdatedTimeout
= timeout
;
80 m_model
->setRecentlyUpdatedTimeout(timeout
);
82 void setOnlyHilightChangedValues(bool hilight
)
84 m_onlyHilightChangedValues
= hilight
;
85 m_model
->setOnlyHilightChangedValues(hilight
);
87 void setViewOptions(bool categorized
, bool scientific
, bool metadata
, bool description
);
88 void setSplitterState(QByteArray state
);
91 void showDescription(bool show
);
99 void currentChanged(const QModelIndex
¤t
, const QModelIndex
&previous
);
101 void updateViewOptions();
102 void searchLineChanged(QString searchText
);
103 void searchTextCleared();
104 void splitterMoved();
105 QString
createObjectDescription(UAVObject
*object
);
108 void viewOptionsChanged(bool categorized
, bool scientific
, bool metadata
, bool description
);
109 void splitterChanged(QByteArray state
);
112 Ui_UAVObjectBrowser
*m_browser
;
113 Ui_viewoptions
*m_viewoptions
;
114 QDialog
*m_viewoptionsDialog
;
115 UAVObjectTreeModel
*m_model
;
116 TreeSortFilterProxyModel
*m_modelProxy
;
118 int m_recentlyUpdatedTimeout
;
119 QColor m_unknownObjectColor
;
120 QColor m_recentlyUpdatedColor
;
121 QColor m_manuallyChangedColor
;
122 bool m_onlyHilightChangedValues
;
123 QString m_mustacheTemplate
;
125 void updateObjectPersistance(ObjectPersistence::OperationOptions op
, UAVObject
*obj
);
126 void enableSendRequest(bool enable
);
127 void updateDescription();
128 ObjectTreeItem
*findCurrentObjectTreeItem();
129 QString
loadFileIntoString(QString fileName
);
132 #endif /* UAVOBJECTBROWSERWIDGET_H_ */