diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-02 12:50:45 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-02 12:50:45 +0300 |
commit | 6c4cf085e028a76dd6c0fb4d9649783b3d97aefd (patch) | |
tree | 859e8a0a8a5fb44fc58c1c18130bad6b9c723e46 /launcher/FileIgnoreProxy.cpp | |
parent | 87155e346c33288fccb68c3b9029a11b658395b2 (diff) | |
parent | b51f1f1d41a6153c37b1d61a04df8ece5004cc27 (diff) | |
download | PrismLauncher-6c4cf085e028a76dd6c0fb4d9649783b3d97aefd.tar.gz PrismLauncher-6c4cf085e028a76dd6c0fb4d9649783b3d97aefd.tar.bz2 PrismLauncher-6c4cf085e028a76dd6c0fb4d9649783b3d97aefd.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into curse
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/FileIgnoreProxy.cpp')
-rw-r--r-- | launcher/FileIgnoreProxy.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/launcher/FileIgnoreProxy.cpp b/launcher/FileIgnoreProxy.cpp index a3b7d505..4c8c64c7 100644 --- a/launcher/FileIgnoreProxy.cpp +++ b/launcher/FileIgnoreProxy.cpp @@ -40,6 +40,7 @@ #include <QFileSystemModel> #include <QSortFilterProxyModel> #include <QStack> +#include <algorithm> #include "FileSystem.h" #include "SeparatorPrefixTree.h" #include "StringUtils.h" @@ -254,3 +255,25 @@ bool FileIgnoreProxy::filterAcceptsColumn(int source_column, const QModelIndex& 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); + return !ignoreFile(fileInfo); +} + +bool FileIgnoreProxy::ignoreFile(QFileInfo fileInfo) const +{ + auto fileName = fileInfo.fileName(); + auto path = relPath(fileInfo.absoluteFilePath()); + return std::any_of(m_ignoreFiles.cbegin(), m_ignoreFiles.cend(), [fileName](auto iFileName) { return fileName == iFileName; }) || + m_ignoreFilePaths.covers(path); +} + +bool FileIgnoreProxy::filterFile(const QString& fileName) const +{ + return blocked.covers(fileName) || ignoreFile(QFileInfo(QDir(root), fileName)); +} |