diff options
author | Marcus Tillmanns <[email protected]> | 2022-11-01 09:27:54 +0100 |
---|---|---|
committer | Marcus Tillmanns <[email protected]> | 2022-11-02 09:50:23 +0000 |
commit | c86b86b2546424dd6ec5bccf4b50ab04965fded4 (patch) | |
tree | 35b8eea61ac30a202195eb4587c98ae1b68d82c1 /src/plugins/help/helpmanager.cpp | |
parent | 9a79e530c83558887cfdafd96210d36b954d451f (diff) |
Help: Remove duplicate results
Workaround for QTBUG-108131
Change-Id: If3de18249fe11b753323c5375559d5ffd0ef0673
Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins/help/helpmanager.cpp')
-rw-r--r-- | src/plugins/help/helpmanager.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/plugins/help/helpmanager.cpp b/src/plugins/help/helpmanager.cpp index a716bb537af..74b907b3374 100644 --- a/src/plugins/help/helpmanager.cpp +++ b/src/plugins/help/helpmanager.cpp @@ -195,19 +195,34 @@ QSet<QString> HelpManager::userDocumentationPaths() return d->m_userRegisteredFiles; } -// This should go into Qt 4.8 once we start using it for Qt Creator -QMultiMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) +QMultiMap<QString, QUrl> HelpManager::linksForKeyword(QHelpEngineCore *engine, + const QString &key, + std::optional<QString> filterName) { - QTC_ASSERT(!d->m_needsSetup, return {}); - if (key.isEmpty()) - return {}; QMultiMap<QString, QUrl> links; - const QList<QHelpLink> docs = d->m_helpEngine->documentsForKeyword(key, QString()); + const QList<QHelpLink> docs = filterName.has_value() + ? engine->documentsForKeyword(key, filterName.value()) + : engine->documentsForKeyword(key); + for (const auto &doc : docs) links.insert(doc.title, doc.url); + + // Remove duplicates (workaround for QTBUG-108131) + links.removeIf([&links](const QMultiMap<QString, QUrl>::iterator it) { + return links.find(it.key(), it.value()) != it; + }); + return links; } +QMultiMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) +{ + QTC_ASSERT(!d->m_needsSetup, return {}); + if (key.isEmpty()) + return {}; + return HelpManager::linksForKeyword(d->m_helpEngine, key, QString()); +} + QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id) { QTC_ASSERT(!d->m_needsSetup, return {}); |