- enhancement: keep current position in the class browser after contents modified

This commit is contained in:
Roy Qu 2022-10-23 16:43:26 +08:00
parent b4deb9299b
commit f348f0782a
1 changed files with 1 additions and 11 deletions

View File

@ -4148,9 +4148,7 @@ void MainWindow::onClassBrowserRefreshEnd()
{
QModelIndex index = mClassBrowserModel.modelIndexForStatement(mClassBrowserCurrentStatement);
if (index.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
ui->classBrowser->expandRecursively(index);
#endif
ui->classBrowser->expand(index);
ui->classBrowser->setCurrentIndex(index);
}
}
@ -6261,11 +6259,7 @@ void MainWindow::on_actionAdd_to_project_triggered()
QModelIndex parentIndex = mProject->model()->getParentIndex(newUnit->node().get());
parentIndex = mProjectProxyModel->mapFromSource(parentIndex);
if (parentIndex.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
ui->projectView->expandRecursively(parentIndex);
#else
ui->projectView->expand(parentIndex);
#endif
}
if (index.isValid()) {
ui->projectView->setCurrentIndex(index);
@ -6684,11 +6678,7 @@ void MainWindow::setProjectViewCurrentNode(PProjectModelNode node)
QModelIndex parentIndex = mProject->model()->getParentIndex(node.get());
parentIndex = mProjectProxyModel->mapFromSource(parentIndex);
if (parentIndex.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
ui->projectView->expandRecursively(parentIndex);
#else
ui->projectView->expand(parentIndex);
#endif
}
QModelIndex index = mProject->model()->getNodeIndex(node.get());
index = mProjectProxyModel->mapFromSource(index);