2017-04-27 18:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-06-17 22:58:26 +00:00
|
|
|
#ifndef QTHELPER_H
|
|
|
|
#define QTHELPER_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2013-10-04 18:39:33 +00:00
|
|
|
#include "dive.h"
|
2013-11-26 17:44:18 +00:00
|
|
|
#include "divelist.h"
|
2018-02-24 22:28:13 +00:00
|
|
|
|
2018-03-14 19:37:19 +00:00
|
|
|
// 1) Types
|
2018-02-24 22:28:13 +00:00
|
|
|
|
|
|
|
enum inertgas {N2, HE};
|
|
|
|
|
|
|
|
// 2) Functions visible only to C++ parts
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
#include <QMultiMap>
|
|
|
|
#include <QString>
|
2013-10-09 05:25:02 +00:00
|
|
|
#include <QTranslator>
|
2015-02-26 13:39:42 +00:00
|
|
|
#include <QDir>
|
2018-07-03 14:52:20 +00:00
|
|
|
#include "core/gettextfromc.h"
|
2013-10-04 18:39:33 +00:00
|
|
|
QString weight_string(int weight_in_grams);
|
2015-07-14 18:35:04 +00:00
|
|
|
QString distance_string(int distanceInMeters);
|
2014-06-03 01:13:50 +00:00
|
|
|
bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out = 0);
|
2013-11-26 17:44:18 +00:00
|
|
|
QList<int> getDivesInTrip(dive_trip_t *trip);
|
2015-05-28 19:23:49 +00:00
|
|
|
QString get_gas_string(struct gasmix gas);
|
2016-07-06 12:40:28 +00:00
|
|
|
QString get_divepoint_gas_string(struct dive *d, const divedatapoint& dp);
|
2018-04-09 08:09:34 +00:00
|
|
|
QString get_taglist_string(struct tag_entry *tag_list);
|
2015-02-26 13:39:42 +00:00
|
|
|
void read_hashes();
|
|
|
|
void write_hashes();
|
2018-04-29 20:07:05 +00:00
|
|
|
QString thumbnailFileName(const QString &filename);
|
2018-06-02 16:03:03 +00:00
|
|
|
void learnPictureFilename(const QString &originalName, const QString &localName);
|
2018-02-17 14:55:50 +00:00
|
|
|
QString localFilePath(const QString &originalFilename);
|
2015-05-28 20:17:09 +00:00
|
|
|
weight_t string_to_weight(const char *str);
|
|
|
|
depth_t string_to_depth(const char *str);
|
|
|
|
pressure_t string_to_pressure(const char *str);
|
|
|
|
volume_t string_to_volume(const char *str, pressure_t workp);
|
|
|
|
fraction_t string_to_fraction(const char *str);
|
2015-06-01 20:09:45 +00:00
|
|
|
int getCloudURL(QString &filename);
|
2015-07-31 01:38:28 +00:00
|
|
|
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
2015-08-22 14:05:13 +00:00
|
|
|
QByteArray getCurrentAppState();
|
2018-02-17 14:55:50 +00:00
|
|
|
void setCurrentAppState(const QByteArray &state);
|
2015-11-14 18:43:37 +00:00
|
|
|
void init_proxy();
|
2015-11-19 01:57:13 +00:00
|
|
|
QString getUUID();
|
2018-05-15 18:47:35 +00:00
|
|
|
extern const QStringList videoExtensionsList;
|
2018-07-13 19:06:28 +00:00
|
|
|
QStringList mediaExtensionFilters();
|
2017-05-05 19:13:46 +00:00
|
|
|
QStringList imageExtensionFilters();
|
2018-07-13 19:06:28 +00:00
|
|
|
QStringList videoExtensionFilters();
|
2017-05-07 06:41:27 +00:00
|
|
|
char *intdup(int index);
|
2018-02-28 22:37:09 +00:00
|
|
|
char *copy_qstring(const QString &);
|
2018-06-03 20:15:19 +00: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);
|
|
|
|
QString get_depth_unit();
|
|
|
|
QString get_weight_string(weight_t weight, bool showunit = false);
|
|
|
|
QString get_weight_unit();
|
|
|
|
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_string(int mliter, bool showunit = false);
|
|
|
|
QString get_volume_unit();
|
|
|
|
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
|
|
|
QString get_pressure_unit();
|
|
|
|
QString getSubsurfaceDataPath(QString folderToFind);
|
|
|
|
QString getPrintingTemplatePathUser();
|
|
|
|
QString getPrintingTemplatePathBundle();
|
|
|
|
QString get_dc_nickname(const char *model, uint32_t deviceid);
|
|
|
|
int gettimezoneoffset(timestamp_t when = 0);
|
|
|
|
int parseDurationToSeconds(const QString &text);
|
|
|
|
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 render_seconds_to_string(int seconds);
|
2018-07-03 14:52:20 +00:00
|
|
|
QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = gettextFromC::tr("sec"), QString separator = ":", bool isFreeDive = false);
|
2018-06-03 20:15:19 +00:00
|
|
|
QString get_dive_surfint_string(timestamp_t when, QString daysText, QString hoursText, QString minutesText, QString separator = " ", int maxdays = 4);
|
|
|
|
QString get_dive_date_string(timestamp_t when);
|
|
|
|
QString get_short_dive_date_string(timestamp_t 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
|
|
|
|
|
2018-06-30 19:32:14 +00:00
|
|
|
// Move a range in a vector to a different position.
|
|
|
|
// The parameters are given according to the usual STL-semantics:
|
|
|
|
// v: a container with STL-like random access iterator via std::begin(...)
|
|
|
|
// rangeBegin: index of first element
|
|
|
|
// rangeEnd: index one *past* last element
|
|
|
|
// destination: index to element before which the range will be moved
|
|
|
|
// Owing to std::begin() magic, this function works with STL-like containers:
|
|
|
|
// QVector<int> v{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
|
|
|
// moveInVector(v, 1, 4, 6);
|
|
|
|
// as well as with C-style arrays:
|
|
|
|
// int array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
|
|
|
// moveInVector(array, 1, 4, 6);
|
|
|
|
// Both calls will have the following effect:
|
|
|
|
// Before: 0 1 2 3 4 5 6 7 8 9
|
|
|
|
// After: 0 4 5 1 2 3 6 7 8 9
|
|
|
|
// No sanitizing of the input arguments is performed.
|
|
|
|
template <typename Vector>
|
|
|
|
void moveInVector(Vector &v, int rangeBegin, int rangeEnd, int destination)
|
|
|
|
{
|
|
|
|
auto it = std::begin(v);
|
|
|
|
if (destination > rangeEnd)
|
|
|
|
std::rotate(it + rangeBegin, it + rangeEnd, it + destination);
|
|
|
|
else if (destination < rangeBegin)
|
|
|
|
std::rotate(it + destination, it + rangeBegin, it + rangeEnd);
|
|
|
|
}
|
|
|
|
|
2018-02-24 22:28:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// 3) Functions visible to C and C++
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-10-20 18:12:15 +00:00
|
|
|
const char *printGPSCoords(const location_t *loc);
|
2018-02-24 22:28:13 +00:00
|
|
|
bool in_planner();
|
|
|
|
bool getProxyString(char **buffer);
|
|
|
|
bool canReachCloudServer();
|
|
|
|
void updateWindowTitle();
|
|
|
|
void subsurface_mkdir(const char *dir);
|
|
|
|
char *get_file_name(const char *fileName);
|
|
|
|
void copy_image_and_overwrite(const char *cfileName, const char *path, const char *cnewName);
|
|
|
|
char *move_away(const char *path);
|
|
|
|
const char *local_file_path(struct picture *picture);
|
|
|
|
char *cloud_url();
|
|
|
|
char *hashfile_name_string();
|
|
|
|
char *picturedir_string();
|
|
|
|
const char *subsurface_user_agent();
|
|
|
|
enum deco_mode decoMode();
|
|
|
|
int parse_seabear_header(const char *filename, char **params, int pnr);
|
2018-03-13 21:12:23 +00:00
|
|
|
char *get_current_date();
|
2018-02-24 22:28:13 +00:00
|
|
|
double cache_value(int tissue, int timestep, enum inertgas gas);
|
|
|
|
void cache_insert(int tissue, int timestep, enum inertgas gas, double value);
|
|
|
|
void print_qt_versions();
|
|
|
|
void lock_planner();
|
|
|
|
void unlock_planner();
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-17 22:58:26 +00:00
|
|
|
#endif // QTHELPER_H
|