aboutsummaryrefslogtreecommitdiff
path: root/launcher/FileIgnoreProxy.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-07-02 13:14:19 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-07-02 13:14:19 +0300
commit7ac2a23bc8083f0320d73af32f62ad97a407557b (patch)
treefc4004dacb288ebefce9420099cc29f67383d41a /launcher/FileIgnoreProxy.cpp
parentf8adb508ab0152af76829e0fdee92b451dcc1acf (diff)
parentb51f1f1d41a6153c37b1d61a04df8ece5004cc27 (diff)
downloadPrismLauncher-7ac2a23bc8083f0320d73af32f62ad97a407557b.tar.gz
PrismLauncher-7ac2a23bc8083f0320d73af32f62ad97a407557b.tar.bz2
PrismLauncher-7ac2a23bc8083f0320d73af32f62ad97a407557b.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into catpacks
Diffstat (limited to 'launcher/FileIgnoreProxy.cpp')
-rw-r--r--launcher/FileIgnoreProxy.cpp23
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));
+}