mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#include "IMGArchiveModel.hpp"
|
|
|
|
QVariant IMGArchiveModel::data(const QModelIndex& index, int role) const {
|
|
if (role == Qt::DisplayRole) {
|
|
if (index.row() >= 0 &&
|
|
static_cast<unsigned>(index.row()) < archive.getAssetCount()) {
|
|
auto& f = archive.getAssetInfoByIndex(index.row());
|
|
if (index.column() == 0) {
|
|
return QString(f.name);
|
|
}
|
|
if (index.column() == 1) {
|
|
return f.size;
|
|
}
|
|
}
|
|
}
|
|
return QVariant::Invalid;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
int IMGArchiveModel::rowCount(const QModelIndex&) const {
|
|
return static_cast<int>(archive.getAssetCount());
|
|
}
|
|
|
|
int IMGArchiveModel::columnCount(const QModelIndex&) const {
|
|
return 2;
|
|
}
|