* @brief Wires ProjectModel source add/delete signals into selection bookkeeping. */
| 575 | * @brief Wires ProjectModel source add/delete signals into selection bookkeeping. |
| 576 | */ |
| 577 | void DataModel::ProjectEditor::wireSourceSignals() |
| 578 | { |
| 579 | auto& pm = DataModel::ProjectModel::instance(); |
| 580 | |
| 581 | connect( |
| 582 | &pm, |
| 583 | &DataModel::ProjectModel::sourceAdded, |
| 584 | this, |
| 585 | [this](int sourceId) { |
| 586 | if (!m_selectionModel) |
| 587 | return; |
| 588 | |
| 589 | for (auto it = m_sourceItems.begin(); it != m_sourceItems.end(); ++it) { |
| 590 | if (it.value().sourceId != sourceId) |
| 591 | continue; |
| 592 | |
| 593 | m_selectionModel->setCurrentIndex(it.key()->index(), QItemSelectionModel::ClearAndSelect); |
| 594 | return; |
| 595 | } |
| 596 | |
| 597 | m_pendingSelectionKind = PendingSelectionKind::Source; |
| 598 | m_pendingSelectionGroupId = -1; |
| 599 | m_pendingSelectionItemId = sourceId; |
| 600 | }, |
| 601 | Qt::QueuedConnection); |
| 602 | |
| 603 | connect( |
| 604 | &pm, |
| 605 | &DataModel::ProjectModel::sourceDeleted, |
| 606 | this, |
| 607 | [this] { |
| 608 | if (m_selectionModel) { |
| 609 | auto index = m_treeModel->index(0, 0); |
| 610 | m_selectionModel->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); |
| 611 | } |
| 612 | }, |
| 613 | Qt::QueuedConnection); |
| 614 | } |
| 615 | |
| 616 | /** |
| 617 | * @brief Wires editor self-signals that fan out form-model change notifications. |
nothing calls this directly
no test coverage detected