APMAirframeComponentController.h 3.09 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

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:
Don Gagne's avatar
Don Gagne committed
38 39 40 41
    void _githubJsonDownloadFinished(QString remoteFile, QString localFile);
    void _githubJsonDownloadError(QString errorMsg);
    void _paramFileDownloadFinished(QString remoteFile, QString localFile);
    void _paramFileDownloadError(QString errorMsg);
42 43

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

47 48 49
    Fact*               _frameClassFact;
    Fact*               _frameTypeFact;
    QmlObjectListModel* _frameClassModel;
50 51
};

52
class APMFrameClass : public QObject
53 54 55 56
{
    Q_OBJECT
    
public:
57
    APMFrameClass(const QString& name, bool copter, int frameClass, Fact* frameTypeFact, QObject* parent = nullptr);
58
    ~APMFrameClass();
59
    
60 61 62 63 64 65 66 67 68
    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)
69

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

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

83 84 85
signals:
    void imageResourceChanged(void);
    void frameTypeChanged();
86 87

private:
88
    Fact* _frameTypeFact;
89
};