#ifndef WIMAFLYAREA_H
#define WIMAFLYAREA_H

#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"

class WimaFlyArea : public QObject
{
    Q_OBJECT
public:
    WimaFlyArea(QObject *parent = nullptr);
    WimaFlyArea(const WimaFlyArea& other, QObject *parent = nullptr);

    const WimaFlyArea& operator=(const WimaFlyArea& other);



    Q_PROPERTY(QmlObjectListModel   *polygons                           READ    polygons                NOTIFY  polygonsChanged)
    Q_PROPERTY(QGCMapPolygon        *currentPolygonItem                 READ    currentPolygonItem      NOTIFY  currentPolygonItemChanged)
    Q_PROPERTY(int                  currentPolygonIndex                 READ    currentPolygonIndex     NOTIFY  currentPolygonIndexChanged)

    Q_INVOKABLE void appendFlyAreaPolygon();
    Q_INVOKABLE void removeFlyAreaPolygon(int index);
    Q_INVOKABLE void setCurrentPolygon(int index);

    //  Property Accessors
    QmlObjectListModel *        polygons                        (void)        { return _polygons;}
    QGCMapPolygon *             currentPolygonItem              (void)        { return _currentPolygonItem;}
    int                         currentPolygonIndex             (void)        { return _currentPolygonIndex;}


    // Methodes
    void _init(void);

signals:
    void polygonsChanged(void);
    void currentPolygonItemChanged(QGCMapPolygon * polygon);
    void currentPolygonIndexChanged(int index);


public slots:

private:



    QmlObjectListModel* _polygons;
    QGCMapPolygon*      _currentPolygonItem;
    int                 _currentPolygonIndex;


};

#endif // WIMAFLYAREA_H
