* @brief Wires ProjectModel output-widget add/delete signals into selection bookkeeping. */
| 524 | * @brief Wires ProjectModel output-widget add/delete signals into selection bookkeeping. |
| 525 | */ |
| 526 | void DataModel::ProjectEditor::wireOutputWidgetSignals() |
| 527 | { |
| 528 | auto& pm = DataModel::ProjectModel::instance(); |
| 529 | |
| 530 | connect( |
| 531 | &pm, |
| 532 | &DataModel::ProjectModel::outputWidgetAdded, |
| 533 | this, |
| 534 | [this](int groupId, int widgetId) { |
| 535 | if (!m_selectionModel) |
| 536 | return; |
| 537 | |
| 538 | for (auto it = m_outputWidgetItems.begin(); it != m_outputWidgetItems.end(); ++it) { |
| 539 | if (it.value().groupId != groupId || it.value().widgetId != widgetId) |
| 540 | continue; |
| 541 | |
| 542 | m_selectionModel->setCurrentIndex(it.key()->index(), QItemSelectionModel::ClearAndSelect); |
| 543 | return; |
| 544 | } |
| 545 | |
| 546 | m_pendingSelectionKind = PendingSelectionKind::OutputWidget; |
| 547 | m_pendingSelectionGroupId = groupId; |
| 548 | m_pendingSelectionItemId = widgetId; |
| 549 | }, |
| 550 | Qt::QueuedConnection); |
| 551 | |
| 552 | connect( |
| 553 | &pm, |
| 554 | &DataModel::ProjectModel::outputWidgetDeleted, |
| 555 | this, |
| 556 | [this](int groupId) { |
| 557 | if (!m_selectionModel) |
| 558 | return; |
| 559 | |
| 560 | for (auto it = m_groupItems.begin(); it != m_groupItems.end(); ++it) { |
| 561 | if (it.value().groupId != groupId) |
| 562 | continue; |
| 563 | |
| 564 | m_selectionModel->setCurrentIndex(it.key()->index(), QItemSelectionModel::ClearAndSelect); |
| 565 | return; |
| 566 | } |
| 567 | |
| 568 | auto index = m_treeModel->index(0, 0); |
| 569 | m_selectionModel->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); |
| 570 | }, |
| 571 | Qt::QueuedConnection); |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * @brief Wires ProjectModel source add/delete signals into selection bookkeeping. |
nothing calls this directly
no test coverage detected