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

Method setTemplateIdx

app/src/DataModel/Scripting/FrameParser.cpp:726–748  ·  view source on GitHub ↗

* @brief Loads the template at idx into the source and saves it to the project. */

Source from the content-addressed store, hash-verified

724 * @brief Loads the template at idx into the source and saves it to the project.
725 */
726void DataModel::FrameParser::setTemplateIdx(int sourceId, int idx)
727{
728 if (languageForSource(sourceId) == SerialStudio::Native) {
729 setNativeTemplateIdx(sourceId, idx);
730 return;
731 }
732
733 if (idx < 0 || idx >= m_templateFiles.size())
734 return;
735
736 engineForSource(sourceId).templateIdx = idx;
737 const QString code = templateCode(sourceId);
738
739 if (loadScript(sourceId, code, !m_suppressMessageBoxes)) {
740 auto& model = DataModel::ProjectModel::instance();
741 if (sourceId == 0)
742 model.setFrameParserCode(code);
743 else
744 model.updateSourceFrameParser(sourceId, code);
745
746 model.setModified(true);
747 }
748}
749
750/**
751 * @brief Persists the native template at idx (with schema defaults) for the source; params are

Callers 3

switchLanguageMethod · 0.80
switchNativeLanguageMethod · 0.80
selectTemplateMethod · 0.80

Calls 4

setFrameParserCodeMethod · 0.80
setModifiedMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected