diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 8875253def1..aea16f3d8b4 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -157,7 +157,6 @@ QModelIndex QmlJSEditorWidget::outlineModelIndex() { if (!m_outlineModelIndex.isValid()) { m_outlineModelIndex = indexForPosition(position()); - emit outlineModelIndexChanged(m_outlineModelIndex); } return m_outlineModelIndex; } @@ -249,6 +248,7 @@ void QmlJSEditorWidget::updateOutlineIndexNow() m_outlineModelIndex = QModelIndex(); // invalidate QModelIndex comboIndex = outlineModelIndex(); + emit outlineModelIndexChanged(m_outlineModelIndex); if (comboIndex.isValid()) { bool blocked = m_outlineCombo->blockSignals(true); @@ -530,8 +530,6 @@ void QmlJSEditorWidget::createToolBar() this, &QmlJSEditorWidget::jumpToOutlineElement); connect(m_qmlJsEditorDocument->outlineModel(), &QmlOutlineModel::updated, static_cast(m_outlineCombo->view()), &QTreeView::expandAll); - connect(m_qmlJsEditorDocument->outlineModel(), &QmlOutlineModel::updated, - this, &QmlJSEditorWidget::updateOutlineIndexNow); connect(this, &QmlJSEditorWidget::cursorPositionChanged, &m_updateOutlineIndexTimer, static_cast(&QTimer::start)); diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 7c0edd5ab53..5dde3a8660a 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -66,6 +66,7 @@ public: QmlJSEditorDocument *qmlJsEditorDocument() const; QModelIndex outlineModelIndex(); + void updateOutlineIndexNow(); TextEditor::AssistInterface *createAssistInterface(TextEditor::AssistKind assistKind, TextEditor::AssistReason reason) const override; @@ -84,7 +85,6 @@ private: void modificationChanged(bool); void jumpToOutlineElement(int index); - void updateOutlineIndexNow(); void updateContextPane(); void showTextMarker(); diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index cb513f1ab56..26ae8b5fc6d 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -136,6 +136,7 @@ void QmlJSOutlineWidget::setEditor(QmlJSEditorWidget *editor) this, &QmlJSOutlineWidget::updateSelectionInTree); connect(m_editor->qmlJsEditorDocument()->outlineModel(), &QmlOutlineModel::updated, [this] () { m_treeView->expandAll(); + m_editor->updateOutlineIndexNow(); }); } @@ -147,8 +148,7 @@ QList QmlJSOutlineWidget::filterMenuActions() const void QmlJSOutlineWidget::setCursorSynchronization(bool syncWithCursor) { m_enableCursorSync = syncWithCursor; - if (m_enableCursorSync) - updateSelectionInTree(m_editor->outlineModelIndex()); + m_editor->updateOutlineIndexNow(); } void QmlJSOutlineWidget::restoreSettings(const QVariantMap &map) @@ -227,7 +227,7 @@ void QmlJSOutlineWidget::setShowBindings(bool showBindings) { m_filterModel->setFilterBindings(!showBindings); m_treeView->expandAll(); - updateSelectionInTree(m_editor->outlineModelIndex()); + m_editor->updateOutlineIndexNow(); } bool QmlJSOutlineWidget::syncCursor()