* @brief Wires ProjectModel group add/delete signals into selection bookkeeping. */
| 378 | * @brief Wires ProjectModel group add/delete signals into selection bookkeeping. |
| 379 | */ |
| 380 | void DataModel::ProjectEditor::wireGroupSignals() |
| 381 | { |
| 382 | auto& pm = DataModel::ProjectModel::instance(); |
| 383 | |
| 384 | connect( |
| 385 | &pm, |
| 386 | &DataModel::ProjectModel::groupDeleted, |
| 387 | this, |
| 388 | [this] { |
| 389 | if (!m_selectionModel) |
| 390 | return; |
| 391 | |
| 392 | if (m_groupsRootItem) { |
| 393 | m_selectionModel->setCurrentIndex(m_groupsRootItem->index(), |
| 394 | QItemSelectionModel::ClearAndSelect); |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | auto index = m_treeModel->index(0, 0); |
| 399 | m_selectionModel->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); |
| 400 | }, |
| 401 | Qt::QueuedConnection); |
| 402 | |
| 403 | connect( |
| 404 | &pm, |
| 405 | &DataModel::ProjectModel::groupAdded, |
| 406 | this, |
| 407 | [this](int groupId) { |
| 408 | if (!m_selectionModel) |
| 409 | return; |
| 410 | |
| 411 | for (auto it = m_groupItems.begin(); it != m_groupItems.end(); ++it) { |
| 412 | if (it.value().groupId != groupId) |
| 413 | continue; |
| 414 | |
| 415 | m_selectionModel->setCurrentIndex(it.key()->index(), QItemSelectionModel::ClearAndSelect); |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | m_pendingSelectionKind = PendingSelectionKind::Group; |
| 420 | m_pendingSelectionGroupId = groupId; |
| 421 | m_pendingSelectionItemId = -1; |
| 422 | }, |
| 423 | Qt::QueuedConnection); |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * @brief Wires ProjectModel dataset add/delete signals into selection bookkeeping. |
nothing calls this directly
no test coverage detected