forked from qt-creator/qt-creator
Help: Remove duplicate results
Workaround for QTBUG-108131 Change-Id: If3de18249fe11b753323c5375559d5ffd0ef0673 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -101,10 +101,7 @@ void HelpIndexFilter::accept(const LocatorFilterEntry &selection,
|
|||||||
Q_UNUSED(selectionStart)
|
Q_UNUSED(selectionStart)
|
||||||
Q_UNUSED(selectionLength)
|
Q_UNUSED(selectionLength)
|
||||||
const QString &key = selection.displayName;
|
const QString &key = selection.displayName;
|
||||||
QMultiMap<QString, QUrl> links;
|
const QMultiMap<QString, QUrl> links = LocalHelpManager::linksForKeyword(key);
|
||||||
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(key, QString());
|
|
||||||
for (const auto &doc : docs)
|
|
||||||
links.insert(doc.title, doc.url);
|
|
||||||
emit linksActivated(links, key);
|
emit linksActivated(links, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -195,17 +195,32 @@ QSet<QString> HelpManager::userDocumentationPaths()
|
|||||||
return d->m_userRegisteredFiles;
|
return d->m_userRegisteredFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should go into Qt 4.8 once we start using it for Qt Creator
|
QMultiMap<QString, QUrl> HelpManager::linksForKeyword(QHelpEngineCore *engine,
|
||||||
|
const QString &key,
|
||||||
|
std::optional<QString> filterName)
|
||||||
|
{
|
||||||
|
QMultiMap<QString, QUrl> links;
|
||||||
|
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)
|
QMultiMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
QTC_ASSERT(!d->m_needsSetup, return {});
|
||||||
if (key.isEmpty())
|
if (key.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
QMultiMap<QString, QUrl> links;
|
return HelpManager::linksForKeyword(d->m_helpEngine, key, QString());
|
||||||
const QList<QHelpLink> docs = d->m_helpEngine->documentsForKeyword(key, QString());
|
|
||||||
for (const auto &doc : docs)
|
|
||||||
links.insert(doc.title, doc.url);
|
|
||||||
return links;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
QT_FORWARD_DECLARE_CLASS(QUrl)
|
QT_FORWARD_DECLARE_CLASS(QUrl)
|
||||||
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
|
#include <QHelpEngineCore>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace Help {
|
namespace Help {
|
||||||
@@ -34,6 +35,9 @@ public:
|
|||||||
|
|
||||||
QMultiMap<QString, QUrl> linksForIdentifier(const QString &id) override;
|
QMultiMap<QString, QUrl> linksForIdentifier(const QString &id) override;
|
||||||
QMultiMap<QString, QUrl> linksForKeyword(const QString &key) override;
|
QMultiMap<QString, QUrl> linksForKeyword(const QString &key) override;
|
||||||
|
static QMultiMap<QString, QUrl> linksForKeyword(QHelpEngineCore *engine,
|
||||||
|
const QString &key,
|
||||||
|
std::optional<QString> filterName);
|
||||||
|
|
||||||
static QUrl findFile(const QUrl &url);
|
static QUrl findFile(const QUrl &url);
|
||||||
QByteArray fileData(const QUrl &url) override;
|
QByteArray fileData(const QUrl &url) override;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QHelpEngine>
|
#include <QHelpEngine>
|
||||||
|
#include <QHelpLink>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -521,3 +522,8 @@ bool LocalHelpManager::openOnlineHelp(const QUrl &url)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMultiMap<QString, QUrl> LocalHelpManager::linksForKeyword(const QString &keyword)
|
||||||
|
{
|
||||||
|
return HelpManager::linksForKeyword(&LocalHelpManager::helpEngine(), keyword, std::nullopt);
|
||||||
|
}
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ public:
|
|||||||
static bool canOpenOnlineHelp(const QUrl &url);
|
static bool canOpenOnlineHelp(const QUrl &url);
|
||||||
static bool openOnlineHelp(const QUrl &url);
|
static bool openOnlineHelp(const QUrl &url);
|
||||||
|
|
||||||
|
static QMultiMap<QString, QUrl> linksForKeyword(const QString &keyword);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fallbackFontChanged(const QFont &font);
|
void fallbackFontChanged(const QFont &font);
|
||||||
void fontZoomChanged(int percentage);
|
void fontZoomChanged(int percentage);
|
||||||
|
|||||||
@@ -175,10 +175,7 @@ void IndexWindow::disableSearchLineEdit()
|
|||||||
void IndexWindow::open(const QModelIndex &index, bool newPage)
|
void IndexWindow::open(const QModelIndex &index, bool newPage)
|
||||||
{
|
{
|
||||||
const QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
|
const QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
|
||||||
QMultiMap<QString, QUrl> links;
|
const QMultiMap<QString, QUrl> links = LocalHelpManager::linksForKeyword(keyword);
|
||||||
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(keyword);
|
|
||||||
for (const auto &doc : docs)
|
|
||||||
links.insert(doc.title, doc.url);
|
|
||||||
|
|
||||||
emit linksActivated(links, keyword, newPage);
|
emit linksActivated(links, keyword, newPage);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user