QmlOutline: Ensure that element is always selected

Select parent element if the property isn't shown in outline (due to
filter).
This commit is contained in:
Kai Koehne
2010-09-03 12:40:39 +02:00
parent b0bc76ece0
commit 7c365061a4

View File

@@ -145,8 +145,16 @@ void QmlJSOutlineWidget::updateSelectionInTree(const QModelIndex &index)
return;
m_blockCursorSync = true;
m_treeView->selectionModel()->select(m_filterModel->mapFromSource(index), QItemSelectionModel::ClearAndSelect);
m_treeView->scrollTo(m_filterModel->mapFromSource(index));
QModelIndex baseIndex = index;
QModelIndex filterIndex = m_filterModel->mapFromSource(baseIndex);
while (baseIndex.isValid() && !filterIndex.isValid()) { // Search for ancestor index actually shown
baseIndex = baseIndex.parent();
filterIndex = m_filterModel->mapFromSource(baseIndex);
}
m_treeView->selectionModel()->select(filterIndex, QItemSelectionModel::ClearAndSelect);
m_treeView->scrollTo(filterIndex);
m_blockCursorSync = false;
}