Changeset View
Changeset View
Standalone View
Standalone View
src/file/filtereddiriterator.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #include "filtereddiriterator.h" | 20 | #include "filtereddiriterator.h" | ||
21 | #include "fileindexerconfig.h" | 21 | #include "fileindexerconfig.h" | ||
22 | 22 | | |||
23 | #include <QFileInfo> | 23 | #include <QFileInfo> | ||
24 | 24 | | |||
25 | using namespace Baloo; | 25 | using namespace Baloo; | ||
26 | 26 | | |||
27 | QString skipTrailingSlash(const QString& folder) | ||||
28 | { | ||||
29 | QString result = folder; | ||||
30 | while (result.endsWith('/')) { | ||||
31 | result.chop(1); | ||||
32 | } | ||||
33 | return result; | ||||
34 | } | ||||
35 | | ||||
27 | FilteredDirIterator::FilteredDirIterator(const FileIndexerConfig* config, const QString& folder, Filter filter) | 36 | FilteredDirIterator::FilteredDirIterator(const FileIndexerConfig* config, const QString& folder, Filter filter) | ||
28 | : m_config(config) | 37 | : m_config(config) | ||
29 | , m_currentIter(nullptr) | 38 | , m_currentIter(nullptr) | ||
30 | , m_filters(QDir::NoDotAndDotDot | QDir::Readable | QDir::NoSymLinks) | 39 | , m_filters(QDir::NoDotAndDotDot | QDir::Readable | QDir::NoSymLinks) | ||
31 | , m_firstItem(false) | 40 | , m_firstItem(false) | ||
32 | { | 41 | { | ||
33 | if (filter == DirsOnly) { | 42 | if (filter == DirsOnly) { | ||
34 | m_filters |= QDir::Dirs; | 43 | m_filters |= QDir::Dirs; | ||
35 | } else if (filter == FilesAndDirs) { | 44 | } else if (filter == FilesAndDirs) { | ||
36 | m_filters |= (QDir::Files | QDir::Dirs); | 45 | m_filters |= (QDir::Files | QDir::Dirs); | ||
37 | } | 46 | } | ||
38 | 47 | | |||
39 | if (!m_config || m_config->shouldFolderBeIndexed(folder)) { | 48 | if (!m_config || m_config->shouldFolderBeIndexed(folder)) { | ||
40 | m_currentIter = new QDirIterator(folder, m_filters); | 49 | m_currentIter = new QDirIterator(skipTrailingSlash(folder), m_filters); | ||
41 | m_firstItem = true; | 50 | m_firstItem = true; | ||
42 | } | 51 | } | ||
43 | } | 52 | } | ||
44 | 53 | | |||
45 | FilteredDirIterator::~FilteredDirIterator() | 54 | FilteredDirIterator::~FilteredDirIterator() | ||
46 | { | 55 | { | ||
47 | delete m_currentIter; | 56 | delete m_currentIter; | ||
48 | } | 57 | } | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |