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/texteditor/basehoverhandler.cpp | |
parent | ebd8fef1bef086f528a8bc56e75d39face61c610 (diff) |
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/texteditor/basehoverhandler.cpp')
-rw-r--r-- | src/plugins/texteditor/basehoverhandler.cpp | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp index d382548a104..7a46d5fb114 100644 --- a/src/plugins/texteditor/basehoverhandler.cpp +++ b/src/plugins/texteditor/basehoverhandler.cpp @@ -40,18 +40,11 @@ using namespace Core; namespace TextEditor { -static BaseTextEditorWidget *baseTextEditor(BaseTextEditor *editor) -{ - if (!editor) - return 0; - return qobject_cast<BaseTextEditorWidget *>(editor->widget()); -} - BaseHoverHandler::BaseHoverHandler(QObject *parent) : QObject(parent), m_diagnosticTooltip(false) { // Listen for editor opened events in order to connect to tooltip/helpid requests - connect(Core::EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), - this, SLOT(editorOpened(Core::IEditor*))); + connect(EditorManager::instance(), &EditorManager::editorOpened, + this, &BaseHoverHandler::editorOpened); } BaseHoverHandler::~BaseHoverHandler() @@ -62,33 +55,27 @@ void BaseHoverHandler::editorOpened(Core::IEditor *editor) if (acceptEditor(editor)) { BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(editor); if (textEditor) { - connect(textEditor, SIGNAL(tooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)), - this, SLOT(showToolTip(TextEditor::BaseTextEditor*,QPoint,int))); + connect(textEditor, &BaseTextEditor::tooltipRequested, + this, &BaseHoverHandler::showToolTip); - connect(textEditor, SIGNAL(contextHelpIdRequested(TextEditor::BaseTextEditor*,int)), - this, SLOT(updateContextHelpId(TextEditor::BaseTextEditor*,int))); + connect(textEditor, &BaseTextEditor::contextHelpIdRequested, + this, &BaseHoverHandler::updateContextHelpId); } } } -void BaseHoverHandler::showToolTip(TextEditor::BaseTextEditor *editor, const QPoint &point, int pos) +void BaseHoverHandler::showToolTip(BaseTextEditor *editor, const QPoint &point, int pos) { - BaseTextEditorWidget *baseEditor = baseTextEditor(editor); - if (!baseEditor) - return; + BaseTextEditorWidget *editorWidget = editor->editorWidget(); editor->setContextHelpId(QString()); process(editor, pos); - operateTooltip(editor, point); + operateTooltip(editorWidget, point); } -void BaseHoverHandler::updateContextHelpId(TextEditor::BaseTextEditor *editor, int pos) +void BaseHoverHandler::updateContextHelpId(BaseTextEditor *editor, int pos) { - BaseTextEditorWidget *baseEditor = baseTextEditor(editor); - if (!baseEditor) - return; - // If the tooltip is visible and there is a help match, this match is used to update // the help id. Otherwise, let the identification process happen. if (!Utils::ToolTip::isVisible() || !lastHelpItemIdentified().isValid()) @@ -152,7 +139,7 @@ void BaseHoverHandler::clear() void BaseHoverHandler::process(BaseTextEditor *editor, int pos) { clear(); - identifyMatch(editor, pos); + identifyMatch(editor->editorWidget(), pos); decorateToolTip(); } @@ -171,12 +158,12 @@ void BaseHoverHandler::decorateToolTip() } } -void BaseHoverHandler::operateTooltip(BaseTextEditor *editor, const QPoint &point) +void BaseHoverHandler::operateTooltip(BaseTextEditorWidget *editorWidget, const QPoint &point) { if (m_toolTip.isEmpty()) Utils::ToolTip::hide(); else - Utils::ToolTip::show(point, Utils::TextContent(m_toolTip), editor->widget()); + Utils::ToolTip::show(point, Utils::TextContent(m_toolTip), editorWidget); } } // namespace TextEditor |