mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 21:20:19 +00:00
288aff9dbb
We had two totally different usage cases for "get_volume_string()": one that did the obvious "show this volume as a string", and one that tried to show a cylinder size. The function used a magic third argument (the working pressure of the cylinder) to distinguish between the two cases, but it still got it wrong. A metric cylinder doesn't necessarily have a working pressure at all, and the size is a wet size in liters. We'd pass in zero as the working pressure, and if the volume units were set to cubic feet, the logic in "get_volume_string()" would happily convert the metric wet size into the wet size in cubic feet. But that's completely wrong. An imperial cylinder size simply isn't a wet size. If you don't have a working pressure, you cannot convert the cylinder size to cubic feet. End of story. So instead of having "get_volume_string()" have magical behavior depending on working pressure, and getting it wrong anyway, just make get_volume_string do a pure volume conversion, and create a whole new function for showing the size of a cylinder. Now, if the cylinder doesn't have a working pressure, we just show the metric size, even if the user had asked for cubic feet. [Dirk Hohndel: added call to translation functions for the units] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
56 lines
2.2 KiB
C
56 lines
2.2 KiB
C
/*
|
|
* helpers.h
|
|
*
|
|
* header file for random helper functions of Subsurface
|
|
*
|
|
*/
|
|
#ifndef HELPERS_H
|
|
#define HELPERS_H
|
|
|
|
#include <QString>
|
|
#include "dive.h"
|
|
#include "qthelper.h"
|
|
|
|
QString get_depth_string(depth_t depth, bool showunit = false, bool showdecimal = true);
|
|
QString get_depth_string(int mm, bool showunit = false, bool showdecimal = true);
|
|
QString get_depth_unit();
|
|
QString get_weight_string(weight_t weight, bool showunit = false);
|
|
QString get_weight_unit();
|
|
QString get_cylinder_used_gas_string(cylinder_t *cyl, bool showunit = false);
|
|
QString get_temperature_string(temperature_t temp, bool showunit = false);
|
|
QString get_temp_unit();
|
|
QString get_volume_string(volume_t volume, bool showunit = false);
|
|
QString get_volume_unit();
|
|
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
|
QString get_pressure_unit();
|
|
void set_default_dive_computer(const char *vendor, const char *product);
|
|
void set_default_dive_computer_device(const char *name);
|
|
void set_default_dive_computer_download_mode(int downloadMode);
|
|
QString getSubsurfaceDataPath(QString folderToFind);
|
|
QString getPrintingTemplatePathUser();
|
|
QString getPrintingTemplatePathBundle();
|
|
void copyPath(QString src, QString dst);
|
|
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
|
int gettimezoneoffset(timestamp_t when = 0);
|
|
int parseLengthToMm(const QString &text);
|
|
int parseTemperatureToMkelvin(const QString &text);
|
|
int parseWeightToGrams(const QString &text);
|
|
int parsePressureToMbar(const QString &text);
|
|
int parseGasMixO2(const QString &text);
|
|
int parseGasMixHE(const QString &text);
|
|
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
|
|
QString get_dive_date_string(timestamp_t when);
|
|
QString get_short_dive_date_string(timestamp_t when);
|
|
bool is_same_day (timestamp_t trip_when, timestamp_t dive_when);
|
|
QString get_trip_date_string(timestamp_t when, int nr, bool getday);
|
|
QString uiLanguage(QLocale *callerLoc);
|
|
QLocale getLocale();
|
|
void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsed);
|
|
QString getUserAgent();
|
|
|
|
#if defined __APPLE__
|
|
#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
|
|
#else
|
|
#define TITLE_OR_TEXT(_t, _m) _t, _m
|
|
#endif
|
|
#endif // HELPERS_H
|