SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
optionsdialog.cpp
Go to the documentation of this file.
1// OptionsDialog.cpp
2#include "optionsdialog.h"
3#include <QVBoxLayout>
4#include <QLabel>
5#include <QPushButton>
6
7OptionsDialog::OptionsDialog(QMap<QString, double>* options, QWidget* parent)
8 : QDialog(parent), options_(options)
9{
10 setWindowTitle("SedSat Options");
11
12 auto* layout = new QVBoxLayout(this);
13 auto* formLayout = new QFormLayout;
14
15 // Create a QTextEdit for each option
16 for (auto it = options_->begin(); it != options_->end(); ++it) {
17 auto* edit = new QTextEdit(QString::number(it.value()));
18 edit->setFixedHeight(30); // like a line edit
19 editors_[it.key()] = edit;
20 formLayout->addRow(new QLabel(it.key()), edit);
21 }
22
23 layout->addLayout(formLayout);
24
25 // OK/Cancel buttons
26 auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
27 layout->addWidget(buttonBox);
28
29 connect(buttonBox, &QDialogButtonBox::accepted, this, &OptionsDialog::applyChanges);
30 connect(buttonBox, &QDialogButtonBox::accepted, this, &OptionsDialog::accept);
31 connect(buttonBox, &QDialogButtonBox::rejected, this, &OptionsDialog::reject);
32}
33
35 for (auto it = editors_.begin(); it != editors_.end(); ++it) {
36 bool ok = false;
37 double val = it.value()->toPlainText().toDouble(&ok);
38 if (ok) {
39 (*options_)[it.key()] = val;
40 }
41 }
42}
OptionsDialog(QMap< QString, double > *options, QWidget *parent=nullptr)
QMap< QString, double > * options_
QMap< QString, QTextEdit * > editors_
Configuration options for data presentation and serialization.
Definition interface.h:31