1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 11:52:40 +01:00
openrw/rwviewer/ArchiveContentsWidget.cpp
2014-02-10 17:22:07 +00:00

27 lines
790 B
C++

#include "ArchiveContentsWidget.hpp"
ArchiveContentsWidget::ArchiveContentsWidget(QWidget* parent, Qt::WindowFlags flags)
: QDockWidget(parent, flags), model(nullptr)
{
setWindowTitle("Archive");
table = new QListView();
setWidget(table);
}
void ArchiveContentsWidget::setArchive(const LoaderIMG& archive)
{
auto m = table->model();
model = new IMGArchiveModel(archive);
table->setModel(model);
delete m;
connect(table->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedIndexChanged(QModelIndex)));
}
void ArchiveContentsWidget::selectedIndexChanged(const QModelIndex& current)
{
if(current.row() < model->getArchive().getAssetCount()) {
auto& f = model->getArchive().getAssetInfoByIndex(current.row());
emit selectedFileChanged(f.name);
}
}