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

Method captureSourceSettings

app/src/DataModel/ProjectModel.cpp:1707–1727  ·  view source on GitHub ↗

* @brief Snapshots the current driver settings for source @p sourceId into * Source::connectionSettings. */

Source from the content-addressed store, hash-verified

1705 * Source::connectionSettings.
1706 */
1707void DataModel::ProjectModel::captureSourceSettings(int sourceId)
1708{
1709 if (sourceId < 0 || sourceId >= static_cast<int>(m_sources.size()))
1710 return;
1711
1712 const auto busType = static_cast<SerialStudio::BusType>(m_sources[sourceId].busType);
1713 IO::HAL_Driver* driver = IO::ConnectionManager::instance().uiDriverForBusType(busType);
1714 if (!driver)
1715 return;
1716
1717 QJsonObject settings;
1718 for (const auto& prop : driver->driverProperties())
1719 settings.insert(prop.key, QJsonValue::fromVariant(prop.value));
1720
1721 const auto deviceId = driver->deviceIdentifier();
1722 if (!deviceId.isEmpty())
1723 settings.insert(QStringLiteral("deviceId"), deviceId);
1724
1725 m_sources[sourceId].connectionSettings = settings;
1726 setModified(true);
1727}
1728
1729/**
1730 * @brief Applies the source's saved connectionSettings to its live driver.

Callers 3

sourceConfigureMethod · 0.80
sourceSetPropertyMethod · 0.80

Calls 5

uiDriverForBusTypeMethod · 0.80
isEmptyMethod · 0.80
sizeMethod · 0.45
driverPropertiesMethod · 0.45
deviceIdentifierMethod · 0.45

Tested by

no test coverage detected