diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2010-08-27 12:11:55 +0200 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2010-08-31 19:04:52 +0200 |
commit | ba12a3390eb0ec1a54c226ed137764a5efc2b6b0 (patch) | |
tree | a598f0245cb23484b796b70d7e6398bab0a57a8d /src/plugins/cppeditor/cpphoverhandler.cpp | |
parent | db7bf9a8068683fac9d28fcd7ab91dba371dea7e (diff) |
Refactor how base hover handler manipulates the help items (qt docs interaction).
Diffstat (limited to 'src/plugins/cppeditor/cpphoverhandler.cpp')
-rw-r--r-- | src/plugins/cppeditor/cpphoverhandler.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 15922d906e..47c7ee97fb 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -33,10 +33,12 @@ #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/helpmanager.h> #include <cpptools/cppmodelmanagerinterface.h> #include <extensionsystem/pluginmanager.h> #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> +#include <texteditor/helpitem.h> #include <QtGui/QTextCursor> @@ -84,27 +86,21 @@ void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos) QSharedPointer<CppElement> cppElement = evaluator.identifyCppElement(); if (!cppElement.isNull()) { setToolTip(cppElement->tooltip()); - foreach (const QString &helpId, cppElement->helpIdCandidates()) - addHelpCandidate(HelpCandidate(helpId, - cppElement->helpMark(), - cppElement->helpCategory())); - } - } -} - -void CppHoverHandler::evaluateHelpCandidates() -{ - for (int i = 0; i < helpCandidates().size() && matchingHelpCandidate() == -1; ++i) { - if (helpIdExists(helpCandidates().at(i).m_helpId)) { - setMatchingHelpCandidate(i); - } else { - // There are class help ids with and without qualification. - HelpCandidate candidate = helpCandidates().at(i); - const QString &helpId = removeClassNameQualification(candidate.m_helpId); - if (helpIdExists(helpId)) { - candidate.m_helpId = helpId; - setHelpCandidate(candidate, i); - setMatchingHelpCandidate(i); + foreach (QString helpId, cppElement->helpIdCandidates()) { + bool found = false; + if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) { + found = true; + } else { + helpId = removeClassNameQualification(helpId); + if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) + found = true; + } + if (found) { + setLastHelpItemIdentified(TextEditor::HelpItem(helpId, + cppElement->helpMark(), + cppElement->helpCategory())); + break; + } } } } @@ -112,11 +108,15 @@ void CppHoverHandler::evaluateHelpCandidates() void CppHoverHandler::decorateToolTip(TextEditor::ITextEditor *editor) { - if (matchingHelpCandidate() != -1) { - const QString &contents = getDocContents(extendToolTips(editor)); + CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor->widget()); + if (!cppEditor) + return; + + const TextEditor::HelpItem &help = lastHelpItemIdentified(); + if (help.isValid()) { + const QString &contents = help.extractContent(extendToolTips(editor)); if (!contents.isEmpty()) { - HelpCandidate::Category cat = helpCandidate(matchingHelpCandidate()).m_category; - if (cat == HelpCandidate::ClassOrNamespace) + if (help.category() == TextEditor::HelpItem::ClassOrNamespace) appendToolTip(contents); else setToolTip(contents); @@ -126,5 +126,6 @@ void CppHoverHandler::decorateToolTip(TextEditor::ITextEditor *editor) tip.append(QLatin1String("</nobr>")); setToolTip(tip); } + addF1ToToolTip(); } } |