APMAirframeComponentController.h 2.62 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, int defaultFrameType, 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(int          defaultFrameType    MEMBER _defaultFrameType    CONSTANT)
    Q_PROPERTY(QString      imageResource       READ imageResource          NOTIFY imageResourceChanged)
    Q_PROPERTY(bool         frameTypeSupported  MEMBER _frameTypeSupported  CONSTANT)

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

    QString _name;
71
    bool    _copter;
72 73 74 75
    QString _imageResource;
    int     _frameClass;
    int     _defaultFrameType;
    bool    _frameTypeSupported;
76

77 78 79
signals:
    void imageResourceChanged(void);
    void frameTypeChanged();
80 81

private:
82
    Fact* _frameTypeFact;
83
};