#pragma once

#include "WimaArea.h"
#include "WimaTrackerPolyline.h"
#include <QObject>

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

  Q_PROPERTY(QGeoCoordinate depot READ depot WRITE setDepot NOTIFY depotChanged)

  // Overrides from WimaPolygon
  QString mapVisualQML(void) const { return "WimaServiceAreaMapVisual.qml"; }
  QString editorQML(void) const { return "WimaServiceAreaEditor.qml"; }

  // Property acessors
  const QGeoCoordinate &depot(void) const { return _depot; }

  // Member Methodes
  void saveToJson(QJsonObject &json);
  bool loadFromJson(const QJsonObject &json, QString &errorString);

  // Friends
  friend void print(const WimaServiceArea &area, QString &outputStr);
  friend void print(const WimaServiceArea &area);

  // static Members
  static const char *wimaServiceAreaName;
  static const char *depotLatitudeName;
  static const char *depotLongitudeName;
  static const char *depotAltitudeName;
signals:
  void depotChanged(void);

public slots:
  bool setDepot(const QGeoCoordinate &coordinate);

private:
  // Member Methodes
  void init();

  // Members
  QGeoCoordinate _depot;
};
