* @brief Loads the control script from the project model into the editor. */
| 313 | * @brief Loads the control script from the project model into the editor. |
| 314 | */ |
| 315 | void 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. |
nothing calls this directly
no test coverage detected