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

Method readCode

app/src/DataModel/Editors/ControlScriptEditor.cpp:315–336  ·  view source on GitHub ↗

* @brief Loads the control script from the project model into the editor. */

Source from the content-addressed store, hash-verified

313 * @brief Loads the control script from the project model into the editor.
314 */
315void DataModel::ControlScriptEditor::readCode()
316{
317 if (m_readingCode)
318 return;
319
320 m_readingCode = true;
321
322 QString code = DataModel::ProjectModel::instance().controlScriptCode();
323 if (code.isEmpty() && m_initialLoad)
324 code = defaultControlScript();
325
326 m_initialLoad = false;
327
328 if (m_widget.toPlainText() != code)
329 m_widget.setPlainText(code);
330
331 m_widget.document()->clearUndoRedoStacks();
332 m_widget.document()->setModified(false);
333
334 m_readingCode = false;
335 Q_EMIT modifiedChanged();
336}
337
338/**
339 * @brief Resets the editor to the default setup()/loop() template.

Callers

nothing calls this directly

Calls 4

defaultControlScriptFunction · 0.85
controlScriptCodeMethod · 0.80
isEmptyMethod · 0.80
setModifiedMethod · 0.80

Tested by

no test coverage detected