#include "mapmodel.h"

MapModel::MapModel(QList <tbMap> mmaps, QObject *parent) :
    QAbstractListModel(parent)
{
	maps = mmaps;
}


void MapModel::refresh(QList <tbMap> mmaps)
{
	maps = mmaps;
}


int MapModel::rowCount(const QModelIndex &) const
{
		return maps.count();
}


QVariant MapModel::data(const QModelIndex &index, int role) const
{
		if (!index.isValid())
				return QVariant();

		if (index.row() >= maps.size())
				return QVariant();

		if (role == Qt::DisplayRole)
		{
				return maps.at(index.row()).name;
		}
		return QVariant();
}
