2013-05-06 20:50:30 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/*
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * helpers.h
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * header file for random helper functions of Subsurface
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-11 19:14:46 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifndef HELPERS_H
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define HELPERS_H
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-06 20:50:30 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <QString>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "dive.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "qthelper.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-06 20:50:30 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-22 12:37:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								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);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-18 10:48:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_depth_unit();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_weight_string(weight_t weight, bool showunit = false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_weight_unit();
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 17:50:38 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_cylinder_used_gas_string(cylinder_t *cyl, bool showunit = false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-18 10:48:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_temperature_string(temperature_t temp, bool showunit = false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_temp_unit();
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												Don't use "get_volume_string()" for cylinder size string
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>
											
										 
										
											2016-02-24 14:42:56 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_volume_string(volume_t volume, bool showunit = false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-18 10:48:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_volume_unit();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_pressure_string(pressure_t pressure, bool showunit = false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_pressure_unit();
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 23:24:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void set_default_dive_computer(const char *vendor, const char *product);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void set_default_dive_computer_device(const char *name);
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-06 23:59:28 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void set_default_dive_computer_download_mode(int downloadMode);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-31 06:26:08 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString getSubsurfaceDataPath(QString folderToFind);
							 | 
						
					
						
							
								
									
										
										
										
											2015-10-19 00:25:14 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString getPrintingTemplatePathUser();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString getPrintingTemplatePathBundle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void copyPath(QString src, QString dst);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-01 15:02:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int gettimezoneoffset(timestamp_t when = 0);
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-01 00:32:30 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int parseLengthToMm(const QString &text);
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int parseTemperatureToMkelvin(const QString &text);
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-05 22:51:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int parseWeightToGrams(const QString &text);
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-09 19:52:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int parsePressureToMbar(const QString &text);
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-13 18:34:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int parseGasMixO2(const QString &text);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								int parseGasMixHE(const QString &text);
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-29 11:14:34 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-17 01:00:17 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString get_dive_date_string(timestamp_t when);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_short_dive_date_string(timestamp_t when);
							 | 
						
					
						
							
								
									
										
										
										
											2015-10-06 21:08:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								bool is_same_day (timestamp_t trip_when, timestamp_t dive_when);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								QString get_trip_date_string(timestamp_t when, int nr, bool getday);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-06 12:10:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString uiLanguage(QLocale *callerLoc);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-28 08:35:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QLocale getLocale();
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-09 22:45:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsed);
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-23 09:09:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								QString getUserAgent();
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-21 04:23:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#if defined __APPLE__
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-21 04:23:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#else
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define TITLE_OR_TEXT(_t, _m) _t, _m
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-21 04:23:10 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-11 19:14:46 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif // HELPERS_H
							 |