subsurface/qt-ui/addcylinderdialog.cpp
Tomaz Canabrava 92397a2bad Started the real code on the Qt Interface.
1 - Open File already open files, it tries to not break the Gtk version,
    but some methods on the GTK version still need to be called inside Qt
    because the code is too tight-coupled.

2 - Close file already close files, same comments for the open file dialog
    applies here.

3 - The code for adding new cylinders in the cylinder dialog is done,
    already works and it's integrated with the system.  There's a need to
    implement the edit and delete now, but it will be easyer since I'm
    starting to not get lost on the code.

4 - Some functions that were used to convert unities have been moved to
    convert.h ( can be changed later, put there because it's easyer to
    find something that converts in a convert.h =p ) because they were
    static functions that operated in the GTK version but I need those
    functions in the Qt version too.

[Dirk Hohndel: lots and lots of whitespace and coding style changes]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-13 14:08:16 -07:00

48 lines
1.5 KiB
C++

#include "addcylinderdialog.h"
#include "ui_addcylinderdialog.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include "../conversions.h"
AddCylinderDialog::AddCylinderDialog(QWidget *parent) : ui(new Ui::AddCylinderDialog())
{
ui->setupUi(this);
}
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();
}