Added salinity to the Dive Info tab.

Took the opportunity to remove some copy&paste.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
This commit is contained in:
Patrick Valsecchi 2013-10-10 10:16:32 +02:00 committed by Dirk Hohndel
parent c5a15c6a45
commit 1dccf84c67
2 changed files with 26 additions and 20 deletions

View file

@ -195,6 +195,8 @@ bool MainTab::eventFilter(QObject* object, QEvent* event)
void MainTab::clearEquipment() void MainTab::clearEquipment()
{ {
cylindersModel->clear();
weightModel->clear();
} }
void MainTab::clearInfo() void MainTab::clearInfo()
@ -211,6 +213,7 @@ void MainTab::clearInfo()
ui.waterTemperatureText->clear(); ui.waterTemperatureText->clear();
ui.airTemperatureText->clear(); ui.airTemperatureText->clear();
ui.airPressureText->clear(); ui.airPressureText->clear();
ui.salinityText->clear();
} }
void MainTab::clearStats() void MainTab::clearStats()
@ -325,6 +328,10 @@ void MainTab::updateDiveInfo(int dive)
ui.airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar)); ui.airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
else else
ui.airPressureText->clear(); ui.airPressureText->clear();
if (d->salinity)
ui.salinityText->setText(QString("%1g/l").arg(d->salinity/10.0));
else
ui.salinityText->clear();
ui.depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, TRUE)); ui.depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, TRUE));
ui.depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, TRUE)); ui.depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, TRUE));
ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, TRUE)); ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, TRUE));
@ -354,29 +361,12 @@ void MainTab::updateDiveInfo(int dive)
weightModel->setDive(&multiEditEquipmentPlaceholder); weightModel->setDive(&multiEditEquipmentPlaceholder);
} else { } else {
/* clear the fields */ /* clear the fields */
clearInfo();
clearStats();
clearEquipment();
ui.rating->setCurrentStars(0); ui.rating->setCurrentStars(0);
ui.coordinates->clear(); ui.coordinates->clear();
ui.sacText->clear();
ui.otuText->clear();
ui.oxygenHeliumText->clear();
ui.dateText->clear();
ui.diveTimeText->clear();
ui.surfaceIntervalText->clear();
ui.maximumDepthText->clear();
ui.averageDepthText->clear();
ui.visibility->setCurrentStars(0); ui.visibility->setCurrentStars(0);
ui.waterTemperatureText->clear();
ui.airTemperatureText->clear();
ui.gasUsedText->clear();
ui.airPressureText->clear();
cylindersModel->clear();
weightModel->clear();
ui.depthLimits->clear();
ui.sacLimits->clear();
ui.divesAllText->clear();
ui.tempLimits->clear();
ui.totalTimeAllText->clear();
ui.timeLimits->clear();
/* turns out this is non-trivial for a dateTimeEdit... this is a partial hack */ /* turns out this is non-trivial for a dateTimeEdit... this is a partial hack */
QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit*>(); QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit*>();
le->setText(""); le->setText("");

View file

@ -584,6 +584,22 @@
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QGroupBox">
<property name="title">
<string>Salinity</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="salinityText">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>