diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-01 15:37:41 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-01 16:02:34 -0700 |
commit | f45618f0c7ce5af85e0f69aab49ef20a1663bca1 (patch) | |
tree | 839eab034e60bd663e61810e1d4c84d1ac7b85ca /qt-ui/addweightsystemdialog.cpp | |
parent | 482bea84c2f218f515b3b16556197379623a8028 (diff) | |
download | subsurface-f45618f0c7ce5af85e0f69aab49ef20a1663bca1.tar.gz |
Create Add Weightsystem dialog
My first attempt to create a Qt dialog and to hook it up with the program.
Unsurprisingly this doesn't quite work as expected (i.e., the values I
enter aren't populated in the model), but it's a start...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/addweightsystemdialog.cpp')
-rw-r--r-- | qt-ui/addweightsystemdialog.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/qt-ui/addweightsystemdialog.cpp b/qt-ui/addweightsystemdialog.cpp new file mode 100644 index 000000000..6ac1c02f9 --- /dev/null +++ b/qt-ui/addweightsystemdialog.cpp @@ -0,0 +1,38 @@ +/* + * addweightsystemdialog.cpp + * + * classes for the add weightsystem dialog of Subsurface + * + */ +#include "addweightsystemdialog.h" +#include "ui_addweightsystemdialog.h" +#include <QComboBox> +#include <QDoubleSpinBox> +#include "../conversions.h" +#include "models.h" + +AddWeightsystemDialog::AddWeightsystemDialog(QWidget *parent) : ui(new Ui::AddWeightsystemDialog()) +{ + ui->setupUi(this); +} + +void AddWeightsystemDialog::setWeightsystem(weightsystem_t *ws) +{ + currentWeightsystem = ws; + + ui->description->insert(QString(ws->description)); + if (get_units()->weight == units::KG) + ui->weight->setValue(ws->weight.grams / 1000); + else + ui->weight->setValue(grams_to_lbs(ws->weight.grams)); +} + +void AddWeightsystemDialog::updateWeightsystem() +{ + currentWeightsystem->description = strdup(ui->description->text().toUtf8().data()); + if (get_units()->weight == units::KG) + currentWeightsystem->weight.grams = ui->weight->value() * 1000; + else + currentWeightsystem->weight.grams = lbs_to_grams(ui->weight->value()); +} + |