forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -3,15 +3,16 @@
|
||||
|
||||
#include "helpindexfilter.h"
|
||||
|
||||
#include "helpmanager.h"
|
||||
#include "helptr.h"
|
||||
#include "localhelpmanager.h"
|
||||
#include "helpmanager.h"
|
||||
#include "helpplugin.h"
|
||||
#include "helptr.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;
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user