* @brief Reloads the editor text from the current project model code. */
| 421 | * @brief Reloads the editor text from the current project model code. |
| 422 | */ |
| 423 | void 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. |
no test coverage detected