QGCParamWidget.h 4.2 KB
Newer Older
1 2 3 4
/*=====================================================================

QGroundControl Open Source Ground Control Station

5
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief Declaration of class QGCParamWidget
 *   @author Lorenz Meier <mail@qgroundcontrol.org>
 */

pixhawk's avatar
pixhawk committed
30 31 32 33 34 35
#ifndef QGCPARAMWIDGET_H
#define QGCPARAMWIDGET_H

#include <QWidget>
#include <QTreeWidget>
#include <QMap>
lm's avatar
lm committed
36
#include <QLabel>
37
#include <QTimer>
38
#include "QGCParamTreeWidget.h"
pixhawk's avatar
pixhawk committed
39

40 41 42 43
#include "QGCBaseParamWidget.h"


//forward declarations
44
class QGridLayout;
45
class UASInterface;
pixhawk's avatar
pixhawk committed
46

47 48 49
/**
 * @brief Widget to read/set onboard parameters
 */
50
class QGCParamWidget : public QGCBaseParamWidget
pixhawk's avatar
pixhawk committed
51
{
52
    Q_OBJECT
pixhawk's avatar
pixhawk committed
53
public:
54
    QGCParamWidget(QWidget *parent = 0);
55

Don Gagne's avatar
Don Gagne committed
56 57 58 59
    /// @brief Sets the list of parameters which should be shown by this editor. Parameter names can be
    ///         wildcarded at the end such as this: "RC*". Which will filter to all parameters which begin
    ///         with "RC". The wildcard (*) can only be at the end of the string.
    void setFilterList(const QStringList& filterList) { _filterList = filterList; }
LM's avatar
LM committed
60

tstellanova's avatar
tstellanova committed
61 62
protected:
    virtual void setParameterStatusMsg(const QString& msg);
63
    virtual void layoutWidget();///< Layout the appearance of this widget
64 65 66
    virtual void connectViewSignalsAndSlots();///< Connect view signals/slots as needed
    virtual void disconnectViewSignalsAndSlots();///< Connect view signals/slots as needed

67 68 69
    virtual QTreeWidgetItem* getParentWidgetItemForParam(int compId, const QString& paramName);
    virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName);

70
    /** @brief Add a component item as a child of this widget
tstellanova's avatar
tstellanova committed
71 72 73 74 75
     * @param compId Component id of the component
     * @param compName Human friendly name of the component
     */
    void addComponentItem(int compId, QString compName);

76 77
    virtual void addActionButtonsToLayout(QGridLayout* layout);

78 79 80 81
public slots:
    virtual void handleOnboardParamUpdate(int component,const QString& parameterName, QVariant value);
    virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);
    virtual void handleOnboardParameterListUpToDate();
tstellanova's avatar
tstellanova committed
82
    virtual void handleParamStatusMsgUpdate(QString msg, int level);
tstellanova's avatar
tstellanova committed
83

84 85 86
    virtual void clearOnboardParamDisplay();
    virtual void clearPendingParamDisplay();

87 88 89
    /** @brief Adds parameter at the correct location by a alphapetical comparison of the parameter names */
    void insertParamAlphabetical(int indexLowerBound, int indexUpperBound, QTreeWidgetItem* parentItem, QTreeWidgetItem* paramItem);

tstellanova's avatar
tstellanova committed
90
    /** @brief Ensure that view of parameter matches data in the model */
91
    QTreeWidgetItem* updateParameterDisplay(int component, QString parameterName, QVariant value);
92

93 94
    /** @brief Update when user changes parameters */
    void parameterItemChanged(QTreeWidgetItem* prev, int column);
tstellanova's avatar
tstellanova committed
95

96 97 98 99
    /** Promt configuration for param map config from user */
    void configureRCToParam(QString param_id);


100

pixhawk's avatar
pixhawk committed
101
protected:
tstellanova's avatar
tstellanova committed
102 103
    QMap<int, QTreeWidgetItem*>* componentItems; ///< The tree of component items, stored by component ID
    QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups to organize component items
104
    QLabel* statusLabel; ///< User-facing parameter status label
105
    QGCParamTreeWidget* tree;   ///< The parameter tree
Don Gagne's avatar
Don Gagne committed
106
    QStringList _filterList;
107

108 109
private:
    bool _fullParamListLoaded;
pixhawk's avatar
pixhawk committed
110 111 112
};

#endif // QGCPARAMWIDGET_H