diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-10-13 00:01:44 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-26 11:36:23 -0700 |
commit | 6a6b992a7767c2ab4eee83a23d0c17caf979f66f (patch) | |
tree | 77f7767d37fd86487ce15d6900ddcd82572b0c57 /desktop-widgets | |
parent | d16d57577dae2f97e8e1a8bb33812718039ba605 (diff) | |
download | subsurface-6a6b992a7767c2ab4eee83a23d0c17caf979f66f.tar.gz |
Desktop: make salinity a field known to the undo system
The undo system sets updates individual dive fields on
redo respectively undo. Make salinity such a field, since
it is changed on replanning a dive.
To do this, break out the "update salinity" functionality
into its own function, add an entry to the DiveField enum
and add the corresponding switch-case.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 17 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.h | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 492ba97a7..66c1f7401 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -106,6 +106,14 @@ void TabDiveInformation::updateWhen() ui->surfaceIntervalText->clear(); } +void TabDiveInformation::updateSalinity() +{ + if (current_dive->salinity) + ui->salinityText->setText(QString("%1g/ℓ").arg(current_dive->salinity / 10.0)); + else + ui->salinityText->clear(); +} + void TabDiveInformation::updateData() { if (!current_dive) { @@ -117,11 +125,7 @@ void TabDiveInformation::updateData() updateWhen(); ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true)); ui->airTemperatureText->setText(get_temperature_string(current_dive->airtemp, true)); - - if (current_dive->salinity) - ui->salinityText->setText(QString("%1g/ℓ").arg(current_dive->salinity / 10.0)); - else - ui->salinityText->clear(); + updateSalinity(); ui->atmPressType->setEditable(true); ui->atmPressType->setItemText(1, get_depth_unit()); // Check for changes in depth unit (imperial/metric) @@ -155,6 +159,9 @@ void TabDiveInformation::divesChanged(const QVector<dive *> &dives, DiveField fi case DiveField::DATETIME: updateWhen(); break; + case DiveField::SALINITY: + updateSalinity(); + break; default: break; } diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h index 04c27acab..5305f4146 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.h +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -23,6 +23,7 @@ private slots: private: Ui::TabDiveInformation *ui; void updateProfile(); + void updateSalinity(); void updateWhen(); int pressTypeIndex; void updateTextBox(int event); |