forked from qt-creator/qt-creator
QmlDesigner: change interface for context pane
This commit is contained in:
@@ -52,7 +52,7 @@ class QMLJS_EXPORT IContextPane : public QObject
|
|||||||
public:
|
public:
|
||||||
IContextPane(QObject *parent = 0) : QObject(parent) {}
|
IContextPane(QObject *parent = 0) : QObject(parent) {}
|
||||||
virtual ~IContextPane() {}
|
virtual ~IContextPane() {}
|
||||||
virtual void apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, AST::Node *node, bool update) = 0;
|
virtual void apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, const QmlJS::Snapshot &snapshot, AST::Node *node, bool update) = 0;
|
||||||
virtual void setEnabled(bool) = 0;
|
virtual void setEnabled(bool) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ class ContextPaneWidget : public QFrame
|
|||||||
public:
|
public:
|
||||||
explicit ContextPaneWidget(QWidget *parent = 0);
|
explicit ContextPaneWidget(QWidget *parent = 0);
|
||||||
~ContextPaneWidget();
|
~ContextPaneWidget();
|
||||||
void activate(const QPoint &pos, const QPoint &alternative);
|
void activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2);
|
||||||
void rePosition(const QPoint &pos, const QPoint &alternative);
|
void rePosition(const QPoint &pos, const QPoint &alternative , const QPoint &alternative3);
|
||||||
void deactivate();
|
void deactivate();
|
||||||
BauhausColorDialog *colorDialog();
|
BauhausColorDialog *colorDialog();
|
||||||
void setProperties(QmlJS::PropertyReader *propertyReader);
|
void setProperties(QmlJS::PropertyReader *propertyReader);
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
#include <qmljs/qmljspropertyreader.h>
|
#include <qmljs/qmljspropertyreader.h>
|
||||||
#include <qmljs/qmljsrewriter.h>
|
#include <qmljs/qmljsrewriter.h>
|
||||||
#include <qmljs/qmljsindenter.h>
|
#include <qmljs/qmljsindenter.h>
|
||||||
|
#include <qmljs/qmljslookupcontext.h>
|
||||||
|
#include <qmljs/qmljsinterpreter.h>
|
||||||
|
#include <qmljs/qmljsbind.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
#include <texteditor/tabsettings.h>
|
#include <texteditor/tabsettings.h>
|
||||||
#include <colorwidget.h>
|
#include <colorwidget.h>
|
||||||
@@ -62,7 +65,7 @@ QmlContextPane::~QmlContextPane()
|
|||||||
m_widget.clear();
|
m_widget.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, Node *node, bool update)
|
void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, const QmlJS::Snapshot &snapshot, AST::Node *node, bool update)
|
||||||
{
|
{
|
||||||
if (!Internal::BauhausPlugin::pluginInstance()->settings().enableContextPane)
|
if (!Internal::BauhausPlugin::pluginInstance()->settings().enableContextPane)
|
||||||
return;
|
return;
|
||||||
@@ -73,6 +76,15 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document:
|
|||||||
if (update && editor != m_editor)
|
if (update && editor != m_editor)
|
||||||
return; //do not update for different editor
|
return; //do not update for different editor
|
||||||
|
|
||||||
|
LookupContext::Ptr lookupContext = LookupContext::create(doc, snapshot, QList<Node*>());
|
||||||
|
const Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node);
|
||||||
|
|
||||||
|
QStringList prototypes;
|
||||||
|
while (scopeObject) {
|
||||||
|
prototypes.append(scopeObject->className());
|
||||||
|
scopeObject = scopeObject->prototype(lookupContext->context());
|
||||||
|
}
|
||||||
|
|
||||||
setEnabled(doc->isParsedCorrectly());
|
setEnabled(doc->isParsedCorrectly());
|
||||||
m_editor = editor;
|
m_editor = editor;
|
||||||
contextWidget()->setParent(editor->widget()->parentWidget());
|
contextWidget()->setParent(editor->widget()->parentWidget());
|
||||||
|
|||||||
@@ -1085,7 +1085,7 @@ bool QmlJSTextEditor::event(QEvent *e)
|
|||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::ShortcutOverride:
|
case QEvent::ShortcutOverride:
|
||||||
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape && m_contextPane) {
|
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape && m_contextPane) {
|
||||||
m_contextPane->apply(editableInterface(), m_semanticInfo.document, 0, false);
|
m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, 0, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1100,7 +1100,7 @@ void QmlJSTextEditor::wheelEvent(QWheelEvent *event)
|
|||||||
{
|
{
|
||||||
BaseTextEditor::wheelEvent(event);
|
BaseTextEditor::wheelEvent(event);
|
||||||
if (m_contextPane)
|
if (m_contextPane)
|
||||||
m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.declaringMember(position()), true);
|
m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, m_semanticInfo.declaringMember(position()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditor::unCommentSelection()
|
void QmlJSTextEditor::unCommentSelection()
|
||||||
@@ -1344,7 +1344,7 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
|||||||
if (m_contextPane) {
|
if (m_contextPane) {
|
||||||
Node *newNode = m_semanticInfo.declaringMember(position());
|
Node *newNode = m_semanticInfo.declaringMember(position());
|
||||||
if (newNode) {
|
if (newNode) {
|
||||||
m_contextPane->apply(editableInterface(), doc, newNode, true);
|
m_contextPane->apply(editableInterface(), doc, m_semanticInfo.snapshot, newNode, true);
|
||||||
m_oldCurserPosition = position();
|
m_oldCurserPosition = position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1361,11 +1361,13 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
|||||||
|
|
||||||
void QmlJSTextEditor::onCursorPositionChanged()
|
void QmlJSTextEditor::onCursorPositionChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (m_contextPane) {
|
if (m_contextPane) {
|
||||||
Node *newNode = m_semanticInfo.declaringMember(position());
|
Node *newNode = m_semanticInfo.declaringMember(position());
|
||||||
Node *oldNode = m_semanticInfo.declaringMember(m_oldCurserPosition);
|
Node *oldNode = m_semanticInfo.declaringMember(m_oldCurserPosition);
|
||||||
if (oldNode != newNode)
|
if (oldNode != newNode)
|
||||||
m_contextPane->apply(editableInterface(), m_semanticInfo.document, newNode, false);
|
m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, newNode, false);
|
||||||
m_oldCurserPosition = position();
|
m_oldCurserPosition = position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user