MCPcopy Create free account
hub / github.com/cpeditor/cpeditor / loadStatus

Method loadStatus

src/mainwindow.cpp:553–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553void 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
606void MainWindow::applyCompanion(const Extensions::CompanionData &data)
607{

Callers

nothing calls this directly

Calls 6

addCustomCheckersMethod · 0.80
setCheckerIndexMethod · 0.80
countMethod · 0.80
restoreSplitterStatesMethod · 0.80
isInitializedMethod · 0.80
setCheckedMethod · 0.45

Tested by

no test coverage detected