diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 23 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 14 | ||||
-rw-r--r-- | qt-ui/models.cpp | 1 |
3 files changed, 29 insertions, 9 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index df6ee69eb..5f668b2be 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -8,6 +8,8 @@ #include "ui_maintab.h" #include "addcylinderdialog.h" #include "addweightsystemdialog.h" +#include "../helpers.h" +#include "../statistics.h" #include <QLabel> @@ -66,6 +68,7 @@ void MainTab::clearStats() else \ ui->field->setText(d->field) + void MainTab::updateDiveInfo(int dive) { // So, this is what happens now: @@ -77,7 +80,7 @@ void MainTab::updateDiveInfo(int dive) // open the file maintab.ui on the designer // click on the item and check its objectName, // the access is ui->objectName from here on. - + volume_t sacVal; struct dive *d = get_dive(dive); UPDATE_TEXT(d, notes); UPDATE_TEXT(d, location); @@ -88,6 +91,24 @@ void MainTab::updateDiveInfo(int dive) ui->rating->setCurrentStars(d->rating); else ui->rating->setCurrentStars(0); + ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE)); + ui->averageDepthText->setText(get_depth_string(d->meandepth, TRUE)); + sacVal.mliter = d ? d->sac : 0; + ui->sacText->setText(get_volume_string(sacVal, TRUE).append("/min")); + ui->otuText->setText(QString("%1").arg( d ? d->otu : 0)); + ui->waterTemperatureText->setText(d ? get_temperature_string(d->watertemp, TRUE) : ""); + ui->airTemperatureText->setText(d ? get_temperature_string(d->airtemp, TRUE) : ""); + if (d && d->surface_pressure.mbar) + /* this is ALWAYS displayed in mbar */ + ui->airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar)); + else + ui->airPressureText->setText(QString("")); +#if 0 /* this fails to link, even though the function is defined in statistics.c / statistics.h */ + if (d) + ui->gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE)); + else +#endif + ui->gasUsedText->setText(""); } void MainTab::on_addCylinder_clicked() diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index e8fe80460..56ae64b0c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -32,14 +32,17 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), sortModel(new QSortFilterProxyModel()) { ui->setupUi(this); + readSettings(); sortModel->setSourceModel(model); ui->ListWidget->setModel(sortModel); setWindowIcon(QIcon(":subsurface-icon")); - connect(ui->ListWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(dive_selection_changed(QItemSelection,QItemSelection))); - - readSettings(); + QModelIndex firstDiveOrTrip = sortModel->index(0,0); + if (sortModel->index(0,0, firstDiveOrTrip).isValid()) + ui->ListWidget->setCurrentIndex(sortModel->index(0,0, firstDiveOrTrip)); + else + ui->ListWidget->setCurrentIndex(firstDiveOrTrip); } void MainWindow::on_actionNew_triggered() @@ -343,11 +346,6 @@ void MainWindow::readSettings() } ui->ListWidget->collapseAll(); ui->ListWidget->expand(sortModel->index(0,0)); - QModelIndex firstDiveOrTrip = sortModel->index(0,0); - if (sortModel->index(0,0, firstDiveOrTrip).isValid()) - ui->ListWidget->setCurrentIndex(sortModel->index(0,0, firstDiveOrTrip)); - else - ui->ListWidget->setCurrentIndex(firstDiveOrTrip); settings.endGroup(); settings.beginGroup("Units"); GET_UNIT(v, "feet", length, units::METERS, units::FEET); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index eb4d8974b..9a6edce98 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -677,6 +677,7 @@ void DiveTripModel::setupModelData() while (--i >= 0) { struct dive* dive = get_dive(i); + update_cylinder_related_info(dive); dive_trip_t* trip = dive->divetrip; DiveItem* diveItem = new DiveItem(); |