Files
aliendefender/ADeditor/towermodel.cpp
2010-08-25 21:55:42 +04:00

35 lines
667 B
C++

#include "towermodel.h"
TowerModel::TowerModel(QList<tbTower> mtowers, QObject *parent) :
QAbstractListModel(parent)
{
towers = mtowers;
}
void TowerModel::refresh(QList<tbTower> mtowers)
{
towers = mtowers;
}
int TowerModel::rowCount(const QModelIndex &) const
{
return towers.count();
}
QVariant TowerModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= towers.size())
return QVariant();
if (role == Qt::DisplayRole)
{
return towers.at(index.row()).name;
}
return QVariant();
}