From a3666f283eaf2f89bafbf48479152c156c2c90d1 Mon Sep 17 00:00:00 2001 From: Albert S Date: Tue, 31 May 2022 10:14:39 +0200 Subject: [PATCH] shared: DirscanWorker: Use WildcardMatcher to ignore paths --- shared/dirscanworker.cpp | 15 ++++++++++++--- shared/dirscanworker.h | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/shared/dirscanworker.cpp b/shared/dirscanworker.cpp index 1ab97c1..8659231 100644 --- a/shared/dirscanworker.cpp +++ b/shared/dirscanworker.cpp @@ -7,7 +7,7 @@ DirScanWorker::DirScanWorker(ConcurrentQueue &queue, ConcurrentQueuequeue = &queue; this->resultQueue = &resultQueue; - this->ignorePattern = ignorePattern; + this->wildcardMatcher.setPatterns(ignorePattern); this->progressReportThreshold = progressReportThreshold; this->stopToken = &stopToken; setAutoDelete(false); @@ -24,10 +24,19 @@ void DirScanWorker::run() start new DirScanWorkers ourselves here... */ while(queue->dequeue(path)) { - QDirIterator iterator(path, ignorePattern, QDir::Files, QDirIterator::Subdirectories); + if(wildcardMatcher.match(path)) + { + continue; + } + QDirIterator iterator(path, QStringList{}, QDir::Files, QDirIterator::Subdirectories); while(iterator.hasNext()) { - this->results.append(iterator.next()); + QString entry = iterator.next(); + if(wildcardMatcher.match(entry)) + { + continue; + } + this->results.append(entry); ++currentProgress; if(currentProgress == progressReportThreshold) { diff --git a/shared/dirscanworker.h b/shared/dirscanworker.h index 213ec7d..cf76ee7 100644 --- a/shared/dirscanworker.h +++ b/shared/dirscanworker.h @@ -4,6 +4,7 @@ #include #include #include "concurrentqueue.h" +#include "wildcardmatcher.h" class DirScanWorker : public QObject, public QRunnable { Q_OBJECT @@ -12,7 +13,7 @@ class DirScanWorker : public QObject, public QRunnable ConcurrentQueue *queue = nullptr; ConcurrentQueue *resultQueue = nullptr; - QStringList ignorePattern; + WildcardMatcher wildcardMatcher; QVector results; std::atomic *stopToken;