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 <mordred@inaugust.com>
This commit is contained in:
Monty Taylor 2020-05-04 08:54:58 -05:00 committed by Lubomir I. Ivanov
parent b3270222fd
commit 95e6792c4f
9 changed files with 56 additions and 20 deletions

View file

@ -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];