HelpIndexFilter: Remove the old matchesFor() implementation

Change-Id: I867520fc790832c93381f390bcd74e4908086461
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2023-04-24 21:34:21 +02:00
parent 86995160ba
commit 19834f5986
2 changed files with 2 additions and 60 deletions

View File

@@ -110,57 +110,6 @@ LocatorMatcherTasks HelpIndexFilter::matchers()
return {{AsyncTask<QStringList>(onSetup, onDone), storage}};
}
void HelpIndexFilter::prepareSearch(const QString &entry)
{
Q_UNUSED(entry)
if (!m_needsUpdate)
return;
m_needsUpdate = false;
LocalHelpManager::setupGuiHelpEngine();
m_allIndicesCache = LocalHelpManager::filterEngine()->indices({});
m_lastIndicesCache.clear();
m_lastEntry.clear();
}
QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future,
const QString &entry)
{
const QStringList cache = m_lastEntry.isEmpty() || !entry.contains(m_lastEntry)
? m_allIndicesCache : m_lastIndicesCache;
const Qt::CaseSensitivity cs = caseSensitivity(entry);
QStringList bestKeywords;
QStringList worseKeywords;
bestKeywords.reserve(cache.size());
worseKeywords.reserve(cache.size());
for (const QString &keyword : cache) {
if (future.isCanceled())
return {};
if (keyword.startsWith(entry, cs))
bestKeywords.append(keyword);
else if (keyword.contains(entry, cs))
worseKeywords.append(keyword);
}
m_lastIndicesCache = bestKeywords + worseKeywords;
m_lastEntry = entry;
QList<LocatorFilterEntry> entries;
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);
}
return entries;
}
void HelpIndexFilter::invalidateCache()
{
m_needsUpdate = true;

View File

@@ -5,19 +5,13 @@
#include <coreplugin/locator/ilocatorfilter.h>
namespace Help {
namespace Internal {
namespace Help::Internal {
class HelpIndexFilter final : public Core::ILocatorFilter
{
Q_OBJECT
public:
HelpIndexFilter();
void prepareSearch(const QString &entry) override;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
private:
Core::LocatorMatcherTasks matchers() final;
void invalidateCache();
@@ -29,5 +23,4 @@ private:
QIcon m_icon;
};
} // namespace Internal
} // namespace Help
} // namespace Help::Internal