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

Method wireOutputWidgetSignals

app/src/DataModel/ProjectEditor.cpp:526–572  ·  view source on GitHub ↗

* @brief Wires ProjectModel output-widget add/delete signals into selection bookkeeping. */

Source from the content-addressed store, hash-verified

524 * @brief Wires ProjectModel output-widget add/delete signals into selection bookkeeping.
525 */
526void 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.

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