mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-23 12:37:45 +00:00
sagasu: Add support for importing path lists
This isn't finished yet, importing large lists is way too slow.
This commit is contained in:
parent
74bee7fd4e
commit
11a63345aa
8 changed files with 40 additions and 8 deletions
|
@ -26,7 +26,7 @@ class FileTreeModel : public QAbstractItemModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FileTreeModel(bool showUnknown, const QString &gamePath, GameData *data, QObject *parent = nullptr);
|
explicit FileTreeModel(HashDatabase &database, bool showUnknown, const QString &gamePath, GameData *data, QObject *parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
@ -47,6 +47,6 @@ private:
|
||||||
|
|
||||||
QHash<uint32_t, TreeInformation *> knownDirHashes;
|
QHash<uint32_t, TreeInformation *> knownDirHashes;
|
||||||
|
|
||||||
HashDatabase m_database;
|
HashDatabase &m_database;
|
||||||
bool m_showUnknown = false;
|
bool m_showUnknown = false;
|
||||||
};
|
};
|
|
@ -14,7 +14,7 @@ class FileTreeWindow : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent = nullptr);
|
explicit FileTreeWindow(HashDatabase &database, const QString &gamePath, GameData *data, QWidget *parent = nullptr);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void extractFile(const QString &path);
|
void extractFile(const QString &path);
|
||||||
|
@ -28,4 +28,5 @@ private:
|
||||||
QSortFilterProxyModel *m_searchModel = nullptr;
|
QSortFilterProxyModel *m_searchModel = nullptr;
|
||||||
QCheckBox *m_unknownCheckbox = nullptr;
|
QCheckBox *m_unknownCheckbox = nullptr;
|
||||||
QString m_gamePath;
|
QString m_gamePath;
|
||||||
|
HashDatabase &m_database;
|
||||||
};
|
};
|
|
@ -16,6 +16,7 @@ public:
|
||||||
|
|
||||||
void addFolder(const QString &folder);
|
void addFolder(const QString &folder);
|
||||||
void addFile(const QString &file);
|
void addFile(const QString &file);
|
||||||
|
void importFileList(const QString &path);
|
||||||
|
|
||||||
QVector<QString> getKnownFolders();
|
QVector<QString> getKnownFolders();
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
#include "filecache.h"
|
#include "filecache.h"
|
||||||
|
#include "hashdatabase.h"
|
||||||
#include "novusmainwindow.h"
|
#include "novusmainwindow.h"
|
||||||
|
|
||||||
struct GameData;
|
struct GameData;
|
||||||
|
@ -17,10 +18,14 @@ class MainWindow : public NovusMainWindow
|
||||||
public:
|
public:
|
||||||
MainWindow(const QString &gamePath, GameData *data);
|
MainWindow(const QString &gamePath, GameData *data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setupFileMenu(QMenu *menu) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameData *data = nullptr;
|
GameData *data = nullptr;
|
||||||
QTabWidget *partHolder = nullptr;
|
QTabWidget *partHolder = nullptr;
|
||||||
FileCache fileCache;
|
FileCache fileCache;
|
||||||
|
HashDatabase m_database;
|
||||||
|
|
||||||
void refreshParts(const QString &path);
|
void refreshParts(const QString &path);
|
||||||
};
|
};
|
|
@ -6,10 +6,11 @@
|
||||||
|
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
FileTreeModel::FileTreeModel(bool showUnknown, const QString &gamePath, GameData *data, QObject *parent)
|
FileTreeModel::FileTreeModel(HashDatabase &database, bool showUnknown, const QString &gamePath, GameData *data, QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
, gameData(data)
|
, gameData(data)
|
||||||
, m_showUnknown(showUnknown)
|
, m_showUnknown(showUnknown)
|
||||||
|
, m_database(database)
|
||||||
{
|
{
|
||||||
rootItem = new TreeInformation();
|
rootItem = new TreeInformation();
|
||||||
rootItem->type = TreeType::Root;
|
rootItem->type = TreeType::Root;
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent)
|
FileTreeWindow::FileTreeWindow(HashDatabase &database, const QString &gamePath, GameData *data, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, data(data)
|
, data(data)
|
||||||
, m_gamePath(gamePath)
|
, m_gamePath(gamePath)
|
||||||
|
, m_database(database)
|
||||||
{
|
{
|
||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -74,7 +75,7 @@ FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget
|
||||||
void FileTreeWindow::refreshModel()
|
void FileTreeWindow::refreshModel()
|
||||||
{
|
{
|
||||||
// TODO: this should really be handled by the proxy
|
// TODO: this should really be handled by the proxy
|
||||||
m_fileModel = new FileTreeModel(m_unknownCheckbox->isChecked(), m_gamePath, data);
|
m_fileModel = new FileTreeModel(m_database, m_unknownCheckbox->isChecked(), m_gamePath, data);
|
||||||
m_searchModel->setSourceModel(m_fileModel);
|
m_searchModel->setSourceModel(m_fileModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "hashdatabase.h"
|
#include "hashdatabase.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <physis.hpp>
|
#include <physis.hpp>
|
||||||
|
|
||||||
|
@ -93,4 +94,15 @@ QString HashDatabase::getFilename(const uint32_t i)
|
||||||
return query.value(0).toString();
|
return query.value(0).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HashDatabase::importFileList(const QString &path)
|
||||||
|
{
|
||||||
|
QFile file(path);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QTextStream stream(&file);
|
||||||
|
while (!stream.atEnd()) {
|
||||||
|
addFile(stream.readLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_hashdatabase.cpp"
|
#include "moc_hashdatabase.cpp"
|
|
@ -34,7 +34,7 @@ MainWindow::MainWindow(const QString &gamePath, GameData *data)
|
||||||
auto layout = new QHBoxLayout();
|
auto layout = new QHBoxLayout();
|
||||||
dummyWidget->setLayout(layout);
|
dummyWidget->setLayout(layout);
|
||||||
|
|
||||||
auto tree = new FileTreeWindow(gamePath, data);
|
auto tree = new FileTreeWindow(m_database, gamePath, data);
|
||||||
connect(tree, &FileTreeWindow::extractFile, this, [this, data](const QString &path) {
|
connect(tree, &FileTreeWindow::extractFile, this, [this, data](const QString &path) {
|
||||||
const QFileInfo info(path);
|
const QFileInfo info(path);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void MainWindow::refreshParts(const QString &path)
|
||||||
partHolder->addTab(exdWidget, QStringLiteral("Note"));
|
partHolder->addTab(exdWidget, QStringLiteral("Note"));
|
||||||
} else if (info.completeSuffix() == QStringLiteral("mdl")) {
|
} else if (info.completeSuffix() == QStringLiteral("mdl")) {
|
||||||
auto mdlWidget = new MDLPart(data, fileCache);
|
auto mdlWidget = new MDLPart(data, fileCache);
|
||||||
mdlWidget->addModel(physis_mdl_parse(file), QStringLiteral("mdl"), {}, 0);
|
mdlWidget->addModel(physis_mdl_parse(file), glm::vec3(), QStringLiteral("mdl"), {}, 0);
|
||||||
partHolder->addTab(mdlWidget, QStringLiteral("Model"));
|
partHolder->addTab(mdlWidget, QStringLiteral("Model"));
|
||||||
} else if (info.completeSuffix() == QStringLiteral("tex") || info.completeSuffix() == QStringLiteral("atex")) {
|
} else if (info.completeSuffix() == QStringLiteral("tex") || info.completeSuffix() == QStringLiteral("atex")) {
|
||||||
auto texWidget = new TexPart(data);
|
auto texWidget = new TexPart(data);
|
||||||
|
@ -116,3 +116,14 @@ void MainWindow::refreshParts(const QString &path)
|
||||||
auto propertiesWidget = new FilePropertiesWindow(path, file);
|
auto propertiesWidget = new FilePropertiesWindow(path, file);
|
||||||
partHolder->addTab(propertiesWidget, QStringLiteral("Properties"));
|
partHolder->addTab(propertiesWidget, QStringLiteral("Properties"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupFileMenu(QMenu *menu)
|
||||||
|
{
|
||||||
|
auto openList = menu->addAction(QStringLiteral("Import path list..."));
|
||||||
|
openList->setIcon(QIcon::fromTheme(QStringLiteral("document-open")));
|
||||||
|
connect(openList, &QAction::triggered, [this] {
|
||||||
|
auto fileName = QFileDialog::getOpenFileName(nullptr, QStringLiteral("Open Path List"), QStringLiteral("~"));
|
||||||
|
|
||||||
|
m_database.importFileList(fileName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue