aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
blob: b957fd1c75870d92493ff80dd2ebf871d650d0d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "maintab.h"
#include "ui_maintab.h"
#include "addcylinderdialog.h"

#include <QLabel>

MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
				    ui(new Ui::MainTab()),
				    weightModel(new WeightModel()),
				    cylindersModel(new CylindersModel())
{
	ui->setupUi(this);
	ui->cylinders->setModel(cylindersModel);
	ui->weights->setModel(weightModel);
}

void MainTab::clearEquipment()
{
}

void MainTab::clearInfo()
{
	QList<QLabel*> labels;
	labels 	<< ui->sac << ui->otu << ui->oxygenhelium << ui->gasused
		<< ui->date << ui->divetime << ui->surfinterval
		<< ui->maxdepth << ui->avgdepth << ui->visibility
		<< ui->watertemperature << ui->airtemperature << ui->airpress;

	Q_FOREACH(QLabel *l, labels){
		l->setText(QString());
	}
}

void MainTab::clearStats()
{
	QList<QLabel*> labels;
	labels << ui->maxdepth_2 << ui->mindepth << ui->avgdepth
		<< ui->maxsac << ui->minsac << ui->avgsac
		<< ui->dives << ui->maxtemp << ui->mintemp << ui->avgtemp
		<< ui->totaltime << ui->avgtime << ui->longestdive << ui->shortestdive;

	Q_FOREACH(QLabel *l, labels){
		l->setText(QString());
	}
}

void MainTab::on_addCylinder_clicked()
{
	AddCylinderDialog dialog(this);
	cylinder_t *newCylinder = (cylinder_t*) malloc(sizeof(cylinder_t));
	newCylinder->type.description = "";

	dialog.setCylinder(newCylinder);
	int result = dialog.exec();
	if (result == QDialog::Rejected){
		return;
	}

	dialog.updateCylinder();
	cylindersModel->add(newCylinder);
}

void MainTab::on_editCylinder_clicked()
{
}

void MainTab::on_delCylinder_clicked()
{
}

void MainTab::reload()
{
	cylindersModel->update();
}