MCPcopy Create free account
hub / github.com/Kitware/ParaView / readFromFile

Method readFromFile

Qt/Python/pqPythonFileIO.cxx:89–132  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

87
88//-----------------------------------------------------------------------------
89bool 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//-----------------------------------------------------------------------------
135void pqPythonFileIO::PythonFile::start()

Callers 1

openFileMethod · 0.80

Calls 7

mainWidgetFunction · 0.85
translateFunction · 0.85
GetSwapFilenameFunction · 0.85
trFunction · 0.85
ReadFunction · 0.85
WriteFunction · 0.85
isEmptyMethod · 0.45

Tested by

no test coverage detected