diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-01-25 15:04:50 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-01-29 07:57:19 +0000 |
commit | 418dcfbcbbd15a63ed261b22da3391e43e7ab8aa (patch) | |
tree | 7b176df3b7b48527fdb53d1caaa964de63800607 /src/plugins/help/helpplugin.cpp | |
parent | c04c5c1575e4ee425e6d2383e52a2b44e9c20fd2 (diff) |
Help: Avoid multiple lookups of help id for context help
Context help would first query the database with potential IDs, and
afterwards the help plugin would look up the links for the resulting ID
again.
Pass the HelpItem (which potentially contains the cached links) directly
to context help.
Change-Id: I73bddcd3cd4eacaea412b98d53c5e5354a31f3d5
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/help/helpplugin.cpp')
-rw-r--r-- | src/plugins/help/helpplugin.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 20dc5f1392..c7ac66436b 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -65,6 +65,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/findplaceholder.h> +#include <coreplugin/helpitem.h> #include <coreplugin/icore.h> #include <coreplugin/minisplitter.h> #include <coreplugin/modemanager.h> @@ -119,7 +120,7 @@ public: void modeChanged(Core::Id mode, Core::Id old); void requestContextHelp(); - void showContextHelp(const QString &contextHelpId); + void showContextHelp(const HelpItem &contextHelp); void activateIndex(); void activateContents(); @@ -649,17 +650,17 @@ void HelpPluginPrivate::requestContextHelp() QString contextHelpId = Utils::ToolTip::contextHelpId(); IContext *context = ICore::currentContextObject(); if (contextHelpId.isEmpty() && context) - context->contextHelpId([this](const QString &id) { showContextHelp(id); }); + context->contextHelp([this](const HelpItem &item) { showContextHelp(item); }); else showContextHelp(contextHelpId); } -void HelpPluginPrivate::showContextHelp(const QString &contextHelpId) +void HelpPluginPrivate::showContextHelp(const HelpItem &contextHelp) { - QMap<QString, QUrl> links = Core::HelpManager::linksForIdentifier(contextHelpId); + QMap<QString, QUrl> links = contextHelp.links(); // Maybe the id is already an URL - if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelpId)) - links.insert(contextHelpId, contextHelpId); + if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelp.helpId())) + links.insert(contextHelp.helpId(), contextHelp.helpId()); QUrl source = findBestLink(links); if (!source.isValid()) { @@ -675,7 +676,7 @@ void HelpPluginPrivate::showContextHelp(const QString &contextHelpId) .arg(HelpPlugin::tr("No Documentation")) .arg(creatorTheme()->color(Theme::BackgroundColorNormal).name()) .arg(creatorTheme()->color(Theme::TextColorNormal).name()) - .arg(contextHelpId) + .arg(contextHelp.helpId()) .arg(HelpPlugin::tr("No documentation available."))); } } else { |