Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / src / filebrowse / searchengine.h
1 #ifndef SEARCHENGINE_H
2 #define SEARCHENGINE_H
3
4 #include <QDir>
5
6 class SearchWorker;
7
8 /**
9 * @brief The SearchEngine is a front-end for the SearchWorker class.
10 * These two classes could be merged, but it is clearer to keep the background thread
11 * in its own class.
12 */
13 class SearchEngine : public QObject
14 {
15 Q_OBJECT
16 Q_PROPERTY(QString dir READ dir() WRITE setDir(QString) NOTIFY dirChanged())
17 Q_PROPERTY(bool running READ running() NOTIFY runningChanged())
18
19 public:
20 explicit SearchEngine(QObject *parent = 0);
21 ~SearchEngine();
22
23 // property accessors
24 QString dir() const { return m_dir; }
25 void setDir(QString dir);
26 bool running() const;
27
28 // callable from QML
29 Q_INVOKABLE void search(QString searchTerm);
30 Q_INVOKABLE void cancel();
31
32 signals:
33 void dirChanged();
34 void runningChanged();
35
36 void progressChanged(QString directory);
37 void matchFound(QString fullname, QString filename, QString absoluteDir,
38 QString fileIcon, QString fileKind);
39 void workerDone();
40 void workerErrorOccurred(QString message, QString filename);
41
42 private slots:
43 void emitMatchFound(QString fullpath);
44
45 private:
46 QString m_dir;
47 QString m_errorMessage;
48 SearchWorker *m_searchWorker;
49 };
50
51 #endif // SEARCHENGINE_H