diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index d005f12cb9e..1405779bd7e 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -661,7 +661,8 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) : m_outlineCombo(0), m_outlineModel(new QmlOutlineModel(this)), m_modelManager(0), - m_contextPane(0) + m_contextPane(0), + m_updateSelectedElements(false) { qRegisterMetaType("QmlJSEditor::Internal::SemanticInfo"); @@ -996,6 +997,16 @@ void QmlJSTextEditor::updateUses() m_updateUsesTimer->start(); } +bool QmlJSTextEditor::updateSelectedElements() const +{ + return m_updateSelectedElements; +} + +void QmlJSTextEditor::setUpdateSelectedElements(bool value) +{ + m_updateSelectedElements = value; +} + void QmlJSTextEditor::updateUsesNow() { if (document()->revision() != m_semanticInfo.revision()) { @@ -1040,7 +1051,6 @@ public: { m_document = doc; m_snapshot = snapshot; - m_lookupContext = LookupContext::create(m_document, m_snapshot, QList()); m_cursorPositionStart = startPosition; m_cursorPositionEnd = endPosition; m_selectedMembers.clear(); @@ -1068,7 +1078,7 @@ protected: return false; } - UiObjectInitializer *initializer(UiObjectMember *member) const + inline UiObjectInitializer *initializer(UiObjectMember *member) const { if (UiObjectDefinition *def = cast(member)) return def->initializer; @@ -1077,12 +1087,16 @@ protected: return 0; } - bool hasVisualPresentation(Node *ast) + inline bool hasVisualPresentation(Node *ast) { Bind *bind = m_document->bind(); const Interpreter::ObjectValue *objValue = bind->findQmlObject(ast); QStringList prototypes; + if (m_lookupContext.isNull()) { + m_lookupContext = LookupContext::create(m_document, m_snapshot, QList()); + } + while (objValue) { prototypes.append(objValue->className()); objValue = objValue->prototype(m_lookupContext->context()); @@ -1091,7 +1105,7 @@ protected: return prototypes.contains(QString("QGraphicsObject")); } - bool isIdBinding(UiObjectMember *member) const + inline bool isIdBinding(UiObjectMember *member) const { if (UiScriptBinding *script = cast(member)) { if (! script->qualifiedId) @@ -1110,22 +1124,22 @@ protected: return false; } - bool containsCursor(unsigned begin, unsigned end) + inline bool containsCursor(unsigned begin, unsigned end) { return m_cursorPositionStart >= begin && m_cursorPositionEnd <= end; } - bool intersectsCursor(unsigned begin, unsigned end) + inline bool intersectsCursor(unsigned begin, unsigned end) { return (m_cursorPositionEnd >= begin && m_cursorPositionStart <= end); } - bool isRangeSelected() const + inline bool isRangeSelected() const { return (m_cursorPositionStart != m_cursorPositionEnd); } - virtual void postVisit(Node *ast) + void postVisit(Node *ast) { if (!isRangeSelected() && !m_selectedMembers.isEmpty()) return; // nothing to do, we already have the results. @@ -1149,6 +1163,9 @@ protected: void QmlJSTextEditor::setSelectedElements() { + if (!m_updateSelectedElements) + return; + QTextCursor tc = textCursor(); QString wordAtCursor; QList offsets; @@ -1169,10 +1186,8 @@ void QmlJSTextEditor::setSelectedElements() if (m_semanticInfo.document) { SelectedElement selectedMembers; - QList members = selectedMembers(m_semanticInfo.document, m_semanticInfo.snapshot, startPos, endPos); - if (!members.isEmpty()) { foreach(UiObjectMember *m, members) { offsets << m->firstSourceLocation().begin(); diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 562bd64b3ff..058f5e6bd48 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -225,6 +225,9 @@ public: QmlOutlineModel *outlineModel() const; QModelIndex outlineModelIndex(); + bool updateSelectedElements() const; + void setUpdateSelectedElements(bool value); + public slots: void followSymbolUnderCursor(); void showContextPane(); @@ -309,6 +312,7 @@ private: QmlJS::IContextPane *m_contextPane; int m_oldCursorPosition; + bool m_updateSelectedElements; }; } // namespace Internal diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 55f43a9d719..7685dd2db1d 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -523,7 +523,8 @@ ProjectExplorer::Project *InspectorUi::debugProject() const bool InspectorUi::isShadowBuildProject() const { - if (!debugProject()) + // for .qmlproject based stuff, build dir is empty + if (!debugProject() || debugProjectBuildDirectory().isEmpty()) return false; return (debugProject()->projectDirectory() != debugProjectBuildDirectory()); diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp index 4d88481645e..ff6c7786191 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp @@ -186,6 +186,7 @@ void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor) QmlJSEditor::Internal::QmlJSTextEditor* qmljsEditor = qobject_cast(oldEditor->widget()); if (qmljsEditor && m_editors.contains(qmljsEditor)) { m_editors.removeOne(qmljsEditor); + qmljsEditor->setUpdateSelectedElements(false); disconnect(qmljsEditor, SIGNAL(selectedElementsChanged(QList,QString)), this, @@ -246,7 +247,7 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList offsets, const QStr return; QDeclarativeDebugObjectReference objectRefUnderCursor; - if (!wordAtCursor.isEmpty() && wordAtCursor[0].isUpper()) { + if (!wordAtCursor.isEmpty() && wordAtCursor[0].isLower()) { QList refs = m_clientProxy.data()->objectReferences(); foreach (const QDeclarativeDebugObjectReference &ref, refs) { if (ref.idString() == wordAtCursor) { @@ -691,6 +692,16 @@ void QmlJSLiveTextPreview::setClientProxy(ClientProxy *clientProxy) if (m_clientProxy.data()) { connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()), SLOT(updateDebugIds())); + + foreach(QWeakPointer qmlEditor, m_editors) { + if (qmlEditor) + qmlEditor.data()->setUpdateSelectedElements(true); + } + } else { + foreach(QWeakPointer qmlEditor, m_editors) { + if (qmlEditor) + qmlEditor.data()->setUpdateSelectedElements(false); + } } }