Removed logs from instance export
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
faec21d572
commit
87efa700ab
@ -40,6 +40,7 @@
|
|||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
|
#include <algorithm>
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "SeparatorPrefixTree.h"
|
#include "SeparatorPrefixTree.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
@ -254,3 +255,16 @@ bool FileIgnoreProxy::filterAcceptsColumn(int source_column, const QModelIndex&
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileIgnoreProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||||
|
{
|
||||||
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
|
QFileSystemModel* fsm = qobject_cast<QFileSystemModel*>(sourceModel());
|
||||||
|
|
||||||
|
auto fileInfo = fsm->fileInfo(index);
|
||||||
|
auto fileName = fileInfo.fileName();
|
||||||
|
auto path = relPath(fileInfo.absoluteFilePath());
|
||||||
|
return !(path.startsWith("..") || // just in case ignore files outside the gameroot
|
||||||
|
std::any_of(m_ignoreFiles.cbegin(), m_ignoreFiles.cend(), [fileName](auto iFileName) { return fileName == iFileName; }) ||
|
||||||
|
std::any_of(m_ignoreFilePaths.cbegin(), m_ignoreFilePaths.cend(), [path](auto iPath) { return path == iPath; }));
|
||||||
|
}
|
||||||
|
@ -63,10 +63,18 @@ class FileIgnoreProxy : public QSortFilterProxyModel {
|
|||||||
inline const SeparatorPrefixTree<'/'>& blockedPaths() const { return blocked; }
|
inline const SeparatorPrefixTree<'/'>& blockedPaths() const { return blocked; }
|
||||||
inline SeparatorPrefixTree<'/'>& blockedPaths() { return blocked; }
|
inline SeparatorPrefixTree<'/'>& blockedPaths() { return blocked; }
|
||||||
|
|
||||||
|
// list of file names that need to be removed completely from model
|
||||||
|
inline QStringList& ignoreFilesWithName() { return m_ignoreFiles; }
|
||||||
|
// list of relative paths that need to be removed completely from model
|
||||||
|
inline QStringList& ignoreFilesWithPath() { return m_ignoreFilePaths; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const;
|
bool filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const;
|
||||||
|
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString root;
|
const QString root;
|
||||||
SeparatorPrefixTree<'/'> blocked;
|
SeparatorPrefixTree<'/'> blocked;
|
||||||
|
QStringList m_ignoreFiles;
|
||||||
|
QStringList m_ignoreFilePaths;
|
||||||
};
|
};
|
||||||
|
@ -35,22 +35,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ExportInstanceDialog.h"
|
#include "ExportInstanceDialog.h"
|
||||||
#include "ui_ExportInstanceDialog.h"
|
|
||||||
#include <BaseInstance.h>
|
#include <BaseInstance.h>
|
||||||
#include <MMCZip.h>
|
#include <MMCZip.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include "ui_ExportInstanceDialog.h"
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QSaveFile>
|
|
||||||
#include <QStack>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include "SeparatorPrefixTree.h"
|
|
||||||
#include "Application.h"
|
|
||||||
#include <icons/IconList.h>
|
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
|
#include <icons/IconList.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QSaveFile>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QStack>
|
||||||
|
#include "Application.h"
|
||||||
|
#include "SeparatorPrefixTree.h"
|
||||||
|
|
||||||
ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent)
|
ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent)
|
||||||
: QDialog(parent), ui(new Ui::ExportInstanceDialog), m_instance(instance)
|
: QDialog(parent), ui(new Ui::ExportInstanceDialog), m_instance(instance)
|
||||||
@ -60,8 +60,12 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget *parent
|
|||||||
model->setIconProvider(&icons);
|
model->setIconProvider(&icons);
|
||||||
auto root = instance->instanceRoot();
|
auto root = instance->instanceRoot();
|
||||||
proxyModel = new FileIgnoreProxy(root, this);
|
proxyModel = new FileIgnoreProxy(root, this);
|
||||||
loadPackIgnore();
|
|
||||||
proxyModel->setSourceModel(model);
|
proxyModel->setSourceModel(model);
|
||||||
|
auto prefix = QDir(instance->instanceRoot()).relativeFilePath(instance->gameRoot());
|
||||||
|
proxyModel->ignoreFilesWithPath().append({ FS::PathCombine(prefix, "logs"), FS::PathCombine(prefix, "crash-reports") });
|
||||||
|
proxyModel->ignoreFilesWithName().append({ ".DS_Store", "thumbs.db", "Thumbs.db" });
|
||||||
|
loadPackIgnore();
|
||||||
|
|
||||||
ui->treeView->setModel(proxyModel);
|
ui->treeView->setModel(proxyModel);
|
||||||
ui->treeView->setRootIndex(proxyModel->mapFromSource(model->index(root)));
|
ui->treeView->setRootIndex(proxyModel->mapFromSource(model->index(root)));
|
||||||
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
|
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
@ -52,8 +52,9 @@ ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent)
|
|||||||
// use the game root - everything outside cannot be exported
|
// use the game root - everything outside cannot be exported
|
||||||
const QDir root(instance->gameRoot());
|
const QDir root(instance->gameRoot());
|
||||||
proxy = new FileIgnoreProxy(instance->gameRoot(), this);
|
proxy = new FileIgnoreProxy(instance->gameRoot(), this);
|
||||||
|
proxy->ignoreFilesWithPath().append({ "logs", "crash-reports" });
|
||||||
|
proxy->ignoreFilesWithName().append({ ".DS_Store", "thumbs.db", "Thumbs.db" });
|
||||||
proxy->setSourceModel(model);
|
proxy->setSourceModel(model);
|
||||||
proxy->setFilterRegularExpression("^(?!(\\.DS_Store)|([tT]humbs\\.db)).+$");
|
|
||||||
|
|
||||||
const QDir::Filters filter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
|
const QDir::Filters filter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user