RallyPoint.h 1.93 KB
Newer Older
1 2 3 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

#ifndef RallyPoint_H
#define RallyPoint_H

#include <QObject>
#include <QGeoCoordinate>

#include "FactSystem.h"

/// This class is used to encapsulate the QGeoCoordinate associated with a Rally Point into a QObject such
/// that it can be used in a QmlObjectListMode for Qml.
class RallyPoint : public QObject
{
    Q_OBJECT
    
public:
    RallyPoint(const QGeoCoordinate& coordinate, QObject* parent = NULL);
    RallyPoint(const RallyPoint& other, QObject* parent = NULL);

    ~RallyPoint();

    const RallyPoint& operator=(const RallyPoint& other);
    
    Q_PROPERTY(QGeoCoordinate   coordinate      READ coordinate     WRITE setCoordinate     NOTIFY coordinateChanged)
    Q_PROPERTY(bool             dirty           READ dirty          WRITE setDirty          NOTIFY dirtyChanged)
    Q_PROPERTY(QVariantList     textFieldFacts  MEMBER _textFieldFacts                      CONSTANT)

    QGeoCoordinate coordinate(void) const;
    void setCoordinate(const QGeoCoordinate& coordinate);

    bool dirty(void) const { return _dirty; }
    void setDirty(bool dirty);

signals:
    void coordinateChanged      (const QGeoCoordinate& coordinate);
    void dirtyChanged           (bool dirty);

private slots:
    void _sendCoordinateChanged(void);

private:
    void _factSetup(void);

    bool _dirty;
    Fact _longitudeFact;
    Fact _latitudeFact;
    Fact _altitudeFact;

    QVariantList _textFieldFacts;

    static QMap<QString, FactMetaData*> _metaDataMap;

    static const char* _longitudeFactName;
    static const char* _latitudeFactName;
    static const char* _altitudeFactName;
};

#endif