forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "qmljseditordocument.h"
|
||||
#include "qmljseditorplugin.h"
|
||||
#include "qmljsfindreferences.h"
|
||||
#include "qmljshoverhandler.h"
|
||||
#include "qmljsquickfixassist.h"
|
||||
#include "qmloutlinemodel.h"
|
||||
|
||||
@@ -901,6 +902,8 @@ QmlJSEditorFactory::QmlJSEditorFactory()
|
||||
setAutoCompleterCreator([]() { return new AutoCompleter; });
|
||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||
|
||||
addHoverHandler(new QmlJSHoverHandler);
|
||||
|
||||
setEditorActionHandlers(TextEditorActionHandler::Format
|
||||
| TextEditorActionHandler::UnCommentSelection
|
||||
| TextEditorActionHandler::UnCollapseAll
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "qmljseditor.h"
|
||||
#include "qmljseditorconstants.h"
|
||||
#include "qmljseditordocument.h"
|
||||
#include "qmljshoverhandler.h"
|
||||
#include "qmlfilewizard.h"
|
||||
#include "jsfilewizard.h"
|
||||
#include "qmljsoutline.h"
|
||||
@@ -224,7 +223,6 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
|
||||
m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider;
|
||||
addAutoReleasedObject(m_quickFixAssistProvider);
|
||||
addAutoReleasedObject(new QmlJSCompletionAssistProvider);
|
||||
addAutoReleasedObject(new QmlJSHoverHandler);
|
||||
|
||||
errorMessage->clear();
|
||||
|
||||
|
||||
@@ -92,16 +92,11 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
QmlJSHoverHandler::QmlJSHoverHandler(QObject *parent) : BaseHoverHandler(parent), m_modelManager(0)
|
||||
QmlJSHoverHandler::QmlJSHoverHandler() : m_modelManager(0)
|
||||
{
|
||||
m_modelManager = QmlJS::ModelManagerInterface::instance();
|
||||
}
|
||||
|
||||
bool QmlJSHoverHandler::acceptEditor(IEditor *editor)
|
||||
{
|
||||
return editor->context().contains(Constants::C_QMLJSEDITOR_ID);
|
||||
}
|
||||
|
||||
static inline QString getModuleName(const ScopeChain &scopeChain, const Document::Ptr &qmlDocument,
|
||||
const ObjectValue *value)
|
||||
{
|
||||
|
||||
@@ -39,10 +39,6 @@ QT_BEGIN_NAMESPACE
|
||||
template <class> class QList;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
|
||||
namespace TextEditor { class BaseTextEditor; }
|
||||
|
||||
namespace QmlJS {
|
||||
class ScopeChain;
|
||||
class Context;
|
||||
@@ -59,13 +55,13 @@ class QmlJSEditorWidget;
|
||||
class QmlJSHoverHandler : public TextEditor::BaseHoverHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlJSHoverHandler(QObject *parent = 0);
|
||||
QmlJSHoverHandler();
|
||||
|
||||
private:
|
||||
void reset();
|
||||
|
||||
bool acceptEditor(Core::IEditor *editor);
|
||||
void identifyMatch(TextEditor::TextEditorWidget *editorWidget, int pos);
|
||||
void operateTooltip(TextEditor::TextEditorWidget *editorWidget, const QPoint &point);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user