FactPanelController.h 1.7 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
#pragma once
12 13 14 15 16 17 18 19 20

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

#include <QObject>
#include <QQuickItem>

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

Q_DECLARE_LOGGING_CATEGORY(FactPanelControllerLog)
24

25
/// FactPanelController is used for handling missing Facts from C++ code.
26 27
class FactPanelController : public QObject
{
dogmaphobic's avatar
dogmaphobic committed
28
    Q_OBJECT
29
public:
30
    FactPanelController();
dogmaphobic's avatar
dogmaphobic committed
31

32
    Q_PROPERTY(Vehicle* vehicle MEMBER _vehicle CONSTANT)
dogmaphobic's avatar
dogmaphobic committed
33 34 35 36 37

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


38
protected:
Don Gagne's avatar
Don Gagne committed
39 40 41
    /// 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
42

43
    /// Report a missing parameter
Don Gagne's avatar
Don Gagne committed
44
    void _reportMissingParameter(int componentId, const QString& name);
dogmaphobic's avatar
dogmaphobic committed
45

46 47 48
    Vehicle*            _vehicle    = nullptr;
    UASInterface*       _uas        = nullptr;
    AutoPilotPlugin*    _autopilot  = nullptr;
dogmaphobic's avatar
dogmaphobic committed
49

50
private:
Don Gagne's avatar
Don Gagne committed
51 52 53
    void _notifyPanelMissingParameter(const QString& missingParam);
    void _notifyPanelErrorMsg(const QString& errorMsg);
    void _showInternalError(const QString& errorMsg);
54

55
    QStringList _delayedMissingParams;
56
};