#include "common.h" #include "quam/main_window.h" #include "quam/pak.h" #include #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow{parent}, Ui::MainWindow{}, m_directory{}, m_errors{new QErrorMessage{this}}, m_model{nullptr}, m_sorter{nullptr} { setupUi(this); actionClose->setShortcut(QKeySequence{QKeySequence::Close}); actionOpen->setShortcut(QKeySequence{QKeySequence::Open}); actionQuit->setShortcut(QKeySequence{QKeySequence::Quit}); tableView->sortByColumn(Pak::ColumnSize, Qt::AscendingOrder); tableView->resizeColumnsToContents(); } MainWindow::~MainWindow() { } void MainWindow::fileOpen() { auto fileName = QFileDialog::getOpenFileName( this, tr("Open Archive"), QString{}, tr("Quake PACK file (*.pak);;" "Quake WAD2 file (*.wad);;" "All files (*)")); if(!fileName.isEmpty()) { try { auto st = openReadBin(fileName.toStdString()); m_directory = readPak(st); m_model = new PakDirModel{&m_directory, this}; m_sorter = new PakDirModelSorter{m_model}; m_sorter->setSourceModel(m_model); tableView->setModel(m_sorter); } catch(std::exception const &exc) { m_errors->showMessage(tr(exc.what())); } } } void MainWindow::fileClose() { tableView->setModel(nullptr); delete m_sorter; delete m_model; m_directory = PakDir{}; } // EOF