| 551 | } |
| 552 | |
| 553 | void MainWindow::loadStatus(const EditorStatus &status, bool duplicate) |
| 554 | { |
| 555 | LOG_INFO("Requesting loadStatus"); |
| 556 | setProblemURL(status.problemURL); |
| 557 | if (status.isLanguageSet) |
| 558 | setLanguage(status.language); |
| 559 | customCompileCommand = status.customCompileCommand; // this must be after setLanguage |
| 560 | if (!duplicate) |
| 561 | { |
| 562 | untitledIndex = status.untitledIndex; |
| 563 | setFilePath(status.filePath); |
| 564 | } |
| 565 | testcases->addCustomCheckers(status.customCheckers); |
| 566 | testcases->setCheckerIndex(status.checkerIndex); |
| 567 | savedText = status.savedText; |
| 568 | editor->setPlainText(status.editorText); |
| 569 | auto cursor = editor->textCursor(); |
| 570 | cursor.setPosition(status.editorAnchor); |
| 571 | cursor.setPosition(status.editorCursor, QTextCursor::KeepAnchor); |
| 572 | editor->setTextCursor(cursor); |
| 573 | editor->horizontalScrollBar()->setValue(status.horizontalScrollBarValue); |
| 574 | editor->verticalScrollBar()->setValue(status.verticalScrollbarValue); |
| 575 | customTimeLimit = status.customTimeLimit; |
| 576 | testcases->loadStatus(status.input, status.expected); |
| 577 | for (int i = 0; i < status.testcasesIsShow.count() && i < testcases->count(); ++i) |
| 578 | testcases->setChecked(i, status.testcasesIsShow[i].toBool()); |
| 579 | testcases->restoreSplitterStates(status.testCaseSplitterStates); |
| 580 | |
| 581 | if (!isUntitled()) |
| 582 | { |
| 583 | const auto info = QFileInfo(filePath); |
| 584 | if (info.exists()) |
| 585 | { |
| 586 | const auto mTime = info.fileTime(QFile::FileModificationTime); |
| 587 | if (mTime.isValid() && mTime.toMSecsSinceEpoch() > status.timestamp) |
| 588 | { |
| 589 | if (appWindow->isInitialized()) |
| 590 | onFileWatcherChanged(filePath); |
| 591 | else |
| 592 | { |
| 593 | // Change this to Qt::SingleShotConnection after migrating to Qt 6 |
| 594 | auto *connection = new QMetaObject::Connection; |
| 595 | *connection = connect(appWindow, &AppWindow::initialized, [this, connection] { |
| 596 | onFileWatcherChanged(filePath); |
| 597 | disconnect(*connection); |
| 598 | delete connection; |
| 599 | }); |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | void MainWindow::applyCompanion(const Extensions::CompanionData &data) |
| 607 | { |
nothing calls this directly
no test coverage detected