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
|
|
|
|
|
2019-07-15 21:44:39 +00:00
|
|
|
#include "core/pref.h"
|
2024-05-04 16:45:55 +00:00
|
|
|
#include "core/gettextfromc.h"
|
2020-07-17 01:40:46 +00:00
|
|
|
#include "subsurface-time.h"
|
2024-05-04 16:45:55 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <libxslt/transform.h>
|
|
|
|
#include <libxslt/xsltutils.h>
|
2019-07-15 21:44:39 +00:00
|
|
|
|
|
|
|
struct picture;
|
2020-09-29 20:45:21 +00:00
|
|
|
struct dive_trip;
|
2020-10-17 18:15:23 +00:00
|
|
|
struct xml_params;
|
2024-05-04 16:45:55 +00:00
|
|
|
struct git_info;
|
|
|
|
class QImage;
|
2018-02-24 22:28:13 +00:00
|
|
|
|
2020-05-04 23:07:56 +00:00
|
|
|
enum watertypes {FRESHWATER, BRACKISHWATER, EN13319WATER, SALTWATER, DC_WATERTYPE};
|
2018-02-24 22:28:13 +00:00
|
|
|
|
2021-11-22 01:20:25 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
|
|
#define SKIP_EMPTY Qt::SkipEmptyParts
|
|
|
|
#else
|
|
|
|
#define SKIP_EMPTY QString::SkipEmptyParts
|
|
|
|
#endif
|
|
|
|
|
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);
|
2015-05-28 19:23:49 +00:00
|
|
|
QString get_gas_string(struct gasmix gas);
|
2021-01-09 20:18:37 +00:00
|
|
|
QStringList get_dive_gas_list(const struct dive *d);
|
2020-01-09 23:09:17 +00:00
|
|
|
QStringList stringToList(const QString &s);
|
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);
|
2024-03-24 21:05:28 +00:00
|
|
|
std::optional<std::string> getCloudURL(); // move to prefs.h, probably.
|
2015-07-31 01:38:28 +00:00
|
|
|
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
2015-11-14 18:43:37 +00:00
|
|
|
void init_proxy();
|
2020-09-21 19:44:35 +00:00
|
|
|
QStringList getWaterTypesAsString();
|
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();
|
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);
|
2021-01-01 11:09:19 +00:00
|
|
|
QString get_depth_unit(bool metric);
|
|
|
|
QString get_depth_unit(); // use preferences unit
|
2018-06-03 20:15:19 +00:00
|
|
|
QString get_weight_string(weight_t weight, bool showunit = false);
|
2021-01-01 11:09:19 +00:00
|
|
|
QString get_weight_unit(bool metric);
|
|
|
|
QString get_weight_unit(); // use preferences unit
|
2018-06-03 20:15:19 +00:00
|
|
|
QString get_temperature_string(temperature_t temp, bool showunit = false);
|
2021-01-01 11:09:19 +00:00
|
|
|
QString get_temp_unit(bool metric);
|
|
|
|
QString get_temp_unit(); // use preferences unit
|
2018-06-03 20:15:19 +00:00
|
|
|
QString get_volume_string(volume_t volume, bool showunit = false);
|
|
|
|
QString get_volume_string(int mliter, bool showunit = false);
|
2021-01-01 11:09:19 +00:00
|
|
|
QString get_volume_unit(bool metric);
|
|
|
|
QString get_volume_unit(); // use preferences unit
|
2018-06-03 20:15:19 +00:00
|
|
|
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
2020-05-04 13:54:58 +00:00
|
|
|
QString get_salinity_string(int salinity);
|
|
|
|
QString get_water_type_string(int salinity);
|
2018-06-03 20:15:19 +00:00
|
|
|
QString getSubsurfaceDataPath(QString folderToFind);
|
|
|
|
QString getPrintingTemplatePathUser();
|
|
|
|
QString getPrintingTemplatePathBundle();
|
2020-05-22 16:02:15 +00:00
|
|
|
QDateTime timestampToDateTime(timestamp_t when);
|
2020-05-22 16:53:25 +00:00
|
|
|
timestamp_t dateTimeToTimestamp(const QDateTime &t);
|
2018-06-03 20:15:19 +00:00
|
|
|
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);
|
2024-03-02 08:12:21 +00:00
|
|
|
std::string get_dive_date_c_string(timestamp_t when);
|
2020-02-06 22:29:26 +00:00
|
|
|
QString get_first_dive_date_string();
|
|
|
|
QString get_last_dive_date_string();
|
2018-06-03 20:15:19 +00:00
|
|
|
QString get_short_dive_date_string(timestamp_t when);
|
2020-03-22 15:43:21 +00:00
|
|
|
QString getUiLanguage();
|
|
|
|
void initUiLanguage();
|
2018-06-03 20:15:19 +00:00
|
|
|
QLocale getLocale();
|
2019-04-03 21:05:44 +00:00
|
|
|
QVector<QPair<QString, int>> selectedDivesGasUsed();
|
2018-06-03 20:15:19 +00:00
|
|
|
QString getUserAgent();
|
2019-03-25 08:05:47 +00:00
|
|
|
QString printGPSCoords(const location_t *loc);
|
2024-02-29 12:53:17 +00:00
|
|
|
std::string printGPSCoordsC(const location_t *loc);
|
2020-02-23 18:24:06 +00:00
|
|
|
std::vector<int> get_cylinder_map_for_remove(int count, int n);
|
|
|
|
std::vector<int> get_cylinder_map_for_add(int count, int n);
|
2024-03-08 09:44:20 +00:00
|
|
|
std::string get_current_date();
|
2018-06-03 20:15:19 +00:00
|
|
|
|
2020-03-05 16:57:02 +00:00
|
|
|
extern QString (*changesCallback)();
|
2020-04-01 13:55:12 +00:00
|
|
|
void uiNotification(const QString &msg);
|
2024-02-27 22:10:09 +00:00
|
|
|
std::string get_changes_made();
|
|
|
|
std::string subsurface_user_agent();
|
2024-05-30 13:00:28 +00:00
|
|
|
std::string get_file_name(const std::string &fileName);
|
2024-03-11 20:41:14 +00:00
|
|
|
std::string move_away(const std::string &path);
|
2020-03-05 16:57:02 +00:00
|
|
|
|
2018-06-03 20:15:19 +00:00
|
|
|
#if defined __APPLE__
|
|
|
|
#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
|
|
|
|
#else
|
|
|
|
#define TITLE_OR_TEXT(_t, _m) _t, _m
|
|
|
|
#endif
|
|
|
|
|
2022-04-13 16:43:37 +00:00
|
|
|
bool canReachCloudServer(struct git_info *);
|
2018-02-24 22:28:13 +00:00
|
|
|
void updateWindowTitle();
|
|
|
|
void subsurface_mkdir(const char *dir);
|
2024-05-30 13:00:28 +00:00
|
|
|
std::string local_file_path(const struct picture &picture);
|
2024-06-11 15:06:27 +00:00
|
|
|
std::string hashfile_name();
|
2021-02-12 17:19:24 +00:00
|
|
|
enum deco_mode decoMode(bool in_planner);
|
2020-10-17 18:15:23 +00:00
|
|
|
void parse_seabear_header(const char *filename, struct xml_params *params);
|
2020-07-17 01:40:46 +00:00
|
|
|
time_t get_dive_datetime_from_isostring(char *when);
|
2018-02-24 22:28:13 +00:00
|
|
|
void print_qt_versions();
|
|
|
|
void lock_planner();
|
|
|
|
void unlock_planner();
|
2019-03-03 21:55:18 +00:00
|
|
|
xsltStylesheetPtr get_stylesheet(const char *name);
|
2019-07-15 20:38:21 +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);
|
cleanup: invert control-flow when resetting the core structures
To reset the core data structures, the mobile and desktop UIs
were calling into the dive-list models, which then reset the
core data structures, themselves and the unrelated
locationinformation model. The UI code then reset various other
things, such as the TankInformation model or the map. . This was
unsatisfying from a control-flow perspective, as the models should
display the core data, not act on it. Moreover, this meant lots
of intricate intermodule-dependencies.
Thus, straighten up the control flow: give the C core the
possibility to send a "all data reset" event. And do that
in those functions that reset the core data structures.
Let each module react to this event by itself. This removes
inter-module dependencies. For example, the MainWindow now
doesn't have to reset the TankInfoModel or the MapWidget.
Then, to reset the core data structures, let the UI code
simply directly call the respective core functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04 22:12:36 +00:00
|
|
|
void emit_reset_signal();
|
|
|
|
|
2013-06-17 22:58:26 +00:00
|
|
|
#endif // QTHELPER_H
|