#include "tycho.h"

MapModel::MapModel(Project *parent) :
   AbstractMapModel(static_cast<QWidget *>(parent)),
   ProjectModel()
{
   dbgPrintFunc();
}

MapModel::~MapModel()
{
   dbgPrintFunc();
}

bool MapModel::isDirty() const
{
   return AbstractMapModel::isDirty();
}

bool MapModel::open(QString const &path)
{
   return AbstractMapModel::open(path);
}

bool MapModel::save() const
{
   return AbstractMapModel::save();
}

bool MapModel::saveAs(QString const &path) const
{
   return AbstractMapModel::saveAs(path);
}

void MapModel::deselect()
{
   AbstractMapModel::deselect();

   emit deselected();
}

void MapModel::select(QModelIndex const &index)
{
   auto idx = index.internalId();

   AbstractMapModel::select(idx);

   emit selected(idx);
}

QVariant MapModel::data(const QModelIndex &index, int role) const
{
   switch(role) {
      case Qt::DecorationRole: {
         auto name = propIcon(index.row());
         auto icon = name.front() == ':' ? QIcon(name)
                                         : QIcon::fromTheme(name);
         return QVariant::fromValue(icon);
      }
      default:
         return AbstractMapModel::data(index, role);
   }
}

// EOF
