* @brief Builds a default Source[0] from the UI driver state when JSON has no sources array. */
| 2652 | * @brief Builds a default Source[0] from the UI driver state when JSON has no sources array. |
| 2653 | */ |
| 2654 | void DataModel::ProjectModel::seedDefaultSourceFromUi(const QString& legacyParserCode) |
| 2655 | { |
| 2656 | DataModel::Source defaultSource; |
| 2657 | defaultSource.sourceId = 0; |
| 2658 | defaultSource.title = tr("Device A"); |
| 2659 | auto& cm = IO::ConnectionManager::instance(); |
| 2660 | defaultSource.busType = static_cast<int>(cm.busType()); |
| 2661 | defaultSource.frameStart = m_frameStartSequence; |
| 2662 | defaultSource.frameEnd = m_frameEndSequence; |
| 2663 | defaultSource.checksumAlgorithm = m_checksumAlgorithm; |
| 2664 | defaultSource.frameDetection = static_cast<int>(m_frameDetection); |
| 2665 | defaultSource.decoderMethod = static_cast<int>(m_frameDecoder); |
| 2666 | defaultSource.hexadecimalDelimiters = m_hexadecimalDelimiters; |
| 2667 | defaultSource.frameParserCode = |
| 2668 | legacyParserCode.isEmpty() ? FrameParser::defaultTemplateCode() : legacyParserCode; |
| 2669 | |
| 2670 | IO::HAL_Driver* uiDriver = cm.uiDriverForBusType(cm.busType()); |
| 2671 | if (uiDriver) { |
| 2672 | QJsonObject settings; |
| 2673 | for (const auto& prop : uiDriver->driverProperties()) |
| 2674 | settings.insert(prop.key, QJsonValue::fromVariant(prop.value)); |
| 2675 | |
| 2676 | const auto deviceId = uiDriver->deviceIdentifier(); |
| 2677 | if (!deviceId.isEmpty()) |
| 2678 | settings.insert(QStringLiteral("deviceId"), deviceId); |
| 2679 | |
| 2680 | defaultSource.connectionSettings = settings; |
| 2681 | } |
| 2682 | |
| 2683 | m_sources.push_back(defaultSource); |
| 2684 | } |
| 2685 | |
| 2686 | /** |
| 2687 | * @brief Truncates multi-source projects to one source on GPL builds with a user warning. |
nothing calls this directly
no test coverage detected