Outline: Make recalculation of current model index more robust

This commit is contained in:
Kai Koehne
2010-07-12 16:40:15 +02:00
parent b2694a33bb
commit 503f720f85
6 changed files with 23 additions and 21 deletions

View File

@@ -697,8 +697,12 @@ QmlOutlineModel *QmlJSTextEditor::outlineModel() const
return m_outlineModel;
}
QModelIndex QmlJSTextEditor::outlineModelIndex() const
QModelIndex QmlJSTextEditor::outlineModelIndex()
{
if (!m_outlineModelIndex.isValid()) {
m_outlineModelIndex = indexForPosition(position());
emit outlineModelIndexChanged(m_outlineModelIndex);
}
return m_outlineModelIndex;
}
@@ -822,10 +826,8 @@ void QmlJSTextEditor::jumpToMethod(int /*index*/)
void QmlJSTextEditor::updateMethodBoxIndex()
{
m_outlineModelIndex = indexForPosition(position());
emit outlineModelIndexChanged(m_outlineModelIndex);
QModelIndex comboIndex = m_outlineModelIndex;
m_outlineModelIndex = QModelIndex(); // invalidate
QModelIndex comboIndex = outlineModelIndex();
if (comboIndex.isValid()) {
bool blocked = m_methodCombo->blockSignals(true);
@@ -1364,8 +1366,6 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
QTreeView *treeView = static_cast<QTreeView*>(m_methodCombo->view());
treeView->expandAll();
// ComboBox only let's you select top level indexes for a QAbstractItemModel!
// therefore we've to fake a treeview by listview + indentation
if (m_contextPane) {
Node *newNode = m_semanticInfo.declaringMember(position());
@@ -1542,3 +1542,4 @@ void SemanticHighlighter::setModelManager(QmlJS::ModelManagerInterface *modelMan
{
m_modelManager = modelManager;
}

View File

@@ -217,7 +217,7 @@ public:
bool isOutdated() const;
QmlOutlineModel *outlineModel() const;
QModelIndex outlineModelIndex() const;
QModelIndex outlineModelIndex();
public slots:
void followSymbolUnderCursor();

View File

@@ -67,7 +67,6 @@ void QmlJSOutlineWidget::setCursorSynchronization(bool syncWithCursor)
void QmlJSOutlineWidget::modelUpdated()
{
m_treeView->expandAll();
updateSelectionInTree(m_editor.data()->outlineModelIndex());
}
void QmlJSOutlineWidget::updateSelectionInTree(const QModelIndex &index)