openrw/rwviewer/models/IMGArchiveModel.cpp

39 lines
1.1 KiB
C++
Raw Normal View History

2014-02-10 16:21:30 +00:00
#include "IMGArchiveModel.hpp"
2014-02-10 15:34:09 +00:00
2016-09-09 21:13:21 +01:00
QVariant IMGArchiveModel::data(const QModelIndex& index, int role) const {
if (role == Qt::DisplayRole) {
if (index.row() >= 0 &&
2018-07-27 22:53:35 +02:00
static_cast<unsigned>(index.row()) < archive.getAssetCount()) {
2016-09-09 21:13:21 +01:00
auto& f = archive.getAssetInfoByIndex(index.row());
if (index.column() == 0) {
return QString(f.name);
}
if (index.column() == 1) {
return f.size;
}
}
}
return QVariant::Invalid;
2014-02-10 15:34:09 +00:00
}
2016-09-09 21:13:21 +01:00
QVariant IMGArchiveModel::headerData(int section, Qt::Orientation orientation,
int role) const {
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
if (section == 0) {
return "Name";
}
if (section == 1) {
return "Size";
}
}
return QVariant::Invalid;
2014-02-10 15:34:09 +00:00
}
int IMGArchiveModel::rowCount(const QModelIndex&) const {
2018-08-30 02:19:38 +02:00
return static_cast<int>(archive.getAssetCount());
2014-02-10 15:34:09 +00:00
}
int IMGArchiveModel::columnCount(const QModelIndex&) const {
2016-09-09 21:13:21 +01:00
return 2;
2014-02-10 15:34:09 +00:00
}