* @brief Snapshots the current driver settings for source @p sourceId into * Source::connectionSettings. */
| 1705 | * Source::connectionSettings. |
| 1706 | */ |
| 1707 | void 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. |
no test coverage detected