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

WIP: load combo box

parent 0dd1e4ae
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@
#include "ui_edit_tandem_preset_dialog.h"
#include <QSettings>
#include <QDir>
EditTandemPresetDialog::EditTandemPresetDialog(QWidget * parent):
......@@ -70,6 +71,7 @@ void EditTandemPresetDialog::setTandemParametersFiles(const TandemParametersFile
}
_tandem_params = _p_tandem_preset_file->getTandemParameters();
fillPresetComboBox();
populate();
}
......@@ -95,17 +97,13 @@ void EditTandemPresetDialog::doSave() {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
_p_tandem_preset_file->setTandemParameters(_tandem_params);
fillPresetComboBox();
}
void EditTandemPresetDialog::doLoad() {
int index = ui->preset_combobox->currentIndex();
int index = ui->preset_combo_box->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 {
......@@ -113,16 +111,38 @@ if (_p_tandem_preset_file == nullptr) {
}
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));
_p_tandem_preset_file = new TandemParametersFile(
ui->preset_combo_box->itemData(index).value<QString>());
_tandem_params = _p_tandem_preset_file->getTandemParameters();
populate();
}
}
void EditTandemPresetDialog::doEdit() {
void EditTandemPresetDialog::fillPresetComboBox() {
ui->preset_combo_box->clear();
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
QString default_preset_name = _tandem_params.getMethodName();
QDir preset_dir(default_preset_location);
QStringList filters;
filters << "*.xml";
preset_dir.setNameFilters(filters);
for (QFileInfo file_info: preset_dir.entryInfoList() ) {
ui->preset_combo_box->addItem(file_info.baseName(), QVariant(file_info.absoluteFilePath()));
}
int index = ui->preset_combo_box->findText(default_preset_name);
if ( index != -1 ) { // -1 for not found
ui->preset_combo_box->setCurrentIndex(index);
}
}
void EditTandemPresetDialog::doEdit(QString value) {
QObject *senderObj = sender();
QString senderObjName = senderObj->objectName();
qDebug() << "EditTandemPresetDialog::doEdit begin " << senderObjName;
qDebug() << "EditTandemPresetDialog::doEdit begin " << senderObjName << " " << value;
qDebug() << "EditTandemPresetDialog::doEdit end " << senderObjName;
}
void EditTandemPresetDialog::doHelp() {
......
......@@ -51,9 +51,10 @@ public slots:
void doHelp ();
void doSave();
void doCopy();
void doEdit();
void doEdit(QString value);
void doLoad();
private:
void fillPresetComboBox();
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