FactPanelController.h 2.04 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9

10 11 12 13 14 15 16 17 18 19 20 21

#ifndef FactPanelController_H
#define FactPanelController_H

/// @file
///     @author Don Gagne <don@thegagnes.com>

#include <QObject>
#include <QQuickItem>

#include "UASInterface.h"
#include "AutoPilotPlugin.h"
Don Gagne's avatar
Don Gagne committed
22 23 24
#include "QGCLoggingCategory.h"

Q_DECLARE_LOGGING_CATEGORY(FactPanelControllerLog)
25 26 27 28 29

/// FactPanelController is used in combination with the FactPanel Qml control for handling
/// missing Facts from C++ code.
class FactPanelController : public QObject
{
dogmaphobic's avatar
dogmaphobic committed
30 31
    Q_OBJECT

32
public:
dogmaphobic's avatar
dogmaphobic committed
33 34
    FactPanelController(void);

35
    Q_PROPERTY(QQuickItem* factPanel READ factPanel WRITE setFactPanel)
36
    Q_PROPERTY(Vehicle* vehicle MEMBER _vehicle CONSTANT)
dogmaphobic's avatar
dogmaphobic committed
37 38 39 40

    Q_INVOKABLE Fact*   getParameterFact    (int componentId, const QString& name, bool reportMissing = true);
    Q_INVOKABLE bool    parameterExists     (int componentId, const QString& name);

41 42
    QQuickItem* factPanel(void);
    void setFactPanel(QQuickItem* panel);
dogmaphobic's avatar
dogmaphobic committed
43

44
protected:
Don Gagne's avatar
Don Gagne committed
45 46 47
    /// Checks for existence of the specified parameters
    /// @return true: all parameters exists, false: parameters missing and reported
    bool _allParametersExists(int componentId, QStringList names);
dogmaphobic's avatar
dogmaphobic committed
48

Don Gagne's avatar
Don Gagne committed
49 50
    /// Report a missing parameter to the FactPanel Qml element
    void _reportMissingParameter(int componentId, const QString& name);
dogmaphobic's avatar
dogmaphobic committed
51

52 53 54
    Vehicle*            _vehicle;
    UASInterface*       _uas;
    AutoPilotPlugin*    _autopilot;
dogmaphobic's avatar
dogmaphobic committed
55

56 57
private slots:
    void _checkForMissingFactPanel(void);
dogmaphobic's avatar
dogmaphobic committed
58

59
private:
Don Gagne's avatar
Don Gagne committed
60 61 62
    void _notifyPanelMissingParameter(const QString& missingParam);
    void _notifyPanelErrorMsg(const QString& errorMsg);
    void _showInternalError(const QString& errorMsg);
63 64

    QQuickItem*         _factPanel;
Don Gagne's avatar
Don Gagne committed
65
    QStringList         _delayedMissingParams;
66 67
};

dogmaphobic's avatar
dogmaphobic committed
68
#endif