De-hardcode .index
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
f60562c5a2
commit
22aaf56855
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ExportMrPackDialog.h"
|
#include "ExportMrPackDialog.h"
|
||||||
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
#include "ui_ExportMrPackDialog.h"
|
#include "ui_ExportMrPackDialog.h"
|
||||||
@ -36,32 +37,35 @@ ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent)
|
|||||||
ui->name->setText(instance->name());
|
ui->name->setText(instance->name());
|
||||||
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
||||||
|
|
||||||
auto model = new QFileSystemModel(this);
|
QFileSystemModel* model = new QFileSystemModel(this);
|
||||||
// use the game root - everything outside cannot be exported
|
// use the game root - everything outside cannot be exported
|
||||||
QString root = instance->gameRoot();
|
const QDir root(instance->gameRoot());
|
||||||
proxy = new FileIgnoreProxy(root, this);
|
proxy = new FileIgnoreProxy(instance->gameRoot(), this);
|
||||||
proxy->setSourceModel(model);
|
proxy->setSourceModel(model);
|
||||||
|
|
||||||
QDir::Filters filter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
|
const QDir::Filters filter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
|
||||||
|
|
||||||
for (QString file : QDir(root).entryList(filter)) {
|
for (const QString& file : root.entryList(filter)) {
|
||||||
if (!(file == "mods" || file == "coremods" || file == "datapacks" || file == "config" || file == "options.txt" ||
|
if (!(file == "mods" || file == "coremods" || file == "datapacks" || file == "config" || file == "options.txt" ||
|
||||||
file == "servers.dat"))
|
file == "servers.dat"))
|
||||||
proxy->blockedPaths().insert(file);
|
proxy->blockedPaths().insert(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir modsIndex(instance->gameRoot() + "/mods/.index");
|
MinecraftInstance* mcInstance = dynamic_cast<MinecraftInstance*>(instance.get());
|
||||||
if (modsIndex.exists())
|
if (mcInstance) {
|
||||||
proxy->blockedPaths().insert("mods/.index");
|
const QDir dir = mcInstance->loaderModList()->indexDir();
|
||||||
|
if (dir.exists())
|
||||||
|
proxy->blockedPaths().insert(root.relativeFilePath(dir.absolutePath()));
|
||||||
|
}
|
||||||
|
|
||||||
ui->treeView->setModel(proxy);
|
ui->treeView->setModel(proxy);
|
||||||
ui->treeView->setRootIndex(proxy->mapFromSource(model->index(root)));
|
ui->treeView->setRootIndex(proxy->mapFromSource(model->index(instance->gameRoot())));
|
||||||
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
|
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
model->setFilter(filter);
|
model->setFilter(filter);
|
||||||
model->setRootPath(root);
|
model->setRootPath(instance->gameRoot());
|
||||||
|
|
||||||
auto headerView = ui->treeView->header();
|
QHeaderView* headerView = ui->treeView->header();
|
||||||
headerView->setSectionResizeMode(QHeaderView::ResizeToContents);
|
headerView->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
headerView->setSectionResizeMode(0, QHeaderView::Stretch);
|
headerView->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
}
|
}
|
||||||
@ -100,4 +104,3 @@ void ExportMrPackDialog::done(int result)
|
|||||||
|
|
||||||
QDialog::done(result);
|
QDialog::done(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user