MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / wireSourceSignals

Method wireSourceSignals

app/src/DataModel/ProjectEditor.cpp:577–614  ·  view source on GitHub ↗

* @brief Wires ProjectModel source add/delete signals into selection bookkeeping. */

Source from the content-addressed store, hash-verified

575 * @brief Wires ProjectModel source add/delete signals into selection bookkeeping.
576 */
577void 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.

Callers

nothing calls this directly

Calls 4

beginMethod · 0.80
setCurrentIndexMethod · 0.80
keyMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected