#pragma once

#include <QGeoCoordinate>
#include <QObject>

#include "WimaAreaData.h"
#include "WimaMeasurementArea.h"

class WimaMeasurementAreaData : public WimaAreaData {
  Q_OBJECT

public:
  WimaMeasurementAreaData(QObject *parent = nullptr);
  WimaMeasurementAreaData(const WimaMeasurementAreaData &other,
                          QObject *parent = nullptr);
  WimaMeasurementAreaData(const WimaMeasurementArea &other,
                          QObject *parent = nullptr);
  WimaMeasurementAreaData &operator=(const WimaMeasurementAreaData &other);
  WimaMeasurementAreaData &operator=(const WimaMeasurementArea &other);

  Q_PROPERTY(QmlObjectListModel *tiles READ tiles NOTIFY tileDataChanged)
  Q_PROPERTY(QVector<int> progress READ progress NOTIFY progressChanged)

  virtual QString mapVisualQML() const override;

  bool operator==(const WimaMeasurementAreaData &other) const;
  bool operator!=(const WimaMeasurementAreaData &other) const;

  // Property setters.
  void setTileData(const TileData &d);
  void setProgress(const QVector<int> &d);

  // Property getters.
  QString type() const;
  WimaMeasurementAreaData *Clone() const {
    return new WimaMeasurementAreaData(*this);
  }
  QmlObjectListModel *tiles();
  const QmlObjectListModel *tiles() const;
  const QVariantList &tileCenterPoints() const;
  QVariantList &tileCenterPoints();
  const TileData &tileData() const;
  TileData &tileData();
  const QVector<int> &progress() const;
  QVector<int> &progress();

  static const char *typeString;

signals:
  void tileDataChanged();
  void progressChanged();

protected:
  void assign(const WimaMeasurementAreaData &other);
  void assign(const WimaMeasurementArea &other);

private:
  TileData _tileData;
  QVector<int> _progress;
};

bool operator==(const WimaMeasurementAreaData &m1,
                const WimaMeasurementArea &m2);
bool operator!=(const WimaMeasurementAreaData &m1,
                const WimaMeasurementArea &m2);
bool operator==(const WimaMeasurementArea &m1,
                const WimaMeasurementAreaData &m2);
bool operator!=(const WimaMeasurementArea &m1,
                const WimaMeasurementAreaData &m2);
