File indexing completed on 2024-04-21 03:51:46

0001 /*
0002     This file is part of the KDE Baloo project.
0003     SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef BALOO_UNINDEXEDFILEITERATOR_H
0009 #define BALOO_UNINDEXEDFILEITERATOR_H
0010 
0011 #include "filtereddiriterator.h"
0012 
0013 #include <QMimeDatabase>
0014 
0015 namespace Baloo {
0016 
0017 class Transaction;
0018 
0019 /**
0020  * Iterate over all the files (and directories) under a specific directory which require
0021  * indexing. This checks the following -
0022  * - Config include / exclude path
0023  * - Config filters
0024  * - Config mimetype filters
0025  * - Database for mtime differences
0026  */
0027 class UnIndexedFileIterator
0028 {
0029 public:
0030     UnIndexedFileIterator(const FileIndexerConfig* config, Transaction* transaction, const QString& folder);
0031     ~UnIndexedFileIterator();
0032 
0033     QString next();
0034     QString filePath() const;
0035     QString mimetype() const;
0036     bool mTimeChanged() const;
0037     bool cTimeChanged() const;
0038 
0039 private:
0040     bool shouldIndex(const QString& filePath);
0041 
0042     const FileIndexerConfig* m_config;
0043     Transaction* m_transaction;
0044     FilteredDirIterator m_iter;
0045 
0046     QMimeDatabase m_mimeDb;
0047     QString m_mimetype;
0048 
0049     bool m_mTimeChanged;
0050     bool m_cTimeChanged;
0051 };
0052 
0053 }
0054 
0055 #endif // BALOO_UNINDEXEDFILEITERATOR_H