diff options
author | willemferguson <willemferguson@zoology.up.ac.za> | 2019-11-19 19:16:45 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-06 07:00:34 +0900 |
commit | d2cf58e07e64b4e1e6a81f07c2efce38c55be78b (patch) | |
tree | 1b0ad636f59da7600f4a38a819f8ddd5d03fc437 /commands | |
parent | ebabbfb457184ea4d9e939ad8501986c35699264 (diff) | |
download | subsurface-d2cf58e07e64b4e1e6a81f07c2efce38c55be78b.tar.gz |
core: read and write the user-specified salinity
Both XML and git storage are added.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/command.cpp | 5 | ||||
-rw-r--r-- | commands/command.h | 1 | ||||
-rw-r--r-- | commands/command_edit.cpp | 21 | ||||
-rw-r--r-- | commands/command_edit.h | 9 |
4 files changed, 36 insertions, 0 deletions
diff --git a/commands/command.cpp b/commands/command.cpp index 9ea0e860f..29702c703 100644 --- a/commands/command.cpp +++ b/commands/command.cpp @@ -218,6 +218,11 @@ int editAtmPress(int newValue, bool currentDiveOnly) return execute_edit(new EditAtmPress(newValue, currentDiveOnly)); } +int editWaterTypeUser(int newValue, bool currentDiveOnly) +{ + return execute_edit(new EditWaterTypeUser(newValue, currentDiveOnly)); +} + int editDepth(int newValue, bool currentDiveOnly) { return execute_edit(new EditDepth(newValue, currentDiveOnly)); diff --git a/commands/command.h b/commands/command.h index 0f93a3e85..34df6eba8 100644 --- a/commands/command.h +++ b/commands/command.h @@ -71,6 +71,7 @@ int editChill(int newValue, bool currentDiveOnly); int editAirTemp(int newValue, bool currentDiveOnly); int editWaterTemp(int newValue, bool currentDiveOnly); int editAtmPress(int newValue, bool currentDiveOnly); +int editWaterTypeUser(int newValue, bool currentDiveOnly); int editDepth(int newValue, bool currentDiveOnly); int editDuration(int newValue, bool currentDiveOnly); int editDiveSite(struct dive_site *newValue, bool currentDiveOnly); diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index 701da3ee1..31ca4ea23 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -355,6 +355,27 @@ DiveField EditWaterTemp::fieldId() const return DiveField::WATER_TEMP; } +// ***** Water Type ***** +void EditWaterTypeUser::set(struct dive *d, int value) const +{ + d->user_salinity = value > 0 ? value : 0; +} + +int EditWaterTypeUser::data(struct dive *d) const +{ + return d->user_salinity; +} + +QString EditWaterTypeUser::fieldName() const +{ + return tr("salinity"); +} + +DiveField EditWaterTypeUser::fieldId() const +{ + return DiveField::SALINITY; +} + // ***** Atmospheric pressure ***** void EditAtmPress::set(struct dive *d, int value) const { diff --git a/commands/command_edit.h b/commands/command_edit.h index 76b538b4d..aa749ceda 100644 --- a/commands/command_edit.h +++ b/commands/command_edit.h @@ -161,6 +161,15 @@ public: DiveField fieldId() const override; }; +class EditWaterTypeUser : public EditBase<int> { +public: + using EditBase<int>::EditBase; // Use constructor of base class. + void set(struct dive *d, int value) const override; + int data(struct dive *d) const override; + QString fieldName() const override; + DiveField fieldId() const override; +}; + class EditDuration : public EditBase<int> { public: using EditBase<int>::EditBase; // Use constructor of base class. |