############################################################################## ################################# SLOTS #################################### ############################################################################## ! expand the aspect \c aspect (the tree index corresponding to it) in the tree view and makes it visible and selected. Called when a new aspect is added to the
| 549 | and makes it visible and selected. Called when a new aspect is added to the project. |
| 550 | */ |
| 551 | void ProjectExplorer::aspectAdded(const AbstractAspect* aspect) { |
| 552 | if (m_project->isLoading() || m_project->aspectAddedSignalSuppressed()) |
| 553 | return; |
| 554 | |
| 555 | // don't do anything if hidden aspects were added |
| 556 | if (aspect->isHidden()) |
| 557 | return; |
| 558 | |
| 559 | // don't do anything for newly added: |
| 560 | // * data spreadsheets of data picker curves |
| 561 | // * notes with fit results |
| 562 | if ((aspect->type() == AspectType::Spreadsheet && aspect->parentAspect()->type() == AspectType::DatapickerCurve) |
| 563 | || (aspect->type() == AspectType::Note && aspect->parentAspect()->type() == AspectType::XYFitCurve)) |
| 564 | return; |
| 565 | |
| 566 | const auto* tree_model = qobject_cast<AspectTreeModel*>(m_treeView->model()); |
| 567 | const auto& index = tree_model->modelIndexOfAspect(aspect); |
| 568 | |
| 569 | // expand and make the aspect visible |
| 570 | // no need to expand and to show child columns of a statistics spreadsheet |
| 571 | if (aspect->type() != AspectType::StatisticsSpreadsheet) |
| 572 | m_treeView->setExpanded(index, true); |
| 573 | |
| 574 | // newly added columns are only expanded but not selected, return here |
| 575 | if (aspect->type() == AspectType::Column) { |
| 576 | m_treeView->setExpanded(tree_model->modelIndexOfAspect(aspect->parentAspect()), true); |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | m_treeView->scrollTo(index); |
| 581 | m_treeView->setCurrentIndex(index); |
| 582 | m_treeView->header()->resizeSections(QHeaderView::ResizeToContents); |
| 583 | m_treeView->header()->resizeSection(0, m_treeView->header()->sectionSize(0) * 1.2); |
| 584 | } |
| 585 | |
| 586 | void ProjectExplorer::navigateTo(const QString& path) { |
| 587 | const auto* tree_model = dynamic_cast<AspectTreeModel*>(m_treeView->model()); |
nothing calls this directly
no test coverage detected