MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / storeINI_

Method storeINI_

src/openms_gui/source/VISUAL/DIALOGS/TOPPASToolConfigDialog.cpp:140–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 }
139
140 void TOPPASToolConfigDialog::storeINI_()
141 {
142 //nothing to save
143 if (param_->empty())
144 return;
145
146 filename_ = QFileDialog::getSaveFileName(this, tr("Save ini file"), default_dir_.c_str(), tr("ini files (*.ini)"));
147 //no file selected
148 if (filename_.isEmpty())
149 return;
150
151 if (!filename_.endsWith(".ini"))
152 filename_.append(".ini");
153
154 bool was_modified = editor_->isModified();
155 editor_->store();
156 if (was_modified) editor_->setModified(true);
157
158 arg_param_.insert(tool_name_ + ":1:", *param_);
159 try
160 {
161 QString tmp_ini_file = File::getTempDirectory().toQString() + QDir::separator() + "TOPPAS_" + tool_name_.toQString() + "_";
162 if (!tool_type_.empty())
163 {
164 tmp_ini_file += tool_type_.toQString() + "_";
165 }
166 tmp_ini_file += File::getUniqueName().toQString() + "_tmp.ini";
167 //store current parameters
168 ParamXMLFile paramFile;
169 paramFile.store(tmp_ini_file.toStdString(), arg_param_);
170 //restore other parameters that might be missing
171 QString executable = File::findSiblingTOPPExecutable(tool_name_).toQString();
172 QStringList args;
173 args << "-write_ini" << filename_ << "-ini" << tmp_ini_file;
174 if (!tool_type_.empty())
175 {
176 args << "-type" << tool_type_.toQString();
177 }
178
179 if (QProcess::execute(executable, args) != 0)
180 {
181 QMessageBox::critical(nullptr, "Error", (String("Could not execute '\"") + executable + "\" \"" + args.join("\" \"") + "\"'!\n\nMake sure the TOPP tools are present in '" + File::getExecutablePath() + "', that you have permission to write to the temporary file path, and that there is space left in the temporary file path.").c_str());
182 return;
183 }
184 }
185 catch (Exception::BaseException& e)
186 {
187 QMessageBox::critical(this, "Error", (String("Error storing INI file: ") + e.what()).c_str());
188 return;
189 }
190 }
191
192}

Callers

nothing calls this directly

Calls 9

setModifiedMethod · 0.80
StringClass · 0.50
emptyMethod · 0.45
isEmptyMethod · 0.45
appendMethod · 0.45
isModifiedMethod · 0.45
storeMethod · 0.45
insertMethod · 0.45
toQStringMethod · 0.45

Tested by

no test coverage detected