* @brief Loads the template at idx into the source and saves it to the project. */
| 724 | * @brief Loads the template at idx into the source and saves it to the project. |
| 725 | */ |
| 726 | void 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 |
no test coverage detected