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>
This commit is contained in:
Berthold Stoeger 2019-10-13 00:01:44 +02:00 committed by Dirk Hohndel
parent d16d57577d
commit 6a6b992a77
3 changed files with 14 additions and 5 deletions

View file

@ -28,6 +28,7 @@ enum class DiveField {
TAGS, TAGS,
MODE, MODE,
NOTES, NOTES,
SALINITY
}; };
enum class TripField { enum class TripField {
LOCATION, LOCATION,

View file

@ -106,6 +106,14 @@ void TabDiveInformation::updateWhen()
ui->surfaceIntervalText->clear(); 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() void TabDiveInformation::updateData()
{ {
if (!current_dive) { if (!current_dive) {
@ -117,11 +125,7 @@ void TabDiveInformation::updateData()
updateWhen(); updateWhen();
ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true)); ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true));
ui->airTemperatureText->setText(get_temperature_string(current_dive->airtemp, true)); ui->airTemperatureText->setText(get_temperature_string(current_dive->airtemp, true));
updateSalinity();
if (current_dive->salinity)
ui->salinityText->setText(QString("%1g/").arg(current_dive->salinity / 10.0));
else
ui->salinityText->clear();
ui->atmPressType->setEditable(true); ui->atmPressType->setEditable(true);
ui->atmPressType->setItemText(1, get_depth_unit()); // Check for changes in depth unit (imperial/metric) 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: case DiveField::DATETIME:
updateWhen(); updateWhen();
break; break;
case DiveField::SALINITY:
updateSalinity();
break;
default: default:
break; break;
} }

View file

@ -23,6 +23,7 @@ private slots:
private: private:
Ui::TabDiveInformation *ui; Ui::TabDiveInformation *ui;
void updateProfile(); void updateProfile();
void updateSalinity();
void updateWhen(); void updateWhen();
int pressTypeIndex; int pressTypeIndex;
void updateTextBox(int event); void updateTextBox(int event);