summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/TabDiveInformation.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-04-26 09:46:36 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-29 12:58:49 -0700
commit98a3eb414befe32f912b21e1db2fed17a2017943 (patch)
treeb3cfa6dc91f7efd3dd93ef6b4327a4016ded4d1b /desktop-widgets/tab-widgets/TabDiveInformation.cpp
parent88fbcefd4fa0e4d699240d96f48f8e9ab97b5e87 (diff)
downloadsubsurface-98a3eb414befe32f912b21e1db2fed17a2017943.tar.gz
Desktop: use current_dive in information tab
The information tab used displayed_dive to fill out its field. For consistency with the main tab and in a bigger effort to remove displayed_dive, use current_dive instead. Only clear the fields if no current_dive is set. The code used to clear the fields and overwrite them later. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveInformation.cpp')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveInformation.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
index aff781a3b..e2bbb4fbd 100644
--- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
@@ -37,47 +37,50 @@ void TabDiveInformation::clear()
void TabDiveInformation::updateData()
{
- clear();
+ if (!current_dive) {
+ clear();
+ return;
+ }
- ui->maxcnsText->setText(QString("%1\%").arg(displayed_dive.maxcns));
- ui->otuText->setText(QString("%1").arg(displayed_dive.otu));
- ui->maximumDepthText->setText(get_depth_string(displayed_dive.maxdepth, true));
- ui->averageDepthText->setText(get_depth_string(displayed_dive.meandepth, true));
- ui->dateText->setText(get_short_dive_date_string(displayed_dive.when));
- ui->waterTemperatureText->setText(get_temperature_string(displayed_dive.watertemp, true));
- ui->airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, true));
+ ui->maxcnsText->setText(QString("%1\%").arg(current_dive->maxcns));
+ ui->otuText->setText(QString("%1").arg(current_dive->otu));
+ ui->maximumDepthText->setText(get_depth_string(current_dive->maxdepth, true));
+ ui->averageDepthText->setText(get_depth_string(current_dive->meandepth, true));
+ ui->dateText->setText(get_short_dive_date_string(current_dive->when));
+ ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true));
+ ui->airTemperatureText->setText(get_temperature_string(current_dive->airtemp, true));
volume_t gases[MAX_CYLINDERS] = {};
- get_gas_used(&displayed_dive, gases);
+ get_gas_used(current_dive, gases);
QString volumes;
int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS];
- per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration);
+ per_cylinder_mean_depth(current_dive, select_dc(current_dive), mean, duration);
volume_t sac;
QString gaslist, SACs, separator;
gaslist = ""; SACs = ""; volumes = ""; separator = "";
for (int i = 0; i < MAX_CYLINDERS; i++) {
- if (!is_cylinder_used(&displayed_dive, i))
+ if (!is_cylinder_used(current_dive, i))
continue;
gaslist.append(separator); volumes.append(separator); SACs.append(separator);
separator = "\n";
- gaslist.append(gasname(displayed_dive.cylinder[i].gasmix));
+ gaslist.append(gasname(current_dive->cylinder[i].gasmix));
if (!gases[i].mliter)
continue;
volumes.append(get_volume_string(gases[i], true));
if (duration[i]) {
- sac.mliter = lrint(gases[i].mliter / (depth_to_atm(mean[i], &displayed_dive) * duration[i] / 60));
+ sac.mliter = lrint(gases[i].mliter / (depth_to_atm(mean[i], current_dive) * duration[i] / 60));
SACs.append(get_volume_string(sac, true).append(tr("/min")));
}
}
ui->gasUsedText->setText(volumes);
ui->oxygenHeliumText->setText(gaslist);
- ui->diveTimeText->setText(get_dive_duration_string(displayed_dive.duration.seconds, tr("h"), tr("min"), tr("sec"),
- " ", displayed_dive.dc.divemode == FREEDIVE));
+ ui->diveTimeText->setText(get_dive_duration_string(current_dive->duration.seconds, tr("h"), tr("min"), tr("sec"),
+ " ", current_dive->dc.divemode == FREEDIVE));
- timestamp_t surface_interval = get_surface_interval(displayed_dive.when);
+ timestamp_t surface_interval = get_surface_interval(current_dive->when);
if (surface_interval >= 0)
ui->surfaceIntervalText->setText(get_dive_surfint_string(surface_interval, tr("d"), tr("h"), tr("min")));
else
@@ -85,13 +88,13 @@ void TabDiveInformation::updateData()
ui->sacText->setText( mean[0] ? SACs : QString());
- if (displayed_dive.surface_pressure.mbar) /* this is ALWAYS displayed in mbar */
- ui->airPressureText->setText(QString("%1mbar").arg(displayed_dive.surface_pressure.mbar));
+ if (current_dive->surface_pressure.mbar) /* this is ALWAYS displayed in mbar */
+ ui->airPressureText->setText(QString("%1mbar").arg(current_dive->surface_pressure.mbar));
else
ui->airPressureText->clear();
- if (displayed_dive.salinity)
- ui->salinityText->setText(QString("%1g/ℓ").arg(displayed_dive.salinity / 10.0));
+ if (current_dive->salinity)
+ ui->salinityText->setText(QString("%1g/ℓ").arg(current_dive->salinity / 10.0));
else
ui->salinityText->clear();