! * show the content of the project in the tree view */
| 319 | * show the content of the project in the tree view |
| 320 | */ |
| 321 | void ImportProjectDialog::refreshPreview() { |
| 322 | const QString& project = m_cbFileName->currentText(); |
| 323 | m_projectParser->setProjectFileName(project); |
| 324 | |
| 325 | #ifdef HAVE_LIBORIGIN |
| 326 | if (m_projectType == ProjectType::Origin) { |
| 327 | auto* originParser = reinterpret_cast<OriginProjectParser*>(m_projectParser); |
| 328 | bool hasUnusedObjects = false; |
| 329 | bool hasMultiLayerGraphs = false; |
| 330 | originParser->checkContent(hasUnusedObjects, hasMultiLayerGraphs); |
| 331 | |
| 332 | ui.lUnusedObjects->setVisible(hasUnusedObjects); |
| 333 | ui.chbUnusedObjects->setVisible(hasUnusedObjects); |
| 334 | originParser->setImportUnusedObjects(hasUnusedObjects && ui.chbUnusedObjects->isChecked()); |
| 335 | |
| 336 | ui.lGraphLayer->setVisible(hasMultiLayerGraphs); |
| 337 | ui.cbGraphLayer->setVisible(hasMultiLayerGraphs); |
| 338 | } |
| 339 | #endif |
| 340 | |
| 341 | delete ui.tvPreview->model(); |
| 342 | ui.tvPreview->setModel(m_projectParser->model()); |
| 343 | connect(ui.tvPreview->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ImportProjectDialog::selectionChanged); |
| 344 | |
| 345 | // show top-level containers only |
| 346 | if (ui.tvPreview->model()) { |
| 347 | QModelIndex root = ui.tvPreview->model()->index(0, 0); |
| 348 | showTopLevelOnly(root); |
| 349 | } |
| 350 | |
| 351 | // select the first top-level node and |
| 352 | // expand the tree to show all available top-level objects and adjust the header sizes |
| 353 | ui.tvPreview->setCurrentIndex(ui.tvPreview->model()->index(0, 0)); |
| 354 | ui.tvPreview->expandAll(); |
| 355 | ui.tvPreview->header()->resizeSections(QHeaderView::ResizeToContents); |
| 356 | } |
| 357 | |
| 358 | /*! |
| 359 | Hides the non-toplevel items of the model used in the tree view. |
nothing calls this directly
no test coverage detected