diff options
author | hjk <hjk121@nokiamail.com> | 2014-09-09 13:25:10 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-09-10 13:11:53 +0200 |
commit | 0e16affc89c3b5d7698efd883a3442dac5d66259 (patch) | |
tree | 36de7d0a171e6c066cf69d97e4c74f5b31ca8ade /src/plugins/cppeditor/cpphoverhandler.cpp | |
parent | ebd8fef1bef086f528a8bc56e75d39face61c610 (diff) | |
download | qt-creator-0e16affc89c3b5d7698efd883a3442dac5d66259.tar.gz |
TextEditor: Move some hover handler operation from Editor to Widget
Change-Id: Ie54bf52d3f89c76f379d20c4807b1e252af51505
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins/cppeditor/cpphoverhandler.cpp')
-rw-r--r-- | src/plugins/cppeditor/cpphoverhandler.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index d53bb04179..c93b7af7e1 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -40,10 +40,13 @@ #include <QTextCursor> #include <QUrl> -using namespace CppEditor::Internal; using namespace Core; +using namespace TextEditor; -CppHoverHandler::CppHoverHandler(QObject *parent) : BaseHoverHandler(parent) +namespace CppEditor { +namespace Internal { + +CppHoverHandler::CppHoverHandler() {} CppHoverHandler::~CppHoverHandler() @@ -54,19 +57,15 @@ bool CppHoverHandler::acceptEditor(IEditor *editor) return editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID; } -void CppHoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos) +void CppHoverHandler::identifyMatch(BaseTextEditorWidget *editorWidget, int pos) { - using namespace TextEditor; - BaseTextEditorWidget *textEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget()); - QTC_ASSERT(textEditor, return); - - if (!textEditor->extraSelectionTooltip(pos).isEmpty()) { - setToolTip(textEditor->extraSelectionTooltip(pos)); + if (!editorWidget->extraSelectionTooltip(pos).isEmpty()) { + setToolTip(editorWidget->extraSelectionTooltip(pos)); } else { - QTextCursor tc(textEditor->document()); + QTextCursor tc(editorWidget->document()); tc.setPosition(pos); - CppElementEvaluator evaluator(textEditor); + CppElementEvaluator evaluator(editorWidget); evaluator.setTextCursor(tc); evaluator.execute(); if (evaluator.hasDiagnosis()) { @@ -83,12 +82,12 @@ void CppHoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos) if (helpId.isEmpty()) continue; - const QMap<QString, QUrl> helpLinks = Core::HelpManager::linksForIdentifier(helpId); + const QMap<QString, QUrl> helpLinks = HelpManager::linksForIdentifier(helpId); if (!helpLinks.isEmpty()) { - setLastHelpItemIdentified(TextEditor::HelpItem(helpId, - cppElement->helpMark, - cppElement->helpCategory, - helpLinks)); + setLastHelpItemIdentified(HelpItem(helpId, + cppElement->helpMark, + cppElement->helpCategory, + helpLinks)); break; } } @@ -104,29 +103,32 @@ void CppHoverHandler::decorateToolTip() if (isDiagnosticTooltip()) return; - const TextEditor::HelpItem &help = lastHelpItemIdentified(); + const HelpItem &help = lastHelpItemIdentified(); if (help.isValid()) { // If Qt is built with a namespace, we still show the tip without it, as // it is in the docs and for consistency with the doc extraction mechanism. - const TextEditor::HelpItem::Category category = help.category(); + const HelpItem::Category category = help.category(); const QString &contents = help.extractContent(false); if (!contents.isEmpty()) { - if (category == TextEditor::HelpItem::ClassOrNamespace) + if (category == HelpItem::ClassOrNamespace) setToolTip(help.helpId() + contents); else setToolTip(contents); - } else if (category == TextEditor::HelpItem::Typedef || - category == TextEditor::HelpItem::Enum || - category == TextEditor::HelpItem::ClassOrNamespace) { + } else if (category == HelpItem::Typedef || + category == HelpItem::Enum || + category == HelpItem::ClassOrNamespace) { // This approach is a bit limited since it cannot be used for functions // because the help id doesn't really help in that case. QString prefix; - if (category == TextEditor::HelpItem::Typedef) + if (category == HelpItem::Typedef) prefix = QLatin1String("typedef "); - else if (category == TextEditor::HelpItem::Enum) + else if (category == HelpItem::Enum) prefix = QLatin1String("enum "); setToolTip(prefix + help.helpId()); } addF1ToToolTip(); } } + +} // namespace Internal +} // namespace CppEditor |