mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-23 04:27: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
|
||||
|
||||
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 columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
@ -47,6 +47,6 @@ private:
|
|||
|
||||
QHash<uint32_t, TreeInformation *> knownDirHashes;
|
||||
|
||||
HashDatabase m_database;
|
||||
HashDatabase &m_database;
|
||||
bool m_showUnknown = false;
|
||||
};
|
|
@ -14,7 +14,7 @@ class FileTreeWindow : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
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:
|
||||
void extractFile(const QString &path);
|
||||
|
@ -28,4 +28,5 @@ private:
|
|||
QSortFilterProxyModel *m_searchModel = nullptr;
|
||||
QCheckBox *m_unknownCheckbox = nullptr;
|
||||
QString m_gamePath;
|
||||
HashDatabase &m_database;
|
||||
};
|
|
@ -16,6 +16,7 @@ public:
|
|||
|
||||
void addFolder(const QString &folder);
|
||||
void addFile(const QString &file);
|
||||
void importFileList(const QString &path);
|
||||
|
||||
QVector<QString> getKnownFolders();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QTreeWidget>
|
||||
|
||||
#include "filecache.h"
|
||||
#include "hashdatabase.h"
|
||||
#include "novusmainwindow.h"
|
||||
|
||||
struct GameData;
|
||||
|
@ -17,10 +18,14 @@ class MainWindow : public NovusMainWindow
|
|||
public:
|
||||
MainWindow(const QString &gamePath, GameData *data);
|
||||
|
||||
protected:
|
||||
void setupFileMenu(QMenu *menu) override;
|
||||
|
||||
private:
|
||||
GameData *data = nullptr;
|
||||
QTabWidget *partHolder = nullptr;
|
||||
FileCache fileCache;
|
||||
HashDatabase m_database;
|
||||
|
||||
void refreshParts(const QString &path);
|
||||
};
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
#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)
|
||||
, gameData(data)
|
||||
, m_showUnknown(showUnknown)
|
||||
, m_database(database)
|
||||
{
|
||||
rootItem = new TreeInformation();
|
||||
rootItem->type = TreeType::Root;
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
#include <QMenu>
|
||||
#include <QTreeWidget>
|
||||
|
||||
FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent)
|
||||
FileTreeWindow::FileTreeWindow(HashDatabase &database, const QString &gamePath, GameData *data, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, data(data)
|
||||
, m_gamePath(gamePath)
|
||||
, m_database(database)
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
@ -74,7 +75,7 @@ FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget
|
|||
void FileTreeWindow::refreshModel()
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "hashdatabase.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QSqlError>
|
||||
#include <physis.hpp>
|
||||
|
||||
|
@ -93,4 +94,15 @@ QString HashDatabase::getFilename(const uint32_t i)
|
|||
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"
|
|
@ -34,7 +34,7 @@ MainWindow::MainWindow(const QString &gamePath, GameData *data)
|
|||
auto layout = new QHBoxLayout();
|
||||
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) {
|
||||
const QFileInfo info(path);
|
||||
|
||||
|
@ -89,7 +89,7 @@ void MainWindow::refreshParts(const QString &path)
|
|||
partHolder->addTab(exdWidget, QStringLiteral("Note"));
|
||||
} else if (info.completeSuffix() == QStringLiteral("mdl")) {
|
||||
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"));
|
||||
} else if (info.completeSuffix() == QStringLiteral("tex") || info.completeSuffix() == QStringLiteral("atex")) {
|
||||
auto texWidget = new TexPart(data);
|
||||
|
@ -116,3 +116,14 @@ void MainWindow::refreshParts(const QString &path)
|
|||
auto propertiesWidget = new FilePropertiesWindow(path, file);
|
||||
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