| 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 QHELPSEARCHENGINE_H | 
| 5 | #define QHELPSEARCHENGINE_H | 
| 6 |  | 
| 7 | #include <QtHelp/qhelp_global.h> | 
| 8 | #include <QtHelp/qhelpsearchresult.h> | 
| 9 |  | 
| 10 | #include <QtCore/qobject.h> | 
| 11 | #include <QtCore/qshareddata.h> | 
| 12 | #include <QtCore/qstringlist.h> | 
| 13 |  | 
| 14 | QT_BEGIN_NAMESPACE | 
| 15 |  | 
| 16 | class QHelpEngineCore; | 
| 17 | class QHelpSearchEnginePrivate; | 
| 18 | class QHelpSearchQueryWidget; | 
| 19 | class QHelpSearchResultWidget; | 
| 20 |  | 
| 21 | #if QT_DEPRECATED_SINCE(6, 7) | 
| 22 | class QHELP_EXPORT QHelpSearchQuery | 
| 23 | { | 
| 24 | public: | 
| 25 |     enum FieldName { DEFAULT = 0, FUZZY, WITHOUT, PHRASE, ALL, ATLEAST }; | 
| 26 |  | 
| 27 |     QT_DEPRECATED_VERSION_X_6_7("Use QString instead" ) | 
| 28 |     QHelpSearchQuery() | 
| 29 |         : fieldName(DEFAULT) { wordList.clear(); } | 
| 30 |     QT_DEPRECATED_VERSION_X_6_7("Use QString instead" ) | 
| 31 |     QHelpSearchQuery(FieldName field, const QStringList &wordList_) | 
| 32 |         : fieldName(field), wordList(wordList_) {} | 
| 33 |  | 
| 34 |     FieldName fieldName; | 
| 35 |     QStringList wordList; | 
| 36 | }; | 
| 37 | #endif // QT_DEPRECATED_SINCE(6, 7) | 
| 38 |  | 
| 39 | class QHELP_EXPORT QHelpSearchEngine : public QObject | 
| 40 | { | 
| 41 |     Q_OBJECT | 
| 42 |  | 
| 43 | public: | 
| 44 |     explicit QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *parent = nullptr); | 
| 45 |     ~QHelpSearchEngine(); | 
| 46 |  | 
| 47 |     QHelpSearchQueryWidget *queryWidget(); | 
| 48 |     QHelpSearchResultWidget *resultWidget(); | 
| 49 |  | 
| 50 | #if QT_DEPRECATED_SINCE(5, 9) | 
| 51 |     typedef QPair<QString, QString> SearchHit; | 
| 52 |  | 
| 53 |     QT_DEPRECATED int hitsCount() const; | 
| 54 |     QT_DEPRECATED int hitCount() const; | 
| 55 |     QT_DEPRECATED QList<SearchHit> hits(int start, int end) const; | 
| 56 |     QT_DEPRECATED QList<QHelpSearchQuery> query() const; | 
| 57 | #endif | 
| 58 |  | 
| 59 |     int searchResultCount() const; | 
| 60 |     QList<QHelpSearchResult> searchResults(int start, int end) const; | 
| 61 |     QString searchInput() const; | 
| 62 |  | 
| 63 | public Q_SLOTS: | 
| 64 |     void reindexDocumentation(); | 
| 65 |     void cancelIndexing(); | 
| 66 |  | 
| 67 | #if QT_DEPRECATED_SINCE(5, 9) | 
| 68 |     QT_DEPRECATED void search(const QList<QHelpSearchQuery> &queryList); | 
| 69 | #endif | 
| 70 |  | 
| 71 |     void search(const QString &searchInput); | 
| 72 |     void cancelSearching(); | 
| 73 |  | 
| 74 |     void scheduleIndexDocumentation(); | 
| 75 |  | 
| 76 | Q_SIGNALS: | 
| 77 |     void indexingStarted(); | 
| 78 |     void indexingFinished(); | 
| 79 |  | 
| 80 |     void searchingStarted(); | 
| 81 |     void searchingFinished(int searchResultCount); | 
| 82 |  | 
| 83 | private Q_SLOTS: | 
| 84 |     void indexDocumentation(); | 
| 85 |  | 
| 86 | private: | 
| 87 |     QHelpSearchEnginePrivate *d; | 
| 88 | }; | 
| 89 |  | 
| 90 | QT_END_NAMESPACE | 
| 91 |  | 
| 92 | #endif // QHELPSEARCHENGINE_H | 
| 93 |  |