mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
2d8e343221
This has become a bit of a catch-all overhaul of a large portion of the planner - I started out wanting to improve the CCR mode, but then as I started pulling all the other threads that needed addressing started to come with it. Improve how the gas selection is handled when planning dives in CCR mode, by making the type (OC / CCR) of segments dependent on the gas use type that was set for the selected gas. Add a preference to allow the user to chose to use OC gases as diluent, in a similar fashion to the original implementation. Hide gases that cannot be used in the currently selected dive mode in all drop downs. Include usage type in gas names if this is needed. Hide columns and disable elements in the 'Dive planner points' table if they can they can not be edited in the curently selected dive mode. Visually identify gases and usage types that are not appropriate for the currently selected dive mode. Move the 'Dive mode' selection to the top of the planner view, to accommodate the fact that this is a property of the dive and not a planner setting. Show a warning instead of the dive plan if the plan contains gases that are not usable in the selected dive mode. Fix the data entry for the setpoint in the 'Dive planner points' table. Fix problems with enabling / disabling planner settings when switching between dive modes. Refactor some names to make them more appropriate for their current usage. One point that is still open is to hide gas usage graphs in the planner profile if the gas isn't used for OC, as there is no way to meaningfully interpolate such usage. Signed-off-by: Michael Keller <github@ike.ch>
127 lines
5.2 KiB
C++
127 lines
5.2 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef QTHELPER_H
|
|
#define QTHELPER_H
|
|
|
|
#include "core/pref.h"
|
|
#include "core/gettextfromc.h"
|
|
#include "subsurface-time.h"
|
|
#include <QString>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <libxslt/transform.h>
|
|
#include <libxslt/xsltutils.h>
|
|
|
|
struct picture;
|
|
struct dive_trip;
|
|
struct xml_params;
|
|
struct git_info;
|
|
class QImage;
|
|
|
|
enum watertypes {FRESHWATER, BRACKISHWATER, EN13319WATER, SALTWATER, DC_WATERTYPE};
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
#define SKIP_EMPTY Qt::SkipEmptyParts
|
|
#else
|
|
#define SKIP_EMPTY QString::SkipEmptyParts
|
|
#endif
|
|
|
|
QString distance_string(int distanceInMeters);
|
|
bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out = 0);
|
|
QString get_gas_string(struct gasmix gas);
|
|
QString get_dive_gas(const struct dive *d, int dcNr, int cylinderId);
|
|
std::vector<std::pair<int, QString>> get_dive_gas_list(const struct dive *d, int dcNr, bool showOnlyAppropriate);
|
|
QStringList stringToList(const QString &s);
|
|
void read_hashes();
|
|
void write_hashes();
|
|
QString thumbnailFileName(const QString &filename);
|
|
void learnPictureFilename(const QString &originalName, const QString &localName);
|
|
QString localFilePath(const QString &originalFilename);
|
|
std::optional<std::string> getCloudURL(); // move to prefs.h, probably.
|
|
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
|
void init_proxy();
|
|
QStringList getWaterTypesAsString();
|
|
extern const QStringList videoExtensionsList;
|
|
QStringList mediaExtensionFilters();
|
|
QStringList imageExtensionFilters();
|
|
QStringList videoExtensionFilters();
|
|
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(bool metric);
|
|
QString get_depth_unit(); // use preferences unit
|
|
QString get_weight_string(weight_t weight, bool showunit = false);
|
|
QString get_weight_unit(bool metric);
|
|
QString get_weight_unit(); // use preferences unit
|
|
QString get_temperature_string(temperature_t temp, bool showunit = false);
|
|
QString get_temp_unit(bool metric);
|
|
QString get_temp_unit(); // use preferences unit
|
|
QString get_volume_string(volume_t volume, bool showunit = false);
|
|
QString get_volume_string(int mliter, bool showunit = false);
|
|
QString get_volume_unit(bool metric);
|
|
QString get_volume_unit(); // use preferences unit
|
|
QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
|
QString get_salinity_string(int salinity);
|
|
QString get_water_type_string(int salinity);
|
|
QString getSubsurfaceDataPath(QString folderToFind);
|
|
QString getPrintingTemplatePathUser();
|
|
QString getPrintingTemplatePathBundle();
|
|
QDateTime timestampToDateTime(timestamp_t when);
|
|
timestamp_t dateTimeToTimestamp(const QDateTime &t);
|
|
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);
|
|
QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = gettextFromC::tr("sec"), QString separator = ":", bool isFreeDive = false);
|
|
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);
|
|
std::string get_dive_date_c_string(timestamp_t when);
|
|
QString get_first_dive_date_string();
|
|
QString get_last_dive_date_string();
|
|
QString get_short_dive_date_string(timestamp_t when);
|
|
QString getUiLanguage();
|
|
void initUiLanguage();
|
|
QLocale getLocale();
|
|
QVector<QPair<QString, int>> selectedDivesGasUsed();
|
|
QString getUserAgent();
|
|
QString printGPSCoords(const location_t *loc);
|
|
std::string printGPSCoordsC(const location_t *loc);
|
|
std::vector<int> get_cylinder_map_for_remove(int count, int n);
|
|
std::vector<int> get_cylinder_map_for_add(int count, int n);
|
|
std::string get_current_date();
|
|
|
|
extern QString (*changesCallback)();
|
|
void uiNotification(const QString &msg);
|
|
std::string get_changes_made();
|
|
std::string subsurface_user_agent();
|
|
std::string get_file_name(const std::string &fileName);
|
|
std::string move_away(const std::string &path);
|
|
|
|
#if defined __APPLE__
|
|
#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
|
|
#else
|
|
#define TITLE_OR_TEXT(_t, _m) _t, _m
|
|
#endif
|
|
|
|
bool canReachCloudServer(struct git_info *);
|
|
void updateWindowTitle();
|
|
void subsurface_mkdir(const char *dir);
|
|
std::string local_file_path(const struct picture &picture);
|
|
std::string hashfile_name();
|
|
enum deco_mode decoMode(bool in_planner);
|
|
void parse_seabear_header(const char *filename, struct xml_params *params);
|
|
time_t get_dive_datetime_from_isostring(char *when);
|
|
void print_qt_versions();
|
|
void lock_planner();
|
|
void unlock_planner();
|
|
xsltStylesheetPtr get_stylesheet(const char *name);
|
|
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);
|
|
void emit_reset_signal();
|
|
|
|
#endif // QTHELPER_H
|