1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-05 08:37:20 +02:00
openrw/rwviewer/IMGArchiveModel.cpp

42 lines
885 B
C++
Raw Normal View History

2014-02-10 17:21:30 +01:00
#include "IMGArchiveModel.hpp"
2014-02-10 16:34:09 +01:00
2014-02-10 17:21:30 +01:00
QVariant IMGArchiveModel::data(const QModelIndex& index, int role) const
2014-02-10 16:34:09 +01:00
{
if(role == Qt::DisplayRole) {
2014-06-10 18:51:55 +02:00
if(index.row() >= 0 && (unsigned) index.row() < archive.getAssetCount()) {
2014-02-10 16:34:09 +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 17:21:30 +01:00
QVariant IMGArchiveModel::headerData(int section, Qt::Orientation orientation, int role) const
2014-02-10 16:34:09 +01:00
{
if(role == Qt::DisplayRole && orientation == Qt::Horizontal) {
if(section == 0) {
return "Name";
}
if(section == 1) {
return "Size";
}
}
return QVariant::Invalid;
}
2014-02-10 17:21:30 +01:00
int IMGArchiveModel::rowCount(const QModelIndex& parent) const
2014-02-10 16:34:09 +01:00
{
return archive.getAssetCount();
}
2014-02-10 17:21:30 +01:00
int IMGArchiveModel::columnCount(const QModelIndex& parent) const
2014-02-10 16:34:09 +01:00
{
return 2;
}