summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_edit.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-30 22:13:24 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commitde579c1a1ad823fbc42d7e3122b77b03626283c3 (patch)
treeafcb74e7c30f5235ba899fa02ca5e2b5e4ce581a /desktop-widgets/command_edit.cpp
parenta12adf8e2a5a9fc2471874e69d31ce50bbaf4cb8 (diff)
downloadsubsurface-de579c1a1ad823fbc42d7e3122b77b03626283c3.tar.gz
Undo: implement undo of air and water temperature editing
Mostly trivial. Since now on editing the field is re-set, the validation function becomes unnecessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r--desktop-widgets/command_edit.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp
index 0480378b8..dc90ccd5e 100644
--- a/desktop-widgets/command_edit.cpp
+++ b/desktop-widgets/command_edit.cpp
@@ -145,7 +145,7 @@ DiveField EditRating::fieldId() const
return DiveField::RATING;
}
-// ***** Visibility ****
+// ***** Visibility *****
void EditVisibility::set(struct dive *d, int value) const
{
d->visibility = value;
@@ -166,6 +166,48 @@ DiveField EditVisibility::fieldId() const
return DiveField::VISIBILITY;
}
+// ***** Air Temperature *****
+void EditAirTemp::set(struct dive *d, int value) const
+{
+ d->airtemp.mkelvin = value > 0 ? (uint32_t)value : 0u;
+}
+
+int EditAirTemp::data(struct dive *d) const
+{
+ return (int)d->airtemp.mkelvin;
+}
+
+QString EditAirTemp::fieldName() const
+{
+ return tr("air temperature");
+}
+
+DiveField EditAirTemp::fieldId() const
+{
+ return DiveField::AIR_TEMP;
+}
+
+// ***** Water Temperature *****
+void EditWaterTemp::set(struct dive *d, int value) const
+{
+ d->watertemp.mkelvin = value > 0 ? (uint32_t)value : 0u;
+}
+
+int EditWaterTemp::data(struct dive *d) const
+{
+ return (int)d->watertemp.mkelvin;
+}
+
+QString EditWaterTemp::fieldName() const
+{
+ return tr("water temperature");
+}
+
+DiveField EditWaterTemp::fieldId() const
+{
+ return DiveField::WATER_TEMP;
+}
+
// ***** Mode *****
// Editing the dive mode has very peculiar semantics for historic reasons:
// Since the dive-mode depends on the dive computer, the i-th dive computer