diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-18 11:58:22 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-19 13:58:07 +0000 |
commit | 9fd9bd25ab5c54fd9ce23a85cb48c54a836867d8 (patch) | |
tree | 56c5457523297b9724bb78ced7b9d563b679c106 /src/plugins/texteditor/basehoverhandler.cpp | |
parent | 0a4073ef90cb61400856ead7c137064096694b6a (diff) | |
download | qt-creator-9fd9bd25ab5c54fd9ce23a85cb48c54a836867d8.tar.gz |
TextEditor: Let BaseHoverHandler handle help id callbacks
...to support asynchronous hover handlers like ClangHoverHandler.
Change-Id: I8dc7189db37ec3a923cf493b8957c59ec9be447c
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/basehoverhandler.cpp')
-rw-r--r-- | src/plugins/texteditor/basehoverhandler.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp index 10a532bcc1..3b5edef2ee 100644 --- a/src/plugins/texteditor/basehoverhandler.cpp +++ b/src/plugins/texteditor/basehoverhandler.cpp @@ -70,16 +70,16 @@ void BaseHoverHandler::setPriority(int priority) m_priority = priority; } -QString BaseHoverHandler::contextHelpId(TextEditorWidget *widget, int pos) +void BaseHoverHandler::contextHelpId(TextEditorWidget *widget, + int pos, + const Core::IContext::HelpIdCallback &callback) { // 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(widget, pos, [](int){}); - - if (lastHelpItemIdentified().isValid()) - return lastHelpItemIdentified().helpId(); - return QString(); + process(widget, pos, [this, widget, callback](int) { propagateHelpId(widget, callback); }); + else + propagateHelpId(widget, callback); } void BaseHoverHandler::setToolTip(const QString &tooltip) @@ -102,6 +102,17 @@ const HelpItem &BaseHoverHandler::lastHelpItemIdentified() const return m_lastHelpItemIdentified; } +void BaseHoverHandler::propagateHelpId(TextEditorWidget *widget, + const Core::IContext::HelpIdCallback &callback) +{ + QString id; + if (lastHelpItemIdentified().isValid()) + id = lastHelpItemIdentified().helpId(); + + widget->setContextHelpId(id); + callback(id); +} + void BaseHoverHandler::process(TextEditorWidget *widget, int pos, ReportPriority report) { m_toolTip.clear(); |