diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 086595b9570..cf7d3bab472 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -77,11 +77,19 @@ void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos) const QSharedPointer &cppElement = evaluator.cppElement(); if (!isDiagnosticTooltip()) setToolTip(cppElement->tooltip); - foreach (const QString &helpId, cppElement->helpIdCandidates) { - if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) { + QStringList candidates = cppElement->helpIdCandidates; + candidates.removeDuplicates(); + HelpManager *hm = HelpManager::instance(); + foreach (const QString &helpId, candidates) { + if (helpId.isEmpty()) + continue; + + const QMap helpLinks = hm->linksForIdentifier(helpId); + if (!helpLinks.isEmpty()) { setLastHelpItemIdentified(TextEditor::HelpItem(helpId, cppElement->helpMark, - cppElement->helpCategory)); + cppElement->helpCategory, + helpLinks)); break; } } diff --git a/src/plugins/texteditor/helpitem.cpp b/src/plugins/texteditor/helpitem.cpp index f247acdbab0..48ce0565100 100644 --- a/src/plugins/texteditor/helpitem.cpp +++ b/src/plugins/texteditor/helpitem.cpp @@ -32,9 +32,6 @@ #include #include -#include -#include - using namespace TextEditor; HelpItem::HelpItem() @@ -48,6 +45,11 @@ HelpItem::HelpItem(const QString &helpId, const QString &docMark, Category categ m_helpId(helpId), m_docMark(docMark), m_category(category) {} +HelpItem::HelpItem(const QString &helpId, const QString &docMark, Category category, + const QMap &helpLinks) : + m_helpId(helpId), m_docMark(docMark), m_category(category), m_helpLinks(helpLinks) +{} + HelpItem::~HelpItem() {} @@ -71,7 +73,9 @@ HelpItem::Category HelpItem::category() const bool HelpItem::isValid() const { - if (!Core::HelpManager::instance()->linksForIdentifier(m_helpId).isEmpty()) + if (m_helpId.isEmpty()) + return false; + if (!retrieveHelpLinks().isEmpty()) return true; if (QUrl(m_helpId).isValid()) return true; @@ -87,7 +91,7 @@ QString HelpItem::extractContent(bool extended) const htmlExtractor.setMode(Utils::HtmlDocExtractor::FirstParagraph); QString contents; - QMap helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId); + QMap helpLinks = retrieveHelpLinks(); if (helpLinks.isEmpty()) { // Maybe this is already an URL... QUrl url(m_helpId); @@ -134,3 +138,10 @@ QString HelpItem::extractContent(bool extended) const } return contents; } + +QMap HelpItem::retrieveHelpLinks() const +{ + if (m_helpLinks.isEmpty()) + m_helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId); + return m_helpLinks; +} diff --git a/src/plugins/texteditor/helpitem.h b/src/plugins/texteditor/helpitem.h index 8a6be8e5b96..ea48f7da3d4 100644 --- a/src/plugins/texteditor/helpitem.h +++ b/src/plugins/texteditor/helpitem.h @@ -32,7 +32,9 @@ #include "texteditor_global.h" +#include #include +#include namespace TextEditor { @@ -55,6 +57,8 @@ public: HelpItem(); HelpItem(const QString &helpId, Category category); HelpItem(const QString &helpId, const QString &docMark, Category category); + HelpItem(const QString &helpId, const QString &docMark, Category category, + const QMap &helpLinks); ~HelpItem(); void setHelpId(const QString &id); @@ -70,10 +74,14 @@ public: QString extractContent(bool extended) const; +private: + QMap retrieveHelpLinks() const; + private: QString m_helpId; QString m_docMark; Category m_category; + mutable QMap m_helpLinks; // cached help links }; } // namespace TextEditor