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// SedSAT3 – Sediment Source Assessment Tool, version 3
2// U.S. Geological Survey. See LICENSE.md and DISCLAIMER.md in the repository root.
3
4// OptionsDialog.cpp
5#include "optionsdialog.h"
6#include <QVBoxLayout>
7#include <QLabel>
8#include <QPushButton>
9
10OptionsDialog::OptionsDialog(QMap<QString, double>* options, QWidget* parent)
11 : QDialog(parent), options_(options)
12{
13 setWindowTitle("SedSat Options");
14
15 auto* layout = new QVBoxLayout(this);
16 auto* formLayout = new QFormLayout;
17
18 // Create a QTextEdit for each option
19 for (auto it = options_->begin(); it != options_->end(); ++it) {
20 auto* edit = new QTextEdit(QString::number(it.value()));
21 edit->setFixedHeight(30); // like a line edit
22 editors_[it.key()] = edit;
23 formLayout->addRow(new QLabel(it.key()), edit);
24 }
25
26 layout->addLayout(formLayout);
27
28 // OK/Cancel buttons
29 auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
30 layout->addWidget(buttonBox);
31
32 connect(buttonBox, &QDialogButtonBox::accepted, this, &OptionsDialog::applyChanges);
33 connect(buttonBox, &QDialogButtonBox::accepted, this, &OptionsDialog::accept);
34 connect(buttonBox, &QDialogButtonBox::rejected, this, &OptionsDialog::reject);
35}
36
38 for (auto it = editors_.begin(); it != editors_.end(); ++it) {
39 bool ok = false;
40 double val = it.value()->toPlainText().toDouble(&ok);
41 if (ok) {
42 (*options_)[it.key()] = val;
43 }
44 }
45}
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:34