* @brief Persists a validated native template config and flips the source to Native. */
| 2861 | * @brief Persists a validated native template config and flips the source to Native. |
| 2862 | */ |
| 2863 | static void applyNativeTemplate(int sourceId, |
| 2864 | const QString& templateId, |
| 2865 | const QJsonObject& templateParams) |
| 2866 | { |
| 2867 | Q_ASSERT(sourceId >= 0); |
| 2868 | Q_ASSERT(!templateId.isEmpty()); |
| 2869 | |
| 2870 | const auto* tmpl = DataModel::nativeTemplateById(templateId); |
| 2871 | if (!tmpl) |
| 2872 | return; |
| 2873 | |
| 2874 | const auto params = |
| 2875 | templateParams.isEmpty() ? DataModel::nativeTemplateDefaults(*tmpl) : templateParams; |
| 2876 | |
| 2877 | auto& model = DataModel::ProjectModel::instance(); |
| 2878 | model.updateSourceFrameParserLanguage(sourceId, SerialStudio::Native); |
| 2879 | model.updateSourceFrameParserParams(sourceId, params); |
| 2880 | model.updateSourceFrameParserTemplate(sourceId, templateId); |
| 2881 | } |
| 2882 | |
| 2883 | /** |
| 2884 | * @brief Handles parserSetCode for the Native language: code carries the JSON descriptor. |
no test coverage detected