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

Function applyNativeTemplate

app/src/API/Handlers/ProjectHandler.cpp:2863–2881  ·  view source on GitHub ↗

* @brief Persists a validated native template config and flips the source to Native. */

Source from the content-addressed store, hash-verified

2861 * @brief Persists a validated native template config and flips the source to Native.
2862 */
2863static 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.

Callers 2

parserSetTemplateMethod · 0.85

Tested by

no test coverage detected