mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
b3270222fd
commit
95e6792c4f
9 changed files with 56 additions and 20 deletions
|
@ -5011,6 +5011,8 @@ Only a subset of the dive data is exported:
|
||||||
|startPressure| (*string*) the start pressure
|
|startPressure| (*string*) the start pressure
|
||||||
|endPressure| (*string*) the end pressure
|
|endPressure| (*string*) the end pressure
|
||||||
|firstGas| (*string*) first used gas
|
|firstGas| (*string*) first used gas
|
||||||
|
|salinity| (*string*) the salinity of the water for the dive
|
||||||
|
|waterType| (*string*) the type of the water for the dive
|
||||||
|=====================
|
|=====================
|
||||||
|
|
||||||
Please note that some of the variables like 'notes' need to be extended with '|safe' to support HTML tags:
|
Please note that some of the variables like 'notes' need to be extended with '|safe' to support HTML tags:
|
||||||
|
|
|
@ -1196,6 +1196,11 @@ static void fixup_water_salinity(struct dive *dive)
|
||||||
dive->salinity = (sum + nr / 2) / nr;
|
dive->salinity = (sum + nr / 2) / nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_dive_salinity(const struct dive *dive)
|
||||||
|
{
|
||||||
|
return dive->user_salinity ? dive->user_salinity : dive->salinity;
|
||||||
|
}
|
||||||
|
|
||||||
static void fixup_meandepth(struct dive *dive)
|
static void fixup_meandepth(struct dive *dive)
|
||||||
{
|
{
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
|
|
|
@ -332,6 +332,7 @@ extern void sort_dive_table(struct dive_table *table);
|
||||||
extern struct dive *fixup_dive(struct dive *dive);
|
extern struct dive *fixup_dive(struct dive *dive);
|
||||||
extern pressure_t calculate_surface_pressure(const struct dive *dive);
|
extern pressure_t calculate_surface_pressure(const struct dive *dive);
|
||||||
extern pressure_t un_fixup_surface_pressure(const struct dive *d);
|
extern pressure_t un_fixup_surface_pressure(const struct dive *d);
|
||||||
|
extern int get_dive_salinity(const struct dive *dive);
|
||||||
extern void fixup_dc_duration(struct divecomputer *dc);
|
extern void fixup_dc_duration(struct divecomputer *dc);
|
||||||
extern int dive_getUniqID();
|
extern int dive_getUniqID();
|
||||||
extern unsigned int dc_airtemp(const struct divecomputer *dc);
|
extern unsigned int dc_airtemp(const struct divecomputer *dc);
|
||||||
|
|
|
@ -621,6 +621,23 @@ QString get_pressure_string(pressure_t pressure, bool showunit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString get_salinity_string(int salinity)
|
||||||
|
{
|
||||||
|
return QStringLiteral("%L1%2").arg(salinity / 10.0).arg(gettextFromC::tr("g/ℓ"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString get_water_type_string(int salinity)
|
||||||
|
{
|
||||||
|
if (salinity < 10050)
|
||||||
|
return waterTypes[FRESHWATER];
|
||||||
|
else if (salinity < 10190)
|
||||||
|
return waterTypes[SALTYWATER];
|
||||||
|
else if (salinity < 10210)
|
||||||
|
return waterTypes[EN13319WATER];
|
||||||
|
else
|
||||||
|
return waterTypes[SALTWATER];
|
||||||
|
}
|
||||||
|
|
||||||
QString getSubsurfaceDataPath(QString folderToFind)
|
QString getSubsurfaceDataPath(QString folderToFind)
|
||||||
{
|
{
|
||||||
QString execdir;
|
QString execdir;
|
||||||
|
@ -1143,6 +1160,11 @@ QString localFilePath(const QString &originalFilename)
|
||||||
return localFilenameOf.value(originalFilename, originalFilename);
|
return localFilenameOf.value(originalFilename, originalFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the water types need to match the watertypes enum
|
||||||
|
const QStringList waterTypes = {
|
||||||
|
gettextFromC::tr("Fresh"), gettextFromC::tr("Salty"), gettextFromC::tr("EN13319"), gettextFromC::tr("Salt"), gettextFromC::tr("use dc")
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: Apparently Qt has no simple way of listing the supported video
|
// TODO: Apparently Qt has no simple way of listing the supported video
|
||||||
// codecs? Do we have to query them by hand using QMediaPlayer::hasSupport()?
|
// codecs? Do we have to query them by hand using QMediaPlayer::hasSupport()?
|
||||||
const QStringList videoExtensionsList = {
|
const QStringList videoExtensionsList = {
|
||||||
|
|
|
@ -11,6 +11,7 @@ struct picture;
|
||||||
// 1) Types
|
// 1) Types
|
||||||
|
|
||||||
enum inertgas {N2, HE};
|
enum inertgas {N2, HE};
|
||||||
|
enum watertypes {FRESHWATER, SALTYWATER, EN13319WATER, SALTWATER, DC_WATERTYPE};
|
||||||
|
|
||||||
// 2) Functions visible only to C++ parts
|
// 2) Functions visible only to C++ parts
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ int getCloudURL(QString &filename);
|
||||||
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
||||||
void init_proxy();
|
void init_proxy();
|
||||||
QString getUUID();
|
QString getUUID();
|
||||||
|
extern const QStringList waterTypes;
|
||||||
extern const QStringList videoExtensionsList;
|
extern const QStringList videoExtensionsList;
|
||||||
QStringList mediaExtensionFilters();
|
QStringList mediaExtensionFilters();
|
||||||
QStringList imageExtensionFilters();
|
QStringList imageExtensionFilters();
|
||||||
|
@ -55,6 +57,8 @@ QString get_volume_string(int mliter, bool showunit = false);
|
||||||
QString get_volume_unit();
|
QString get_volume_unit();
|
||||||
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
||||||
QString get_pressure_unit();
|
QString get_pressure_unit();
|
||||||
|
QString get_salinity_string(int salinity);
|
||||||
|
QString get_water_type_string(int salinity);
|
||||||
QString getSubsurfaceDataPath(QString folderToFind);
|
QString getSubsurfaceDataPath(QString folderToFind);
|
||||||
QString getPrintingTemplatePathUser();
|
QString getPrintingTemplatePathUser();
|
||||||
QString getPrintingTemplatePathBundle();
|
QString getPrintingTemplatePathBundle();
|
||||||
|
|
|
@ -249,6 +249,19 @@ QStringList getFullCylinderList()
|
||||||
return cylinders;
|
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.
|
// Qt's metatype system insists on generating a default constructed object, even if that makes no sense.
|
||||||
DiveObjectHelper::DiveObjectHelper()
|
DiveObjectHelper::DiveObjectHelper()
|
||||||
{
|
{
|
||||||
|
@ -286,7 +299,9 @@ DiveObjectHelper::DiveObjectHelper(const struct dive *d) :
|
||||||
getCylinder(formatGetCylinder(d)),
|
getCylinder(formatGetCylinder(d)),
|
||||||
startPressure(getStartPressure(d)),
|
startPressure(getStartPressure(d)),
|
||||||
endPressure(getEndPressure(d)),
|
endPressure(getEndPressure(d)),
|
||||||
firstGas(getFirstGas(d))
|
firstGas(getFirstGas(d)),
|
||||||
|
salinity(formatDiveSalinity(d)),
|
||||||
|
waterType(formatDiveWaterType(d))
|
||||||
{
|
{
|
||||||
#if defined(DEBUG_DOH)
|
#if defined(DEBUG_DOH)
|
||||||
void *array[4];
|
void *array[4];
|
||||||
|
|
|
@ -84,6 +84,8 @@ public:
|
||||||
QStringList startPressure;
|
QStringList startPressure;
|
||||||
QStringList endPressure;
|
QStringList endPressure;
|
||||||
QStringList firstGas;
|
QStringList firstGas;
|
||||||
|
QString salinity;
|
||||||
|
QString waterType;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is an extended version of DiveObjectHelper that also keeps track of cylinder data.
|
// This is an extended version of DiveObjectHelper that also keeps track of cylinder data.
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#define TEXT_EDITED 1
|
#define TEXT_EDITED 1
|
||||||
#define CSS_SET_HEADING_BLUE "QLabel { color: mediumblue;} "
|
#define CSS_SET_HEADING_BLUE "QLabel { color: mediumblue;} "
|
||||||
|
|
||||||
enum watertypes { FRESHWATER, SALTYWATER, EN13319WATER, SALTWATER, DC_WATERTYPE};
|
|
||||||
|
|
||||||
TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation())
|
TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -26,8 +24,6 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne
|
||||||
QStringList atmPressTypes { "mbar", get_depth_unit() ,tr("use dc")};
|
QStringList atmPressTypes { "mbar", get_depth_unit() ,tr("use dc")};
|
||||||
ui->atmPressType->insertItems(0, atmPressTypes);
|
ui->atmPressType->insertItems(0, atmPressTypes);
|
||||||
pressTypeIndex = 0;
|
pressTypeIndex = 0;
|
||||||
// the water types need to match the enum above
|
|
||||||
waterTypes = QStringList({tr("Fresh"), tr("Salty"), "EN13319", tr("Salt"), tr("use dc")});
|
|
||||||
ui->waterTypeCombo->insertItems(0, waterTypes);
|
ui->waterTypeCombo->insertItems(0, waterTypes);
|
||||||
|
|
||||||
// This needs to be the same order as enum dive_comp_type in dive.h!
|
// This needs to be the same order as enum dive_comp_type in dive.h!
|
||||||
|
@ -229,24 +225,14 @@ void TabDiveInformation::updateData()
|
||||||
ui->airtemp->setText(get_temperature_string(current_dive->airtemp, true));
|
ui->airtemp->setText(get_temperature_string(current_dive->airtemp, 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)
|
||||||
ui->atmPressType->setCurrentIndex(0); // Set the atmospheric pressure combo box to mbar
|
ui->atmPressType->setCurrentIndex(0); // Set the atmospheric pressure combo box to mbar
|
||||||
if (current_dive->user_salinity)
|
salinity_value = get_dive_salinity(current_dive);
|
||||||
salinity_value = current_dive->user_salinity;
|
|
||||||
else
|
|
||||||
salinity_value = current_dive->salinity;
|
|
||||||
if (salinity_value) { // Set water type indicator (EN13319 = 1.020 g/l)
|
if (salinity_value) { // Set water type indicator (EN13319 = 1.020 g/l)
|
||||||
if (prefs.salinityEditDefault) { //If edit-salinity is enabled then set correct water type in combobox:
|
if (prefs.salinityEditDefault) { //If edit-salinity is enabled then set correct water type in combobox:
|
||||||
ui->waterTypeCombo->setCurrentIndex(updateSalinityComboIndex(salinity_value));
|
ui->waterTypeCombo->setCurrentIndex(updateSalinityComboIndex(salinity_value));
|
||||||
} else { // If water salinity is not editable: show water type as a text label
|
} else { // If water salinity is not editable: show water type as a text label
|
||||||
if (salinity_value < 10050)
|
ui->waterTypeText->setText(get_water_type_string(salinity_value));
|
||||||
ui->waterTypeText->setText(waterTypes[FRESHWATER]);
|
|
||||||
else if (salinity_value < 10190)
|
|
||||||
ui->waterTypeText->setText(waterTypes[SALTYWATER]);
|
|
||||||
else if (salinity_value < 10210)
|
|
||||||
ui->waterTypeText->setText(waterTypes[EN13319WATER]);
|
|
||||||
else
|
|
||||||
ui->waterTypeText->setText(waterTypes[SALTWATER]);
|
|
||||||
}
|
}
|
||||||
ui->salinityText->setText(QString("%1g/ℓ").arg(salinity_value / 10.0));
|
ui->salinityText->setText(get_salinity_string(salinity_value));
|
||||||
} else {
|
} else {
|
||||||
ui->waterTypeCombo->setCurrentIndex(-1);
|
ui->waterTypeCombo->setCurrentIndex(-1);
|
||||||
ui->waterTypeText->setText(tr("unknown"));
|
ui->waterTypeText->setText(tr("unknown"));
|
||||||
|
@ -295,7 +281,7 @@ void TabDiveInformation::on_waterTypeCombo_activated(int index) {
|
||||||
}
|
}
|
||||||
// Save and display the new salinity value
|
// Save and display the new salinity value
|
||||||
if (combobox_salinity)
|
if (combobox_salinity)
|
||||||
ui->salinityText->setText(QString("%1g/ℓ").arg(combobox_salinity / 10.0));
|
ui->salinityText->setText(get_salinity_string(combobox_salinity));
|
||||||
else
|
else
|
||||||
ui->salinityText->clear();
|
ui->salinityText->clear();
|
||||||
divesEdited(Command::editWaterTypeUser(combobox_salinity, false));
|
divesEdited(Command::editWaterTypeUser(combobox_salinity, false));
|
||||||
|
|
|
@ -43,7 +43,6 @@ private:
|
||||||
void divesEdited(int);
|
void divesEdited(int);
|
||||||
void closeWarning();
|
void closeWarning();
|
||||||
void showCurrentWidget(bool show, int position);
|
void showCurrentWidget(bool show, int position);
|
||||||
QStringList waterTypes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue