RallyPointController.h 3.31 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#ifndef RallyPointController_H
#define RallyPointController_H

#include "PlanElementController.h"
#include "RallyPointManager.h"
#include "Vehicle.h"
#include "MultiVehicleManager.h"
#include "QGCLoggingCategory.h"
#include "QmlObjectListModel.h"

Q_DECLARE_LOGGING_CATEGORY(RallyPointControllerLog)

class GeoFenceManager;

class RallyPointController : public PlanElementController
{
    Q_OBJECT
    
public:
29
    RallyPointController(PlanMasterController* masterController, QObject* parent = nullptr);
30 31 32 33 34 35
    ~RallyPointController();
    
    Q_PROPERTY(QmlObjectListModel*  points                  READ points                                             CONSTANT)
    Q_PROPERTY(QString              editorQml               READ editorQml                                          CONSTANT)
    Q_PROPERTY(QObject*             currentRallyPoint       READ currentRallyPoint      WRITE setCurrentRallyPoint  NOTIFY currentRallyPointChanged)

Gus Grubba's avatar
Gus Grubba committed
36 37
    Q_INVOKABLE void addPoint       (QGeoCoordinate point);
    Q_INVOKABLE void removePoint    (QObject* rallyPoint);
38

39
    void start                      (bool flyView) final;
40
    bool supported                  (void) const final;
DonLakeFlyer's avatar
DonLakeFlyer committed
41 42 43 44 45 46 47 48 49 50 51
    void save                       (QJsonObject& json) final;
    bool load                       (const QJsonObject& json, QString& errorString) final;
    void loadFromVehicle            (void) final;
    void sendToVehicle              (void) final;
    void removeAll                  (void) final;
    void removeAllFromVehicle       (void) final;
    bool syncInProgress             (void) const final;
    bool dirty                      (void) const final { return _dirty; }
    void setDirty                   (bool dirty) final;
    bool containsItems              (void) const final;
    bool showPlanFromManagerVehicle (void) final;
52 53 54 55 56

    QmlObjectListModel* points                  (void) { return &_points; }
    QString             editorQml               (void) const;
    QObject*            currentRallyPoint       (void) const { return _currentRallyPoint; }

57 58
    void setCurrentRallyPoint   (QObject* rallyPoint);
    bool isEmpty                (void) const;
59 60 61

signals:
    void currentRallyPointChanged(QObject* rallyPoint);
Don Gagne's avatar
Don Gagne committed
62
    void loadComplete(void);
63 64

private slots:
65 66 67 68 69 70
    void _managerLoadComplete       (void);
    void _managerSendComplete       (bool error);
    void _managerRemoveAllComplete  (bool error);
    void _setFirstPointCurrent      (void);
    void _updateContainsItems       (void);
    void _managerVehicleChanged     (Vehicle* managerVehicle);
71 72

private:
73 74 75
    Vehicle*            _managerVehicle =       nullptr;
    RallyPointManager*  _rallyPointManager =    nullptr;
    bool                _dirty =                false;
76
    QmlObjectListModel  _points;
77 78
    QObject*            _currentRallyPoint =    nullptr;
    bool                _itemsRequested =       false;
79

80 81 82
    static const int    _jsonCurrentVersion = 2;
    static const char*  _jsonFileTypeValue;
    static const char*  _jsonPointsKey;
83 84 85
};

#endif