summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-09-09 13:25:10 +0200
committerhjk <hjk121@nokiamail.com>2014-09-10 13:11:53 +0200
commit0e16affc89c3b5d7698efd883a3442dac5d66259 (patch)
tree36de7d0a171e6c066cf69d97e4c74f5b31ca8ade
parentebd8fef1bef086f528a8bc56e75d39face61c610 (diff)
downloadqt-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>
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.cpp50
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.h11
-rw-r--r--src/plugins/glsleditor/glslhoverhandler.cpp6
-rw-r--r--src/plugins/glsleditor/glslhoverhandler.h2
-rw-r--r--src/plugins/qmakeprojectmanager/profilehoverhandler.cpp42
-rw-r--r--src/plugins/qmakeprojectmanager/profilehoverhandler.h12
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljseditorplugin.cpp3
-rw-r--r--src/plugins/qmljseditor/qmljshoverhandler.cpp44
-rw-r--r--src/plugins/qmljseditor/qmljshoverhandler.h11
-rw-r--r--src/plugins/texteditor/basehoverhandler.cpp39
-rw-r--r--src/plugins/texteditor/basehoverhandler.h21
12 files changed, 100 insertions, 143 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
diff --git a/src/plugins/cppeditor/cpphoverhandler.h b/src/plugins/cppeditor/cpphoverhandler.h
index 22a97789a1..ed7d842975 100644
--- a/src/plugins/cppeditor/cpphoverhandler.h
+++ b/src/plugins/cppeditor/cpphoverhandler.h
@@ -32,25 +32,18 @@
#include <texteditor/basehoverhandler.h>
-#include <QObject>
-
-namespace Core { class IEditor; }
-
-namespace TextEditor { class BaseTextEditor; }
-
namespace CppEditor {
namespace Internal {
class CppHoverHandler : public TextEditor::BaseHoverHandler
{
- Q_OBJECT
public:
- CppHoverHandler(QObject *parent = 0);
+ CppHoverHandler();
virtual ~CppHoverHandler();
private:
virtual bool acceptEditor(Core::IEditor *editor);
- virtual void identifyMatch(TextEditor::BaseTextEditor *editor, int pos);
+ virtual void identifyMatch(TextEditor::BaseTextEditorWidget *editorWidget, int pos);
virtual void decorateToolTip();
};
diff --git a/src/plugins/glsleditor/glslhoverhandler.cpp b/src/plugins/glsleditor/glslhoverhandler.cpp
index 1c60ce07c9..197d297c8d 100644
--- a/src/plugins/glsleditor/glslhoverhandler.cpp
+++ b/src/plugins/glsleditor/glslhoverhandler.cpp
@@ -53,10 +53,10 @@ bool GlslHoverHandler::acceptEditor(IEditor *editor)
return editor->context().contains(Constants::C_GLSLEDITOR_ID);
}
-void GlslHoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos)
+void GlslHoverHandler::identifyMatch(TextEditor::BaseTextEditorWidget *editorWidget, int pos)
{
- if (!editor->editorWidget()->extraSelectionTooltip(pos).isEmpty())
- setToolTip(editor->editorWidget()->extraSelectionTooltip(pos));
+ if (!editorWidget->extraSelectionTooltip(pos).isEmpty())
+ setToolTip(editorWidget->extraSelectionTooltip(pos));
}
void GlslHoverHandler::decorateToolTip()
diff --git a/src/plugins/glsleditor/glslhoverhandler.h b/src/plugins/glsleditor/glslhoverhandler.h
index 6f56c584b9..a4d63692b2 100644
--- a/src/plugins/glsleditor/glslhoverhandler.h
+++ b/src/plugins/glsleditor/glslhoverhandler.h
@@ -50,7 +50,7 @@ public:
private:
virtual bool acceptEditor(Core::IEditor *editor);
- virtual void identifyMatch(TextEditor::BaseTextEditor *editor, int pos);
+ virtual void identifyMatch(TextEditor::BaseTextEditorWidget *editorWidget, int pos);
virtual void decorateToolTip();
};
diff --git a/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp b/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp
index 364f948757..d93de8ff4f 100644
--- a/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp
+++ b/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp
@@ -45,45 +45,39 @@ using namespace Core;
namespace QmakeProjectManager {
namespace Internal {
-ProFileHoverHandler::ProFileHoverHandler(QObject *parent)
- : BaseHoverHandler(parent),
- m_manualKind(UnknownManual)
+ProFileHoverHandler::ProFileHoverHandler()
+ : m_manualKind(UnknownManual)
{
ProFileCompletionAssistProvider *pcap
= ExtensionSystem::PluginManager::getObject<ProFileCompletionAssistProvider>();
m_keywords = TextEditor::Keywords(pcap->variables(), pcap->functions(), QMap<QString, QStringList>());
}
-ProFileHoverHandler::~ProFileHoverHandler()
-{}
-
bool ProFileHoverHandler::acceptEditor(IEditor *editor)
{
return editor->context().contains(Constants::PROFILE_EDITOR_ID);
}
-void ProFileHoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos)
+void ProFileHoverHandler::identifyMatch(TextEditor::BaseTextEditorWidget *editorWidget, int pos)
{
m_docFragment.clear();
m_manualKind = UnknownManual;
- if (TextEditor::BaseTextEditorWidget *widget = editor->editorWidget()) {
- if (!widget->extraSelectionTooltip(pos).isEmpty()) {
- setToolTip(widget->extraSelectionTooltip(pos));
+ if (!editorWidget->extraSelectionTooltip(pos).isEmpty()) {
+ setToolTip(editorWidget->extraSelectionTooltip(pos));
+ } else {
+ QTextDocument *document = editorWidget->document();
+ QTextBlock block = document->findBlock(pos);
+ identifyQMakeKeyword(block.text(), pos - block.position());
+
+ if (m_manualKind != UnknownManual) {
+ QUrl url(QString::fromLatin1("qthelp://com.trolltech.qmake/qdoc/qmake-%1-reference.html#%2")
+ .arg(manualName()).arg(m_docFragment));
+ setLastHelpItemIdentified(TextEditor::HelpItem(url.toString(),
+ m_docFragment, TextEditor::HelpItem::QMakeVariableOfFunction));
} else {
- QTextDocument *document = widget->document();
- QTextBlock block = document->findBlock(pos);
- identifyQMakeKeyword(block.text(), pos - block.position());
-
- if (m_manualKind != UnknownManual) {
- QUrl url(QString::fromLatin1("qthelp://com.trolltech.qmake/qdoc/qmake-%1-reference.html#%2")
- .arg(manualName()).arg(m_docFragment));
- setLastHelpItemIdentified(TextEditor::HelpItem(url.toString(),
- m_docFragment, TextEditor::HelpItem::QMakeVariableOfFunction));
- } else {
- // General qmake manual will be shown outside any function or variable
- setLastHelpItemIdentified(TextEditor::HelpItem(QLatin1String("qmake"),
- TextEditor::HelpItem::Unknown));
- }
+ // General qmake manual will be shown outside any function or variable
+ setLastHelpItemIdentified(TextEditor::HelpItem(QLatin1String("qmake"),
+ TextEditor::HelpItem::Unknown));
}
}
}
diff --git a/src/plugins/qmakeprojectmanager/profilehoverhandler.h b/src/plugins/qmakeprojectmanager/profilehoverhandler.h
index 547440a5e6..fde0b0a26e 100644
--- a/src/plugins/qmakeprojectmanager/profilehoverhandler.h
+++ b/src/plugins/qmakeprojectmanager/profilehoverhandler.h
@@ -31,18 +31,11 @@
#define PROFILEHOVERHANDLER_H
#include <texteditor/basehoverhandler.h>
-#include <texteditor/codeassist/keywordscompletionassist.h>
-
-#include <QObject>
QT_BEGIN_NAMESPACE
class QUrl;
QT_END_NAMESPACE
-namespace Core { class IEditor; }
-
-namespace TextEditor { class BaseTextEditor; }
-
namespace QmakeProjectManager {
namespace Internal {
@@ -50,15 +43,14 @@ class ProFileHoverHandler : public TextEditor::BaseHoverHandler
{
Q_OBJECT
public:
- ProFileHoverHandler(QObject *parent = 0);
- virtual ~ProFileHoverHandler();
+ ProFileHoverHandler();
signals:
void creatorHelpRequested(const QUrl &url);
private:
virtual bool acceptEditor(Core::IEditor *editor);
- virtual void identifyMatch(TextEditor::BaseTextEditor *editor, int pos);
+ virtual void identifyMatch(TextEditor::BaseTextEditorWidget *editorWidget, int pos);
void identifyQMakeKeyword(const QString &text, int pos);
enum ManualKind {
diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp
index 7a4b8b15fb..fa599d7de7 100644
--- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp
@@ -137,7 +137,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
addAutoReleasedObject(new LinguistExternalEditor);
addAutoReleasedObject(new ProFileCompletionAssistProvider);
- addAutoReleasedObject(new ProFileHoverHandler(this));
+ addAutoReleasedObject(new ProFileHoverHandler);
auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<ProFileHighlighter>();
diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp
index c2f4fc84a4..e36c490437 100644
--- a/src/plugins/qmljseditor/qmljseditorplugin.cpp
+++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp
@@ -226,8 +226,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider;
addAutoReleasedObject(m_quickFixAssistProvider);
addAutoReleasedObject(new QmlJSCompletionAssistProvider);
-
- addAutoReleasedObject(new HoverHandler);
+ addAutoReleasedObject(new QmlJSHoverHandler);
errorMessage->clear();
diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp
index 6b8ed1d009..60c55352a2 100644
--- a/src/plugins/qmljseditor/qmljshoverhandler.cpp
+++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp
@@ -56,6 +56,7 @@
using namespace Core;
using namespace QmlJS;
+using namespace TextEditor;
namespace QmlJSEditor {
namespace Internal {
@@ -91,12 +92,12 @@ namespace {
}
}
-HoverHandler::HoverHandler(QObject *parent) : BaseHoverHandler(parent), m_modelManager(0)
+QmlJSHoverHandler::QmlJSHoverHandler(QObject *parent) : BaseHoverHandler(parent), m_modelManager(0)
{
m_modelManager = QmlJS::ModelManagerInterface::instance();
}
-bool HoverHandler::acceptEditor(IEditor *editor)
+bool QmlJSHoverHandler::acceptEditor(IEditor *editor)
{
return editor->context().contains(Constants::C_QMLJSEDITOR_ID);
}
@@ -147,8 +148,8 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
return QString();
}
-bool HoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Document::Ptr &qmlDocument,
- const ObjectValue *value, const QStringList &qName)
+bool QmlJSHoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Document::Ptr &qmlDocument,
+ const ObjectValue *value, const QStringList &qName)
{
QString moduleName = getModuleName(scopeChain, qmlDocument, value);
QString helpId;
@@ -175,21 +176,19 @@ bool HoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Document::
break;
return false;
} while (0);
- setLastHelpItemIdentified(TextEditor::HelpItem(helpId, qName.join(QLatin1Char('.')),
- TextEditor::HelpItem::QmlComponent));
+ setLastHelpItemIdentified(HelpItem(helpId, qName.join(QLatin1Char('.')), HelpItem::QmlComponent));
return true;
}
-void HoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos)
+void QmlJSHoverHandler::identifyMatch(BaseTextEditorWidget *editorWidget, int pos)
{
reset();
if (!m_modelManager)
return;
- QmlJSEditorWidget *qmlEditor = qobject_cast<QmlJSEditorWidget *>(editor->widget());
- if (!qmlEditor)
- return;
+ QmlJSEditorWidget *qmlEditor = qobject_cast<QmlJSEditorWidget *>(editorWidget);
+ QTC_ASSERT(qmlEditor, return);
const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->qmlJsEditorDocument()->semanticInfo();
if (!semanticInfo.isValid() || qmlEditor->qmlJsEditorDocument()->isSemanticInfoOutdated())
@@ -254,10 +253,10 @@ void HoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos)
setQmlHelpItem(scopeChain, qmlDocument, node);
}
-bool HoverHandler::matchDiagnosticMessage(QmlJSEditorWidget *qmlEditor, int pos)
+bool QmlJSHoverHandler::matchDiagnosticMessage(QmlJSEditorWidget *qmlEditor, int pos)
{
foreach (const QTextEdit::ExtraSelection &sel,
- qmlEditor->extraSelections(TextEditor::BaseTextEditorWidget::CodeWarningsSelection)) {
+ qmlEditor->extraSelections(BaseTextEditorWidget::CodeWarningsSelection)) {
if (pos >= sel.cursor.selectionStart() && pos <= sel.cursor.selectionEnd()) {
setToolTip(sel.format.toolTip());
return true;
@@ -273,7 +272,7 @@ bool HoverHandler::matchDiagnosticMessage(QmlJSEditorWidget *qmlEditor, int pos)
return false;
}
-bool HoverHandler::matchColorItem(const ScopeChain &scopeChain,
+bool QmlJSHoverHandler::matchColorItem(const ScopeChain &scopeChain,
const Document::Ptr &qmlDocument,
const QList<AST::Node *> &astPath,
unsigned pos)
@@ -331,7 +330,7 @@ bool HoverHandler::matchColorItem(const ScopeChain &scopeChain,
return false;
}
-void HoverHandler::handleOrdinaryMatch(const ScopeChain &scopeChain, AST::Node *node)
+void QmlJSHoverHandler::handleOrdinaryMatch(const ScopeChain &scopeChain, AST::Node *node)
{
if (node && !(AST::cast<AST::StringLiteral *>(node) != 0 ||
AST::cast<AST::NumericLiteral *>(node) != 0)) {
@@ -340,7 +339,7 @@ void HoverHandler::handleOrdinaryMatch(const ScopeChain &scopeChain, AST::Node *
}
}
-void HoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *node)
+void QmlJSHoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *node)
{
const Imports *imports = scopeChain.context()->imports(scopeChain.document().data());
if (!imports)
@@ -368,22 +367,22 @@ void HoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *nod
}
}
-void HoverHandler::reset()
+void QmlJSHoverHandler::reset()
{
m_colorTip = QColor();
}
-void HoverHandler::operateTooltip(TextEditor::BaseTextEditor *editor, const QPoint &point)
+void QmlJSHoverHandler::operateTooltip(BaseTextEditorWidget *editorWidget, const QPoint &point)
{
if (toolTip().isEmpty())
Utils::ToolTip::hide();
else if (m_colorTip.isValid())
- Utils::ToolTip::show(point, Utils::ColorContent(m_colorTip), editor->widget());
+ Utils::ToolTip::show(point, Utils::ColorContent(m_colorTip), editorWidget);
else
- Utils::ToolTip::show(point, Utils::TextContent(toolTip()), editor->widget());
+ Utils::ToolTip::show(point, Utils::TextContent(toolTip()), editorWidget);
}
-void HoverHandler::prettyPrintTooltip(const QmlJS::Value *value,
+void QmlJSHoverHandler::prettyPrintTooltip(const QmlJS::Value *value,
const QmlJS::ContextPtr &context)
{
if (! value)
@@ -451,7 +450,7 @@ static const ObjectValue *isMember(const ScopeChain &scopeChain,
return owningObject;
}
-bool HoverHandler::setQmlHelpItem(const ScopeChain &scopeChain,
+bool QmlJSHoverHandler::setQmlHelpItem(const ScopeChain &scopeChain,
const Document::Ptr &qmlDocument,
AST::Node *node)
{
@@ -492,8 +491,7 @@ bool HoverHandler::setQmlHelpItem(const ScopeChain &scopeChain,
helpId.clear();
} while (0);
if (!helpId.isEmpty()) {
- setLastHelpItemIdentified(
- TextEditor::HelpItem(helpId, name, TextEditor::HelpItem::QmlProperty));
+ setLastHelpItemIdentified(HelpItem(helpId, name, HelpItem::QmlProperty));
return true;
}
}
diff --git a/src/plugins/qmljseditor/qmljshoverhandler.h b/src/plugins/qmljseditor/qmljshoverhandler.h
index 6a45f4a87e..c0fe356fdf 100644
--- a/src/plugins/qmljseditor/qmljshoverhandler.h
+++ b/src/plugins/qmljseditor/qmljshoverhandler.h
@@ -52,23 +52,22 @@ class ObjectValue;
}
namespace QmlJSEditor {
-
namespace Internal {
class QmlJSEditorWidget;
-class HoverHandler : public TextEditor::BaseHoverHandler
+class QmlJSHoverHandler : public TextEditor::BaseHoverHandler
{
Q_OBJECT
public:
- HoverHandler(QObject *parent = 0);
+ QmlJSHoverHandler(QObject *parent = 0);
private:
void reset();
- virtual bool acceptEditor(Core::IEditor *editor);
- virtual void identifyMatch(TextEditor::BaseTextEditor *editor, int pos);
- virtual void operateTooltip(TextEditor::BaseTextEditor *editor, const QPoint &point);
+ bool acceptEditor(Core::IEditor *editor);
+ void identifyMatch(TextEditor::BaseTextEditorWidget *editorWidget, int pos);
+ void operateTooltip(TextEditor::BaseTextEditorWidget *editorWidget, const QPoint &point);
bool matchDiagnosticMessage(QmlJSEditorWidget *qmlEditor, int pos);
bool matchColorItem(const QmlJS::ScopeChain &lookupContext,
diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp
index d382548a10..7a46d5fb11 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
diff --git a/src/plugins/texteditor/basehoverhandler.h b/src/plugins/texteditor/basehoverhandler.h
index 7d487b21b1..16611c6f48 100644
--- a/src/plugins/texteditor/basehoverhandler.h
+++ b/src/plugins/texteditor/basehoverhandler.h
@@ -32,13 +32,7 @@
#include "texteditor_global.h"
#include "helpitem.h"
-
-#include <QObject>
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-class QPoint;
-QT_END_NAMESPACE
+#include <texteditor/codeassist/keywordscompletionassist.h>
namespace Core { class IEditor; }
@@ -55,11 +49,6 @@ public:
BaseHoverHandler(QObject *parent = 0);
~BaseHoverHandler();
-private slots:
- void editorOpened(Core::IEditor *editor);
- void showToolTip(TextEditor::BaseTextEditor *editor, const QPoint &point, int pos);
- void updateContextHelpId(TextEditor::BaseTextEditor *editor, int pos);
-
protected:
void setToolTip(const QString &tooltip);
void appendToolTip(const QString &extension);
@@ -74,13 +63,17 @@ protected:
const HelpItem &lastHelpItemIdentified() const;
private:
+ void editorOpened(Core::IEditor *editor);
+ void showToolTip(BaseTextEditor *editor, const QPoint &point, int pos);
+ void updateContextHelpId(BaseTextEditor *editor, int pos);
+
void clear();
void process(BaseTextEditor *editor, int pos);
virtual bool acceptEditor(Core::IEditor *editor) = 0;
- virtual void identifyMatch(BaseTextEditor *editor, int pos) = 0;
+ virtual void identifyMatch(BaseTextEditorWidget *editorWidget, int pos) = 0;
virtual void decorateToolTip();
- virtual void operateTooltip(BaseTextEditor *editor, const QPoint &point);
+ virtual void operateTooltip(BaseTextEditorWidget *editorWidget, const QPoint &point);
bool m_diagnosticTooltip;
QString m_toolTip;