| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QHELPSEARCHINDEXREADER_H |
| 5 | #define QHELPSEARCHINDEXREADER_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of the help generator tools. This header file may change from version |
| 13 | // to version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qhelpsearchresult.h" |
| 19 | |
| 20 | #include <QtCore/qlist.h> |
| 21 | #include <QtCore/qmutex.h> |
| 22 | #include <QtCore/qthread.h> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | namespace fulltextsearch { |
| 27 | |
| 28 | // TODO: Employ QFuture / QtConcurrent::run() ? |
| 29 | class QHelpSearchIndexReader : public QThread |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | |
| 33 | public: |
| 34 | ~QHelpSearchIndexReader() override; |
| 35 | |
| 36 | void cancelSearching(); |
| 37 | void search(const QString &collectionFile, const QString &indexFilesFolder, |
| 38 | const QString &searchInput, bool usesFilterEngine = false); |
| 39 | int searchResultCount() const; |
| 40 | QList<QHelpSearchResult> searchResults(int start, int end) const; |
| 41 | |
| 42 | signals: |
| 43 | void searchingStarted(); |
| 44 | void searchingFinished(); |
| 45 | |
| 46 | private: |
| 47 | void run() override; |
| 48 | |
| 49 | mutable QMutex m_mutex; |
| 50 | QList<QHelpSearchResult> m_searchResults; |
| 51 | bool m_cancel = false; |
| 52 | QString m_collectionFile; |
| 53 | QString m_searchInput; |
| 54 | QString m_indexFilesFolder; |
| 55 | bool m_usesFilterEngine = false; |
| 56 | }; |
| 57 | |
| 58 | } // namespace fulltextsearch |
| 59 | |
| 60 | QT_END_NAMESPACE |
| 61 | |
| 62 | #endif // QHELPSEARCHINDEXREADER_H |
| 63 | |