FactPanelController.h 2.18 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:
33 34
    /// @param standaloneUnitTesting true: being run without factPanel, false: normal operation, factPanel is required
    FactPanelController(bool standaloneUnitTesting = false);
dogmaphobic's avatar
dogmaphobic committed
35

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

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

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

45
protected:
Don Gagne's avatar
Don Gagne committed
46 47 48
    /// 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
49

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

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

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

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

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

dogmaphobic's avatar
dogmaphobic committed
69
#endif