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

Method commitAlarmBands

app/src/DataModel/ProjectEditor.cpp:4642–4666  ·  view source on GitHub ↗

* @brief Commits the result of the AlarmBandsEditor dialog into the currently-selected dataset. */

Source from the content-addressed store, hash-verified

4640 * @brief Commits the result of the AlarmBandsEditor dialog into the currently-selected dataset.
4641 */
4642void DataModel::ProjectEditor::commitAlarmBands(const QVariantList& bands)
4643{
4644 m_selectedDataset.alarmBands.clear();
4645 m_selectedDataset.alarmBands.reserve(bands.size());
4646 for (const auto& v : bands) {
4647 const auto m = v.toMap();
4648 DataModel::AlarmBand band;
4649 band.min = SerialStudio::toDouble(m.value(QStringLiteral("min")));
4650 band.max = SerialStudio::toDouble(m.value(QStringLiteral("max")));
4651 band.blink = m.value(QStringLiteral("blink"), false).toBool();
4652 band.color = m.value(QStringLiteral("color")).toString().simplified();
4653 band.label = m.value(QStringLiteral("label")).toString().simplified();
4654 const int sev =
4655 m.value(QStringLiteral("severity"), static_cast<int>(DataModel::AlarmSeverity::Warning))
4656 .toInt();
4657 band.severity = static_cast<DataModel::AlarmSeverity>(qBound(0, sev, 3));
4658 if (band.max > band.min)
4659 m_selectedDataset.alarmBands.push_back(std::move(band));
4660 }
4661
4662 auto& pm = DataModel::ProjectModel::instance();
4663 pm.updateDataset(
4664 m_selectedDataset.groupId, m_selectedDataset.datasetId, m_selectedDataset, false);
4665 buildDatasetModel(m_selectedDataset);
4666}
4667
4668/**
4669 * @brief Dispatches dataset form edits to ProjectModel, rebuilding only on tree-visible changes.

Callers

nothing calls this directly

Calls 4

updateDatasetMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected