mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
115ee47bfc
Added the code that will load and populate the Tank Info ComboBox that`s used by the user to select the Cylinder description. Code curerntly implements more than the GTK version since the GTK version of it was a plain-list, this one is a table based model that can be used in ListViews ( like we use now in the ComboBox ) but also in TableViews ( if there`s a need in the future to see everything that`s catalogued in the Tank Info struct. ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
/*
|
|
* addcylinderdialog.cpp
|
|
*
|
|
* classes for the add cylinder dialog of Subsurface
|
|
*
|
|
*/
|
|
#include "addcylinderdialog.h"
|
|
#include "ui_addcylinderdialog.h"
|
|
#include <QComboBox>
|
|
#include <QDoubleSpinBox>
|
|
#include "../conversions.h"
|
|
#include "models.h"
|
|
|
|
AddCylinderDialog::AddCylinderDialog(QWidget *parent) : ui(new Ui::AddCylinderDialog())
|
|
, tankInfoModel(new TankInfoModel())
|
|
{
|
|
ui->setupUi(this);
|
|
ui->cylinderType->setModel(tankInfoModel);
|
|
}
|
|
|
|
void AddCylinderDialog::setCylinder(cylinder_t *cylinder)
|
|
{
|
|
double volume, pressure;
|
|
int index;
|
|
|
|
currentCylinder = cylinder;
|
|
convert_volume_pressure(cylinder->type.size.mliter, cylinder->type.workingpressure.mbar, &volume, &pressure);
|
|
|
|
index = ui->cylinderType->findText(QString(cylinder->type.description));
|
|
ui->cylinderType->setCurrentIndex(index);
|
|
ui->size->setValue(volume);
|
|
ui->pressure->setValue(pressure);
|
|
|
|
ui->o2percent->setValue(cylinder->gasmix.o2.permille / 10.0);
|
|
ui->hepercent->setValue(cylinder->gasmix.he.permille / 10.0);
|
|
|
|
convert_pressure(cylinder->start.mbar, &pressure);
|
|
ui->start->setValue(pressure);
|
|
|
|
convert_pressure(cylinder->end.mbar, &pressure);
|
|
ui->end->setValue(pressure);
|
|
}
|
|
|
|
void AddCylinderDialog::updateCylinder()
|
|
{
|
|
QByteArray description = ui->cylinderType->currentText().toLocal8Bit();
|
|
|
|
currentCylinder->type.description = description.data();
|
|
currentCylinder->type.size.mliter = ui->size->value();
|
|
currentCylinder->type.workingpressure.mbar = ui->pressure->value();
|
|
currentCylinder->gasmix.o2.permille = ui->o2percent->value();
|
|
currentCylinder->gasmix.he.permille = ui->hepercent->value();
|
|
currentCylinder->start.mbar = ui->start->value();
|
|
currentCylinder->end.mbar = ui->end->value();
|
|
}
|
|
|