diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-04-12 00:02:43 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-04-19 10:58:24 +0000 |
commit | fe067e1d49cdb648b3b387f8a3b4edd94d9b3742 (patch) | |
tree | 1e9fea534b000897e07137bcacd184e18e2f6b10 /src | |
parent | eb98f2f404cc97f94762e9ca035f2a153e58eac5 (diff) |
HelpIndexFilter: Use Acceptor for LocatorFilterEntry
Change-Id: If5fbe4f4c7d0f3c7cda3d232be596937b73c6fd0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/help/helpindexfilter.cpp | 29 | ||||
-rw-r--r-- | src/plugins/help/helpindexfilter.h | 10 | ||||
-rw-r--r-- | src/plugins/help/helpplugin.cpp | 8 | ||||
-rw-r--r-- | src/plugins/help/helpplugin.h | 2 |
4 files changed, 19 insertions, 30 deletions
diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp index 8146b0aa2d..fc6e5b8e24 100644 --- a/src/plugins/help/helpindexfilter.cpp +++ b/src/plugins/help/helpindexfilter.cpp @@ -3,15 +3,16 @@ #include "helpindexfilter.h" +#include "localhelpmanager.h" #include "helpmanager.h" +#include "helpplugin.h" #include "helptr.h" -#include "localhelpmanager.h" -#include <coreplugin/icore.h> #include <coreplugin/helpmanager.h> +#include <coreplugin/icore.h> #include <extensionsystem/pluginmanager.h> -#include <utils/utilsicons.h> #include <utils/tasktree.h> +#include <utils/utilsicons.h> #include <QHelpEngine> #include <QHelpFilterEngine> @@ -77,9 +78,14 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi m_lastEntry = entry; QList<LocatorFilterEntry> entries; - for (const QString &keyword : std::as_const(m_lastIndicesCache)) { - const int index = keyword.indexOf(entry, 0, cs); - LocatorFilterEntry filterEntry(this, keyword); + for (const QString &key : std::as_const(m_lastIndicesCache)) { + const int index = key.indexOf(entry, 0, cs); + LocatorFilterEntry filterEntry; + filterEntry.displayName = key; + filterEntry.acceptor = [key] { + HelpPlugin::showLinksInCurrentViewer(LocalHelpManager::linksForKeyword(key), key); + return AcceptResult(); + }; filterEntry.displayIcon = m_icon; filterEntry.highlightInfo = {index, int(entry.length())}; entries.append(filterEntry); @@ -87,17 +93,6 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi return entries; } -void HelpIndexFilter::accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - const QString &key = selection.displayName; - const QMultiMap<QString, QUrl> links = LocalHelpManager::linksForKeyword(key); - emit linksActivated(links, key); -} - void HelpIndexFilter::invalidateCache() { m_needsUpdate = true; diff --git a/src/plugins/help/helpindexfilter.h b/src/plugins/help/helpindexfilter.h index f836941d48..653d6ff9b7 100644 --- a/src/plugins/help/helpindexfilter.h +++ b/src/plugins/help/helpindexfilter.h @@ -5,10 +5,6 @@ #include <coreplugin/locator/ilocatorfilter.h> -#include <QIcon> -#include <QMultiMap> -#include <QUrl> - namespace Help { namespace Internal { @@ -22,12 +18,6 @@ public: void prepareSearch(const QString &entry) override; QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - -signals: - void linksActivated(const QMultiMap<QString, QUrl> &links, const QString &key) const; - private: void invalidateCache(); diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index de055889ed..c3a743043c 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -165,6 +165,11 @@ void HelpPlugin::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocat dd->showHelpUrl(url, location); } +void HelpPlugin::showLinksInCurrentViewer(const QMultiMap<QString, QUrl> &links, const QString &key) +{ + dd->showLinksInCurrentViewer(links, key); +} + void HelpPlugin::initialize() { dd = new HelpPluginPrivate; @@ -265,9 +270,6 @@ HelpPluginPrivate::HelpPluginPrivate() ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT); connect(action, &QAction::triggered, this, &HelpPluginPrivate::slotSystemInformation); - connect(&helpIndexFilter, &HelpIndexFilter::linksActivated, - this, &HelpPluginPrivate::showLinksInCurrentViewer); - connect(ModeManager::instance(), &ModeManager::currentModeChanged, this, &HelpPluginPrivate::modeChanged); diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index d3a3e0b980..96d14a152b 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -26,6 +26,8 @@ public: ~HelpPlugin() final; static void showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location); + static void showLinksInCurrentViewer(const QMultiMap<QString, QUrl> &links, + const QString &key); static HelpViewer *createHelpViewer(); static HelpWidget *modeHelpWidget(); |