From 95e6792c4fe353441fd1cad8bad8b459b1a37d65 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 4 May 2020 08:54:58 -0500 Subject: Grantlee: Add salinity and water type to grantlee variables These can be useful in a printed divelog, especially if the log entry is also showing weight and exposure suit. Signed-off-by: Monty Taylor --- core/subsurface-qt/diveobjecthelper.cpp | 17 ++++++++++++++++- core/subsurface-qt/diveobjecthelper.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'core/subsurface-qt') diff --git a/core/subsurface-qt/diveobjecthelper.cpp b/core/subsurface-qt/diveobjecthelper.cpp index bed504975..7c8651507 100644 --- a/core/subsurface-qt/diveobjecthelper.cpp +++ b/core/subsurface-qt/diveobjecthelper.cpp @@ -249,6 +249,19 @@ QStringList getFullCylinderList() return cylinders; } +QString formatDiveSalinity(const dive *d) +{ + int salinity = get_dive_salinity(d); + if (!salinity) + return QString(); + return get_salinity_string(salinity); +} + +QString formatDiveWaterType(const dive *d) +{ + return get_water_type_string(get_dive_salinity(d)); +} + // Qt's metatype system insists on generating a default constructed object, even if that makes no sense. DiveObjectHelper::DiveObjectHelper() { @@ -286,7 +299,9 @@ DiveObjectHelper::DiveObjectHelper(const struct dive *d) : getCylinder(formatGetCylinder(d)), startPressure(getStartPressure(d)), endPressure(getEndPressure(d)), - firstGas(getFirstGas(d)) + firstGas(getFirstGas(d)), + salinity(formatDiveSalinity(d)), + waterType(formatDiveWaterType(d)) { #if defined(DEBUG_DOH) void *array[4]; diff --git a/core/subsurface-qt/diveobjecthelper.h b/core/subsurface-qt/diveobjecthelper.h index 7723df0f4..a10fe83f1 100644 --- a/core/subsurface-qt/diveobjecthelper.h +++ b/core/subsurface-qt/diveobjecthelper.h @@ -84,6 +84,8 @@ public: QStringList startPressure; QStringList endPressure; QStringList firstGas; + QString salinity; + QString waterType; }; // This is an extended version of DiveObjectHelper that also keeps track of cylinder data. -- cgit v1.2.3-70-g09d2