From 50790f61872b4b2fadf103f946561406b6732318 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 19 Jun 2017 12:17:59 +0200 Subject: [PATCH] TextEditor: Avoid unneeded calls in BaseHoverHandler In checkToolTip(), the call to decorateToolTip() is not needed since it does not affect the priority. In showToolTip(), we can assume that checkToolTip() was called and thus avoid a call to identifyMatch(). TextEditorWidgetPrivate::processTooltipRequest() is the only caller of checkToolTip() and showToolTip(). Change-Id: I362c697754b6a29c9c0b34f85d3022f00e3e1031 Reviewed-by: David Schulz --- src/plugins/texteditor/basehoverhandler.cpp | 13 +++---------- src/plugins/texteditor/basehoverhandler.h | 3 +-- src/plugins/texteditor/texteditor.cpp | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp index 7764f12dbdd..abbf2154abf 100644 --- a/src/plugins/texteditor/basehoverhandler.cpp +++ b/src/plugins/texteditor/basehoverhandler.cpp @@ -33,11 +33,9 @@ namespace TextEditor { BaseHoverHandler::~BaseHoverHandler() {} -void BaseHoverHandler::showToolTip(TextEditorWidget *widget, const QPoint &point, int pos) +void BaseHoverHandler::showToolTip(TextEditorWidget *widget, const QPoint &point) { - widget->setContextHelpId(QString()); - - process(widget, pos); + decorateToolTip(); operateTooltip(widget, point); } @@ -101,18 +99,13 @@ const HelpItem &BaseHoverHandler::lastHelpItemIdentified() const return m_lastHelpItemIdentified; } -void BaseHoverHandler::clear() +void BaseHoverHandler::process(TextEditorWidget *widget, int pos) { m_toolTip.clear(); m_priority = -1; m_lastHelpItemIdentified = HelpItem(); -} -void BaseHoverHandler::process(TextEditorWidget *widget, int pos) -{ - clear(); identifyMatch(widget, pos); - decorateToolTip(); } void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos) diff --git a/src/plugins/texteditor/basehoverhandler.h b/src/plugins/texteditor/basehoverhandler.h index 351d8df490a..f5c8d757b7a 100644 --- a/src/plugins/texteditor/basehoverhandler.h +++ b/src/plugins/texteditor/basehoverhandler.h @@ -44,7 +44,7 @@ public: QString contextHelpId(TextEditorWidget *widget, int pos); int checkToolTip(TextEditorWidget *widget, int pos); - void showToolTip(TextEditorWidget *widget, const QPoint &point, int pos); + void showToolTip(TextEditorWidget *widget, const QPoint &point); protected: enum { @@ -67,7 +67,6 @@ protected: virtual void operateTooltip(TextEditorWidget *editorWidget, const QPoint &point); private: - void clear(); void process(TextEditorWidget *widget, int pos); QString m_toolTip; diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index e1652a8241e..7156ca120f4 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3143,7 +3143,7 @@ void TextEditorWidgetPrivate::processTooltipRequest(const QTextCursor &c) } if (highest) - highest->showToolTip(q, toolTipPoint, c.position()); + highest->showToolTip(q, toolTipPoint); } bool TextEditorWidget::viewportEvent(QEvent *event)