File indexing completed on 2024-05-05 16:45:50
0001 #ifndef KDEVPLATFORM_PLUGIN_GREPFINDTHREAD_H 0002 #define KDEVPLATFORM_PLUGIN_GREPFINDTHREAD_H 0003 0004 #include <QScopedPointer> 0005 #include <QThread> 0006 #include <QUrl> 0007 0008 class GrepFindFilesThreadPrivate; 0009 0010 class GrepFindFilesThread : public QThread 0011 { 0012 Q_OBJECT 0013 public: 0014 /** 0015 * @brief Constructor 0016 * @param[in] parent Parent 0017 * @param[in] startDirs Root directories or files of the search 0018 * @param[in] depth Depth for the search. Possible values are -1 (recursive), 0 (no recursion), or integers 0019 * from 1 on indicating the level of subfolders allowed in the recursion. 0020 * @param[in] patterns Space-separated list of wildcard patterns to search for 0021 * @param[in] exclusions Space-separated list of wildcard patterns to exclude. 0022 * @param[in] onlyProject Whether the search should only consider project files. 0023 */ 0024 GrepFindFilesThread(QObject *parent, const QList<QUrl> &startDirs, int depth, 0025 const QString &patterns, const QString &exclusions, 0026 bool onlyProject); 0027 0028 ~GrepFindFilesThread() override; 0029 0030 /** 0031 * @note This function may be called only after run() returns, e.g. in a slot 0032 * connected to QThread::finished(). 0033 * @return The list of found files when called for the first time; 0034 * an empty list on subsequent calls. 0035 */ 0036 QList<QUrl> takeFiles(); 0037 /** 0038 * @brief Sets the internal m_tryAbort flag to @c true 0039 * @note It is not guaranteed that the thread stops its work immediately. 0040 * Check this via QThread::isRunning() or QThread::isFinished(). 0041 */ 0042 void tryAbort(); 0043 0044 /** 0045 * @brief Parses include string to a list suitable for QDir::match 0046 */ 0047 static QStringList parseInclude(const QString& inc); 0048 0049 /** 0050 * @brief Parses exclude string to a list suitable for QDir::match 0051 */ 0052 static QStringList parseExclude(const QString& excl); 0053 0054 protected: 0055 void run() override; 0056 0057 private: 0058 const QScopedPointer<class GrepFindFilesThreadPrivate> d_ptr; 0059 Q_DECLARE_PRIVATE(GrepFindFilesThread) 0060 }; 0061 0062 #endif