1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include <coreplugin/locator/ilocatorfilter.h> 29 30 #include <QIcon> 31 #include <QMultiMap> 32 #include <QSet> 33 #include <QUrl> 34 35 #include <atomic> 36 37 namespace Help { 38 namespace Internal { 39 40 class HelpIndexFilter final : public Core::ILocatorFilter 41 { 42 Q_OBJECT 43 44 public: 45 HelpIndexFilter(); 46 ~HelpIndexFilter() final; 47 48 // ILocatorFilter 49 QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, 50 const QString &entry) override; 51 void accept(Core::LocatorFilterEntry selection, 52 QString *newText, int *selectionStart, int *selectionLength) const override; 53 void refresh(QFutureInterface<void> &future) override; 54 55 #ifndef HELP_NEW_FILTER_ENGINE 56 void prepareSearch(const QString &entry) override; 57 Q_INVOKABLE QSet<QString> searchMatches(const QString &databaseFilePath, 58 const QString &term, int limit); 59 #else 60 Q_INVOKABLE QStringList allIndices() const; 61 #endif 62 63 signals: 64 void linksActivated(const QMultiMap<QString, QUrl> &links, const QString &key) const; 65 66 private: 67 void invalidateCache(); 68 69 #ifndef HELP_NEW_FILTER_ENGINE 70 QStringList m_helpDatabases; 71 QSet<QString> m_keywordCache; 72 QString m_searchTermCache; 73 #else 74 bool updateCache(QFutureInterface<Core::LocatorFilterEntry> &future, 75 const QStringList &cache, const QString &entry); 76 77 QStringList m_allIndicesCache; 78 QStringList m_lastIndicesCache; 79 QString m_lastEntry; 80 #endif 81 std::atomic_bool m_needsUpdate = true; 82 QIcon m_icon; 83 }; 84 85 } // namespace Internal 86 } // namespace Help 87