all repos — mgba @ 4c38f769565e8ddd7d3a8eef1a41975206c129a0

mGBA Game Boy Advance Emulator

src/platform/qt/ArchiveInspector.cpp (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "ArchiveInspector.h"
 7
 8extern "C" {
 9#include "util/vfs.h"
10}
11
12using namespace QGBA;
13
14ArchiveInspector::ArchiveInspector(const QString& filename, QWidget* parent)
15	: QDialog(parent)
16{
17	m_ui.setupUi(this);
18	m_dir = VDirOpenArchive(filename.toUtf8().constData());
19	if (m_dir) {
20		m_model.loadDirectory(m_dir);
21	}
22	m_ui.archiveListing->setModel(&m_model);
23}
24
25ArchiveInspector::~ArchiveInspector() {
26	if (m_dir) {
27		m_dir->close(m_dir);
28	}
29}
30
31VFile* ArchiveInspector::selectedVFile() const {
32	QModelIndex index = m_ui.archiveListing->selectionModel()->currentIndex();
33	if (!index.isValid()) {
34		return nullptr;
35	}
36	return m_dir->openFile(m_dir, m_model.entryAt(index.row())->filename, O_RDONLY);
37}