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

Method readCode

app/src/DataModel/Editors/JsCodeEditor.cpp:423–452  ·  view source on GitHub ↗

* @brief Reloads the editor text from the current project model code. */

Source from the content-addressed store, hash-verified

421 * @brief Reloads the editor text from the current project model code.
422 */
423void DataModel::JsCodeEditor::readCode()
424{
425 if (m_readingCode)
426 return;
427
428 m_readingCode = true;
429
430 QString code;
431 int lang = 0;
432 const auto& sources = DataModel::ProjectModel::instance().sources();
433 for (const auto& src : sources) {
434 if (src.sourceId == m_sourceId) {
435 code = src.frameParserCode;
436 lang = src.frameParserLanguage;
437 break;
438 }
439 }
440
441 if (code.isEmpty())
442 code = DataModel::ProjectModel::instance().frameParserCode();
443
444 setLanguage(lang);
445
446 m_widget.setPlainText(code);
447 m_widget.document()->clearUndoRedoStacks();
448 m_widget.document()->setModified(false);
449
450 m_readingCode = false;
451 Q_EMIT modifiedChanged();
452}
453
454/**
455 * @brief Selects all editor text.

Callers 4

setupProjectMethod · 0.45
parserSetLanguageMethod · 0.45
onConnectedChangedMethod · 0.45
switchNativeLanguageMethod · 0.45

Calls 3

isEmptyMethod · 0.80
frameParserCodeMethod · 0.80
setModifiedMethod · 0.80

Tested by

no test coverage detected