Changeset View
Changeset View
Standalone View
Standalone View
krusader/FileSystem/filesearcher.h
- This file was moved from krusader/Search/krsearchmod.h.
Show All 13 Lines | |||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
16 | * GNU General Public License for more details. * | 16 | * GNU General Public License for more details. * | ||
17 | * * | 17 | * * | ||
18 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
20 | *****************************************************************************/ | 20 | *****************************************************************************/ | ||
21 | 21 | | |||
22 | #ifndef KRSEARCHMOD_H | 22 | #ifndef FILESEARCHER_H | ||
23 | #define KRSEARCHMOD_H | 23 | #define FILESEARCHER_H | ||
24 | 24 | | |||
25 | // QtCore | 25 | // QtCore | ||
26 | #include <QDateTime> | 26 | #include <QDateTime> | ||
27 | #include <QObject> | 27 | #include <QObject> | ||
28 | #include <QStack> | 28 | #include <QStack> | ||
29 | #include <QStringList> | 29 | #include <QStringList> | ||
30 | #include <QUrl> | 30 | #include <QUrl> | ||
31 | 31 | | |||
32 | #include <KIO/Global> | 32 | #include <KIO/Global> | ||
33 | 33 | | |||
34 | class KRQuery; | 34 | #include "krquery.h" | ||
35 | | ||||
35 | class FileItem; | 36 | class FileItem; | ||
36 | class FileSystem; | 37 | class FileSystem; | ||
37 | class DefaultFileSystem; | 38 | class DefaultFileSystem; | ||
38 | class VirtualFileSystem; | 39 | class VirtualFileSystem; | ||
39 | 40 | | |||
40 | /** | 41 | /** | ||
41 | * Search for files based on a search query. | 42 | * Search for files based on a search query. | ||
42 | * | 43 | * | ||
43 | * Subdirectories are included if query->isRecursive() is true. | 44 | * Subdirectories are included if query->isRecursive() is true. | ||
44 | */ | 45 | */ | ||
45 | class KRSearchMod : public QObject | 46 | class FileSearcher: public QObject | ||
46 | { | 47 | { | ||
47 | Q_OBJECT | 48 | Q_OBJECT | ||
48 | public: | 49 | public: | ||
49 | explicit KRSearchMod(const KRQuery *query); | 50 | explicit FileSearcher(const KRQuery &query); | ||
50 | ~KRSearchMod(); | 51 | ~FileSearcher(); | ||
51 | 52 | | |||
52 | void start(); | 53 | /** | ||
54 | * Start the search. | ||||
55 | * | ||||
56 | * @param url if given, this single URL is searched - ignoring query->searchInDirs() | ||||
57 | */ | ||||
58 | void start(const QUrl &url = QUrl()); | ||||
59 | /** Stop the ongoing search. */ | ||||
53 | void stop(); | 60 | void stop(); | ||
61 | /** | ||||
62 | * Return the found files. | ||||
63 | * Owner is this file searcher, they are deleted when re-starting the search. | ||||
64 | */ | ||||
65 | QList<FileItem *> files() const { return m_foundFiles; } | ||||
54 | 66 | | |||
55 | private: | 67 | private: | ||
56 | void scanUrl(const QUrl &url); | 68 | void scanUrl(const QUrl &url); | ||
57 | void scanDirectory(const QUrl &url); | 69 | void scanDirectory(const QUrl &url); | ||
58 | FileSystem *getFileSystem(const QUrl &url); | 70 | FileSystem *getFileSystem(const QUrl &url); | ||
59 | 71 | | |||
60 | signals: | 72 | signals: | ||
61 | void searching(const QString &url); | 73 | void searching(const QString &url); | ||
62 | void found(const FileItem &file, const QString &foundText); | 74 | void found(const FileItem &file, const QString &foundText); | ||
63 | // NOTE: unused | | |||
64 | void error(const QUrl &url); | 75 | void error(const QUrl &url); | ||
65 | void finished(); | 76 | void finished(); | ||
66 | 77 | | |||
67 | private slots: | 78 | private slots: | ||
68 | void slotProcessEvents(bool &stopped); | 79 | void slotProcessEvents(bool &stopped); | ||
69 | 80 | | |||
70 | private: | 81 | private: | ||
71 | KRQuery *m_query; | 82 | const KRQuery m_query; | ||
83 | | ||||
72 | DefaultFileSystem *m_defaultFileSystem; | 84 | DefaultFileSystem *m_defaultFileSystem; | ||
73 | VirtualFileSystem *m_virtualFileSystem; | 85 | VirtualFileSystem *m_virtualFileSystem; | ||
74 | 86 | | |||
75 | bool m_stopSearch; | 87 | bool m_stopSearch; | ||
76 | 88 | | |||
89 | QList<FileItem *> m_foundFiles; | ||||
77 | QStack<QUrl> m_scannedUrls; | 90 | QStack<QUrl> m_scannedUrls; | ||
78 | QStack<QUrl> m_unScannedUrls; | 91 | QStack<QUrl> m_unScannedUrls; | ||
79 | QTime m_timer; | 92 | QTime m_timer; | ||
80 | }; | 93 | }; | ||
81 | 94 | | |||
82 | #endif | 95 | #endif |