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
10#include "ConfigController.h"
11
12using namespace QGBA;
13
14ArchiveInspector::ArchiveInspector(const QString& filename, QWidget* parent)
15 : QDialog(parent)
16 , m_model(ConfigController::configDir() + "/library.sqlite3")
17{
18 m_ui.setupUi(this);
19 connect(&m_model, &LibraryModel::doneLoading, [this]() {
20 m_ui.loading->hide();
21 });
22 m_model.loadDirectory(filename);
23 m_model.constrainBase(filename);
24 m_ui.archiveListing->setModel(&m_model);
25}
26
27VFile* ArchiveInspector::selectedVFile() const {
28 QModelIndex index = m_ui.archiveListing->selectionModel()->currentIndex();
29 if (!index.isValid()) {
30 return nullptr;
31 }
32 return m_model.openVFile(index);
33}