diff options
author | hjk <hjk121@nokiamail.com> | 2014-09-30 13:08:05 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-09-30 15:46:34 +0200 |
commit | beef4807837101aa710ffba556c8fe362f92e026 (patch) | |
tree | 0eb5683aa6e44a63794e2c80f028dee96c2fd663 /src/plugins/texteditor/basehoverhandler.cpp | |
parent | b1cc98f79beaca3aff62ebecbeb227c18cc2b896 (diff) |
TextEditor: Simplify HoverHandler handling
The editor factories are already a central place to associate
hover handlers with editors, no need to retrieve them later from
the object pool again. This also allows for easy handling of
more than one active handler per editor.
Change-Id: Ie716b96f5ce6b526ee897468635e03e909d81538
Reviewed-by: David Schulz <david.schulz@digia.com>
Diffstat (limited to 'src/plugins/texteditor/basehoverhandler.cpp')
-rw-r--r-- | src/plugins/texteditor/basehoverhandler.cpp | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp index 82972ccd90a..f5a137e0d11 100644 --- a/src/plugins/texteditor/basehoverhandler.cpp +++ b/src/plugins/texteditor/basehoverhandler.cpp @@ -40,51 +40,31 @@ using namespace Core; namespace TextEditor { -BaseHoverHandler::BaseHoverHandler(QObject *parent) : QObject(parent), m_diagnosticTooltip(false) +BaseHoverHandler::BaseHoverHandler() : m_diagnosticTooltip(false) { - // Listen for editor opened events in order to connect to tooltip/helpid requests - connect(EditorManager::instance(), &EditorManager::editorOpened, - this, &BaseHoverHandler::editorOpened); } BaseHoverHandler::~BaseHoverHandler() {} -void BaseHoverHandler::editorOpened(Core::IEditor *editor) +void BaseHoverHandler::showToolTip(TextEditorWidget *widget, const QPoint &point, int pos) { - if (acceptEditor(editor)) { - BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(editor); - if (textEditor) { - connect(textEditor, &BaseTextEditor::tooltipRequested, - this, &BaseHoverHandler::showToolTip); - - connect(textEditor, &BaseTextEditor::contextHelpIdRequested, - this, &BaseHoverHandler::updateContextHelpId); - } - } -} + widget->setContextHelpId(QString()); -void BaseHoverHandler::showToolTip(BaseTextEditor *editor, const QPoint &point, int pos) -{ - TextEditorWidget *editorWidget = editor->editorWidget(); - - editor->setContextHelpId(QString()); - - process(editor, pos); - operateTooltip(editorWidget, point); + process(widget, pos); + operateTooltip(widget, point); } -void BaseHoverHandler::updateContextHelpId(BaseTextEditor *editor, int pos) +QString BaseHoverHandler::contextHelpId(TextEditorWidget *widget, int pos) { // 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()) - process(editor, pos); + process(widget, pos); if (lastHelpItemIdentified().isValid()) - editor->setContextHelpId(lastHelpItemIdentified().helpId()); - else - editor->setContextHelpId(QString()); // Make sure it's an empty string. + return lastHelpItemIdentified().helpId(); + return QString(); } void BaseHoverHandler::setToolTip(const QString &tooltip) @@ -136,10 +116,10 @@ void BaseHoverHandler::clear() m_lastHelpItemIdentified = HelpItem(); } -void BaseHoverHandler::process(BaseTextEditor *editor, int pos) +void BaseHoverHandler::process(TextEditorWidget *widget, int pos) { clear(); - identifyMatch(editor->editorWidget(), pos); + identifyMatch(widget, pos); decorateToolTip(); } |