QmlJSEditor: cleanup updateOutlineIndexNow

It was called to often - it was already connected in setEditor method.
Change outlineModelIndex() to be just a getter and call the
updateOutlineIndexNow() where an update is necessary.

Change-Id: I6f30bfaff74237416c1aef5418860179c1f8ebf7
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
Tim Jenssen
2017-04-06 17:22:52 +02:00
committed by Robert Loehning
parent 2c1c51bbea
commit c643095f17
3 changed files with 5 additions and 7 deletions

View File

@@ -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<QTreeView *>(m_outlineCombo->view()), &QTreeView::expandAll);
connect(m_qmlJsEditorDocument->outlineModel(), &QmlOutlineModel::updated,
this, &QmlJSEditorWidget::updateOutlineIndexNow);
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
&m_updateOutlineIndexTimer, static_cast<void (QTimer::*)()>(&QTimer::start));