diff --git a/src/file/fileindexerconfig.h b/src/file/fileindexerconfig.h --- a/src/file/fileindexerconfig.h +++ b/src/file/fileindexerconfig.h @@ -82,6 +82,18 @@ */ bool initialUpdateDisabled() const; + /** + * Check if \p folder can be searched taking only + * the includeFolders() into account. + * + * A path can be searched if itself or one of + * its descendants should be indexed. + * + * \return \p true if the \p folder should + * be searched. + */ + bool canBeSearched(const QString& folder) const; + /** * Check if \p path should be indexed taking into account * the includeFolders(), the excludeFolders(), and the diff --git a/src/file/fileindexerconfig.cpp b/src/file/fileindexerconfig.cpp --- a/src/file/fileindexerconfig.cpp +++ b/src/file/fileindexerconfig.cpp @@ -138,6 +138,26 @@ } +bool FileIndexerConfig::canBeSearched(const QString& folder) const +{ + QFileInfo fi(folder); + QString path = fi.absolutePath(); + if (!fi.isDir()) { + return false; + } else if (shouldFolderBeIndexed(path)) { + return true; + } + + // Look for included descendants + for (const QPair& fld: m_folderCache) { + if (fld.second && fld.first.startsWith(path)) { + return true; + } + } + + return false; +} + bool FileIndexerConfig::shouldBeIndexed(const QString& path) const { QFileInfo fi(path);