all repos — mgba @ c11551a1f7809c4f434230fb18b624f6cddea062

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
 8#include <mgba-util/vfs.h>
 9
10using namespace QGBA;
11
12ArchiveInspector::ArchiveInspector(const QString& filename, QWidget* parent)
13	: QDialog(parent)
14{
15	m_ui.setupUi(this);
16	m_dir = VDirOpenArchive(filename.toUtf8().constData());
17	if (m_dir) {
18		m_model.loadDirectory(m_dir);
19	}
20	m_ui.archiveListing->setModel(&m_model);
21}
22
23ArchiveInspector::~ArchiveInspector() {
24	if (m_dir) {
25		m_dir->close(m_dir);
26	}
27}
28
29VFile* ArchiveInspector::selectedVFile() const {
30	QModelIndex index = m_ui.archiveListing->selectionModel()->currentIndex();
31	if (!index.isValid()) {
32		return nullptr;
33	}
34	return m_dir->openFile(m_dir, m_model.entryAt(index.row())->filename, O_RDONLY);
35}