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

10
#pragma once
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

#include <QObject>
#include <QQuickItem>
#include <QList>
#include <QAbstractListModel>

#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"

class APMAirframeModel;
class APMAirframeType;

/// MVC Controller for APMAirframeComponent.qml.
class APMAirframeComponentController : public FactPanelController
{
    Q_OBJECT
    
public:
    APMAirframeComponentController(void);
    ~APMAirframeComponentController();
    
33
    Q_PROPERTY(QmlObjectListModel*  frameClassModel     MEMBER _frameClassModel CONSTANT)
Don Gagne's avatar
Don Gagne committed
34 35

    Q_INVOKABLE void loadParameters(const QString& paramFile);
36 37

private slots:
38 39
    void _githubJsonDownloadComplete(QString remoteFile, QString localFile, QString errorMsg);
    void _paramFileDownloadComplete(QString remoteFile, QString localFile, QString errorMsg);
40 41

private:
42
    void _fillFrameClasses(void);
Don Gagne's avatar
Don Gagne committed
43 44
    void _loadParametersFromDownloadFile(const QString& downloadedParamFile);

45 46 47
    Fact*               _frameClassFact;
    Fact*               _frameTypeFact;
    QmlObjectListModel* _frameClassModel;
48 49
};

50
class APMFrameClass : public QObject
51 52 53 54
{
    Q_OBJECT
    
public:
55 56
    APMFrameClass(const QString& name, bool copter, int frameClass, Fact* frameTypeFact, QObject* parent = nullptr);
    ~APMFrameClass();
57
    
58 59 60 61 62 63 64 65 66 67 68 69
    Q_PROPERTY(QString      name                    MEMBER _name                    CONSTANT)
    Q_PROPERTY(int          frameClass              MEMBER _frameClass              CONSTANT)
    Q_PROPERTY(int          frameType               READ   frameType                NOTIFY frameTypeChanged)
    Q_PROPERTY(QStringList  frameTypeEnumStrings    MEMBER _frameTypeEnumStrings    CONSTANT)
    Q_PROPERTY(QVariantList frameTypeEnumValues     MEMBER _frameTypeEnumValues     CONSTANT)
    Q_PROPERTY(int          defaultFrameType        MEMBER _defaultFrameType        CONSTANT)
    Q_PROPERTY(QString      imageResource           READ   imageResource            NOTIFY imageResourceChanged)
    Q_PROPERTY(QString      imageResourceDefault    MEMBER _imageResourceDefault    CONSTANT)
    Q_PROPERTY(bool         frameTypeSupported      MEMBER _frameTypeSupported      CONSTANT)

    int     frameType       (void) { return _frameTypeFact->rawValue().toInt(); }
    QString imageResource   (void);
70

71 72 73 74 75 76 77 78 79
    QString         _name;
    bool            _copter;
    QString         _imageResource;
    QString         _imageResourceDefault;
    int             _frameClass;
    QStringList     _frameTypeEnumStrings;
    QVariantList    _frameTypeEnumValues;
    int             _defaultFrameType;
    bool            _frameTypeSupported;
80

81 82 83
signals:
    void imageResourceChanged(void);
    void frameTypeChanged();
84 85

private:
86
    Fact* _frameTypeFact;
87
};