before ADeditor correct
This commit is contained in:
34
ADeditor/towermodel.cpp
Normal file
34
ADeditor/towermodel.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#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();
|
||||
}
|
||||
Reference in New Issue
Block a user