#include "WimaMeasurementAreaData.h"
#include "SnakeTile.h"

const char *WimaMeasurementAreaData::typeString = "WimaMeasurementAreaData";

WimaMeasurementAreaData::WimaMeasurementAreaData(QObject *parent)
    : WimaAreaData(parent) {}

WimaMeasurementAreaData::WimaMeasurementAreaData(
    const WimaMeasurementAreaData &other, QObject *parent)
    : WimaAreaData(parent) {
  *this = other;
}

WimaMeasurementAreaData::WimaMeasurementAreaData(
    const WimaMeasurementArea &other, QObject *parent)
    : WimaAreaData(parent) {
  *this = other;
}

/*!
 * \overload operator=();
 *
 * Assigns \a other to the invoking object.
 */
WimaMeasurementAreaData &WimaMeasurementAreaData::
operator=(const WimaMeasurementAreaData &other) {
  assign(other);

  return *this;
}

/*!
 * \overload operator=();
 *
 * Assigns \a other to the invoking object.
 */
WimaMeasurementAreaData &WimaMeasurementAreaData::
operator=(const WimaMeasurementArea &other) {
  assign(other);

  return *this;
}

QString WimaMeasurementAreaData::type() const { return this->typeString; }

QmlObjectListModel *WimaMeasurementAreaData::tiles() {
  return &this->_tileData.tiles;
}

const QmlObjectListModel *WimaMeasurementAreaData::tiles() const {
  return &this->_tileData.tiles;
}

const QVariantList &WimaMeasurementAreaData::tileCenterPoints() const {
  return this->_tileData.tileCenterPoints;
}

QVariantList &WimaMeasurementAreaData::tileCenterPoints() {
  return this->_tileData.tileCenterPoints;
}

const TileData &WimaMeasurementAreaData::tileData() const {
  return this->_tileData;
}

TileData &WimaMeasurementAreaData::tileData() { return this->_tileData; }

const QVector<int> &WimaMeasurementAreaData::progress() const {
  return this->_progress;
}

QVector<int> &WimaMeasurementAreaData::progress() { return this->_progress; }

void WimaMeasurementAreaData::assign(const WimaMeasurementAreaData &other) {
  WimaAreaData::assign(other);
  this->_tileData = other._tileData;
  this->_progress = other._progress;
}

void WimaMeasurementAreaData::assign(const WimaMeasurementArea &other) {
  WimaAreaData::assign(other);
  if (other.ready()) {
    this->_tileData = other.tileData();
    qWarning() << "WimaMeasurementAreaData: add progress copy here.";
  } else {
    qWarning()
        << "WimaMeasurementAreaData::assign(): WimaMeasurementArea not ready.";
  }
}
