diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-04-06 13:30:41 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-04-06 13:32:59 +0200 |
commit | 915a07bdbbd5dc65332369a117acde58793a165d (patch) | |
tree | a353d1bdfb7dc7c23de7a39d8a64b99c5c9a995b /src/plugins/cppeditor/cpphoverhandler.cpp | |
parent | e615cf82a532926e40ab026fbc7753cc22587b15 (diff) | |
download | qt-creator-915a07bdbbd5dc65332369a117acde58793a165d.tar.gz |
CppEditor: Fix context sensitive help for namespaced libraries.
If the generated documentation doesn't contain the namespace name,
we failed to look up the correct help page.
Task-number: QTCREATORBUG-946
Reviewed-by: Erik Verbruggen
Diffstat (limited to 'src/plugins/cppeditor/cpphoverhandler.cpp')
-rw-r--r-- | src/plugins/cppeditor/cpphoverhandler.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 1755e925a4..a4fd089c6a 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -307,6 +307,13 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } + if (m_helpEngineNeedsSetup + && m_helpEngine->registeredDocumentations().count() > 0) { + m_helpEngine->setupData(); + m_helpEngineNeedsSetup = false; + } + + QMap<QString, QUrl> helpLinks; if (m_helpId.isEmpty()) { // Move to the end of a qualified name bool stop = false; @@ -374,6 +381,24 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } + + // Some docs don't contain the namespace in the documentation pages, for instance + // there is QtMobility::QContactManager but the help page is for QContactManager. + // To show their help anyway, try stripping scopes until we find something. + const QString startHelpId = m_helpId; + while (!m_helpId.isEmpty()) { + helpLinks = m_helpEngine->linksForIdentifier(m_helpId); + if (!helpLinks.isEmpty()) + break; + + int coloncolonIndex = m_helpId.indexOf(QLatin1String("::")); + if (coloncolonIndex == -1) { + m_helpId = startHelpId; + break; + } + + m_helpId.remove(0, coloncolonIndex + 2); + } } } @@ -388,13 +413,6 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } - if (m_helpEngineNeedsSetup - && m_helpEngine->registeredDocumentations().count() > 0) { - m_helpEngine->setupData(); - m_helpEngineNeedsSetup = false; - } - - if (!formatTooltip.isEmpty()) { m_toolTip = formatTooltip; } @@ -402,7 +420,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in if (!m_toolTip.isEmpty()) m_toolTip = Qt::escape(m_toolTip); - if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) { + if (!m_helpId.isEmpty() && !helpLinks.isEmpty()) { if (showF1) { m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>" "<td><img src=\":/cppeditor/images/f1.png\"></td></tr></table>")) |