| 58 | } |
| 59 | |
| 60 | bool INIFileEditorWindow::openFile(const String& filename) |
| 61 | { |
| 62 | if (filename.empty()) |
| 63 | { |
| 64 | filename_ = QFileDialog::getOpenFileName(this, tr("Open ini file"), current_path_.toQString(), tr("ini files (*.ini);; all files (*.*)")); |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | filename_ = filename.c_str(); |
| 69 | } |
| 70 | |
| 71 | if (!filename_.isEmpty()) |
| 72 | { |
| 73 | if (File::readable(filename_.toStdString())) |
| 74 | { |
| 75 | |
| 76 | param_.clear(); |
| 77 | ParamXMLFile paramFile; |
| 78 | try |
| 79 | { |
| 80 | paramFile.load(filename_.toStdString(), param_); |
| 81 | editor_->load(param_); |
| 82 | updateWindowTitle(editor_->isModified()); |
| 83 | return true; |
| 84 | } |
| 85 | catch (Exception::BaseException& e) |
| 86 | { |
| 87 | OPENMS_LOG_ERROR << "Error while parsing file '" << filename_.toStdString() << "'\n"; |
| 88 | OPENMS_LOG_ERROR << e << "\n"; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | QMessageBox::critical(this, "Error opening file", ("The file '" + filename_.toStdString() + "' does not exist, is not readable or not a proper INI file!").c_str()); |
| 93 | } |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | bool INIFileEditorWindow::saveFile() |
| 98 | { |