Skip to content
Snippets Groups Projects
Commit 0dd1e4ae authored by Langella Olivier's avatar Langella Olivier
Browse files

WIP: load combo box

parent fbb938fb
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@
#include "tandemparametersfile.h"
#include <QXmlSimpleReader>
#include <QXmlStreamWriter>
#include <QDir>
#include <pappsomspp/pappsoexception.h>
#include "../input/xtandemparamsaxhandler.h"
......@@ -63,19 +64,28 @@ bool TandemParametersFile::exists() const
return _param_source.exists();
}
void TandemParametersFile::setTandemParameters(const TandemParameters & parameters) const {
void TandemParametersFile::setTandemParameters(const TandemParameters & parameters) {
QFile xml_file(_param_source.absoluteFilePath());
QFile new_file(QString("%1/%2.xml").arg(_param_source.absolutePath()).arg(parameters.getMethodName()));
if (_param_source.absoluteFilePath() != QFileInfo( new_file).absoluteFilePath()) {
if (xml_file.exists()) {
//move if renamed
xml_file.remove();
}
}
QXmlStreamWriter * p_out;
if (xml_file.open(QIODevice::WriteOnly)) {
if (new_file.open(QIODevice::WriteOnly)) {
_param_source.setFile(new_file);
p_out = new QXmlStreamWriter();
p_out->setDevice(&xml_file);
p_out->setDevice(&new_file);
writeXmlParametersFile(p_out, parameters);
xml_file.close();
new_file.close();
delete p_out;
} else
{
throw pappso::PappsoException(QObject::tr("error : cannot open the XML X!Tandem parameter file : %1\n").arg(xml_file.fileName()));
throw pappso::PappsoException(QObject::tr("error : cannot open the XML X!Tandem parameter file : %1\n").arg(new_file.fileName()));
}
}
......
......@@ -54,13 +54,13 @@ public:
/** @brief write tandem parameters to XML file
*/
void setTandemParameters(const TandemParameters & parameters) const;
void setTandemParameters(const TandemParameters & parameters);
private :
void writeXmlParametersFile (QXmlStreamWriter * p_out, const TandemParameters & parameters) const;
private :
const QFileInfo _param_source;
QFileInfo _param_source;
};
......
......@@ -29,8 +29,10 @@
#include "edittandempresetdialog.h"
#include <QDebug>
#include <pappsomspp/pappsoexception.h>
#include "ui_edit_tandem_preset_dialog.h"
#include <QSettings>
EditTandemPresetDialog::EditTandemPresetDialog(QWidget * parent):
......@@ -71,6 +73,58 @@ void EditTandemPresetDialog::setTandemParametersFiles(const TandemParametersFile
populate();
}
void EditTandemPresetDialog::doCopy() {
ui->method_name_line_edit->setText("untitled");
readUi();
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
else {
delete _p_tandem_preset_file;
}
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
_p_tandem_preset_file = new TandemParametersFile(QString("%1/untitled.xml").arg(default_preset_location));
}
void EditTandemPresetDialog::doSave() {
readUi();
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
_p_tandem_preset_file->setTandemParameters(_tandem_params);
}
void EditTandemPresetDialog::doLoad() {
int index = ui->preset_combobox->currentIndex();
if ( index != -1 ) { // -1 for not found
ui->preset_combobox->itemData(index).value<QString>();
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
else {
delete _p_tandem_preset_file;
}
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
u
_p_tandem_preset_file = new TandemParametersFile(QString("%1/%2.xml").arg(default_preset_location).arg(ui->preset_combobox));
}
}
void EditTandemPresetDialog::doEdit() {
QObject *senderObj = sender();
QString senderObjName = senderObj->objectName();
qDebug() << "EditTandemPresetDialog::doEdit begin " << senderObjName;
qDebug() << "EditTandemPresetDialog::doEdit end " << senderObjName;
}
void EditTandemPresetDialog::doHelp() {
QObject *senderObj = sender();
QString senderObjName = senderObj->objectName();
......@@ -94,7 +148,7 @@ void EditTandemPresetDialog::doHelp() {
}
void EditTandemPresetDialog::readUi() {
_tandem_params.setMethodName(ui->method_name_line_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error units", ui->parent_ion_window_unit_combo_box->itemData(ui->parent_ion_window_unit_combo_box->currentIndex()).toString());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error minus", ui->parent_ion_lower_window_edit->text());
......
......@@ -49,6 +49,10 @@ public:
public slots:
void doHelp ();
void doSave();
void doCopy();
void doEdit();
void doLoad();
private:
void populate();
void readUi();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment