QGCParamWidget.h 3.58 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 36
#ifndef QGCPARAMWIDGET_H
#define QGCPARAMWIDGET_H

#include <QWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMap>
lm's avatar
lm committed
37
#include <QLabel>
38
#include <QTimer>
pixhawk's avatar
pixhawk committed
39

40
#include "QGCUASParamManager.h"
pixhawk's avatar
pixhawk committed
41 42
#include "UASInterface.h"

43 44 45
/**
 * @brief Widget to read/set onboard parameters
 */
46
class QGCParamWidget : public QGCUASParamManager
pixhawk's avatar
pixhawk committed
47
{
48
    Q_OBJECT
pixhawk's avatar
pixhawk committed
49
public:
50
    QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
LM's avatar
LM committed
51

tstellanova's avatar
tstellanova committed
52 53
protected:
    virtual void setParameterStatusMsg(const QString& msg);
54
    virtual void layoutWidget();
55 56 57
    virtual QTreeWidgetItem* getParentWidgetItemForParam(int compId, const QString& paramName);
    virtual QTreeWidgetItem* findChildWidgetItemForParam(QTreeWidgetItem* parentItem, const QString& paramName);

tstellanova's avatar
tstellanova committed
58

pixhawk's avatar
pixhawk committed
59
signals:
tstellanova's avatar
tstellanova committed
60

tstellanova's avatar
tstellanova committed
61

pixhawk's avatar
pixhawk committed
62
public slots:
tstellanova's avatar
tstellanova committed
63 64 65 66 67 68 69
    /** @brief Add a component to the list
     * @param compId Component id of the component
     * @param compName Human friendly name of the component
     */
    void addComponentItem(int compId, QString compName);


tstellanova's avatar
tstellanova committed
70
    virtual void handleParameterUpdate(int component,const QString& parameterName, QVariant value);
71 72
    virtual void handlePendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending);

tstellanova's avatar
tstellanova committed
73 74 75
    virtual void handleParameterListUpToDate();

    virtual void handleParamStatusMsgUpdate(QString msg, int level);
tstellanova's avatar
tstellanova committed
76 77

    /** @brief Ensure that view of parameter matches data in the model */
78
    QTreeWidgetItem* updateParameterDisplay(int component, QString parameterName, QVariant value);
79
    /** @brief Request list of parameters from MAV */
80
    void requestAllParamsUpdate();
tstellanova's avatar
tstellanova committed
81

82 83
    /** @brief Write the current parameters to permanent storage (EEPROM/HDD) */
    void writeParameters();
84 85
    /** @brief Read the parameters from permanent storage to RAM */
    void readParameters();
86
    /** @brief Clear the parameter list */
pixhawk's avatar
pixhawk committed
87
    void clear();
lm's avatar
lm committed
88
    /** @brief Update when user changes parameters */
89
    void parameterItemChanged(QTreeWidgetItem* prev, int column);
90 91

    /** @brief Store parameters to a file */
92
    void saveParametersToFile();
93
    /** @brief Load parameters from a file */
94 95
    void loadParametersFromFile();

tstellanova's avatar
tstellanova committed
96

97

pixhawk's avatar
pixhawk committed
98
protected:
lm's avatar
lm committed
99
    QTreeWidget* tree;   ///< The parameter tree
tstellanova's avatar
tstellanova committed
100 101 102
    QLabel* statusLabel; ///< User-facing parameter status label
    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
103
    QTreeWidgetItem* updatedLineItem_weak;///< weak ref to user-edited line
lm's avatar
lm committed
104

pixhawk's avatar
pixhawk committed
105 106 107
};

#endif // QGCPARAMWIDGET_H