-----------------------------------------------------------------------------
| 87 | |
| 88 | //----------------------------------------------------------------------------- |
| 89 | bool pqPythonFileIO::PythonFile::readFromFile(QString& str) const |
| 90 | { |
| 91 | if (this->Name.isEmpty()) |
| 92 | { |
| 93 | QMessageBox::warning(pqCoreUtilities::mainWidget(), |
| 94 | QCoreApplication::translate("pqPythonFileIO", "Error"), |
| 95 | QCoreApplication::translate("pqPythonFileIO", "No Filename Given!")); |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | const QString swapFilename = ::GetSwapFilename(this->Name); |
| 100 | if (QFileInfo::exists(swapFilename)) |
| 101 | { |
| 102 | const auto userAnswer = pqCoreUtilities::promptUserGeneric(tr("Script Editor"), |
| 103 | tr("Paraview found an old automatic save file %1. Would you like to recover its content?"), |
| 104 | QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel, nullptr); |
| 105 | switch (userAnswer) |
| 106 | { |
| 107 | case QMessageBox::Yes: |
| 108 | { |
| 109 | const auto contents = ::Read(swapFilename, vtkPVSession::CLIENT); |
| 110 | ::Write(this->Name, this->Location, contents); |
| 111 | QFile::remove(swapFilename); |
| 112 | break; |
| 113 | } |
| 114 | case QMessageBox::Discard: |
| 115 | QFile::remove(swapFilename); |
| 116 | break; |
| 117 | |
| 118 | case QMessageBox::Cancel: |
| 119 | default: |
| 120 | return false; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | { |
| 125 | pqScopedOverrideCursor scopedWaitCursor(Qt::WaitCursor); |
| 126 | str = ::Read(this->Name, this->Location); |
| 127 | } |
| 128 | |
| 129 | pqPythonScriptEditor::bringFront(); |
| 130 | |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | //----------------------------------------------------------------------------- |
| 135 | void pqPythonFileIO::PythonFile::start() |
no test coverage detected