#pragma once

#include <QGeoCoordinate>
#include <QVector>

#include "GenericWaypointManager.h"
#include "QmlObjectListModel.h"
#include "Settings.h"
#include "AreaInterface.h"

namespace WaypointManager {

typedef GenericWaypointManager<QGeoCoordinate,
                               QVector,
                               QmlObjectListModel,
                               Settings>
        ManagerBase;

class DefaultManager : public ManagerBase
{
public:
    DefaultManager() = delete;
    DefaultManager(Settings &settings,
                   AreaInterface &interface);

    void clear() override;


    virtual bool update() override;
    virtual bool next() override;
    virtual bool previous() override;
    virtual bool reset() override;

protected:
    bool _insertMissionItem(const QGeoCoordinate &c,
                            size_t index,
                            QmlObjectListModel &list,
                            bool doUpdate);
    bool _insertMissionItem(const QGeoCoordinate &c,
                            size_t index,
                            bool doUpdate);
    bool _calcShortestPath(const QGeoCoordinate &start,
                           const QGeoCoordinate &destination,
                           QVector<QGeoCoordinate> &path);

    AreaInterface *_areaInterface;
private:
    bool _worker();

};

} // namespace WaypointManager
