mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Massive automated whitespace cleanup
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
006265d7a0
commit
76e6420f6b
114 changed files with 4370 additions and 3717 deletions
12
deco.c
12
deco.c
|
@ -50,7 +50,8 @@ const double buehlmann_N2_factor_expositon_one_second[] = {
|
|||
2.30782347297664E-003, 1.44301447809736E-003, 9.23769302935806E-004, 6.24261986779007E-004,
|
||||
4.27777107246730E-004, 3.01585140931371E-004, 2.12729727268379E-004, 1.50020603047807E-004,
|
||||
1.05980191127841E-004, 7.91232600646508E-005, 6.17759153688224E-005, 4.83354552742732E-005,
|
||||
3.78761777920511E-005, 2.96212356654113E-005, 2.31974277413727E-005, 1.81926738960225E-005};
|
||||
3.78761777920511E-005, 2.96212356654113E-005, 2.31974277413727E-005, 1.81926738960225E-005
|
||||
};
|
||||
|
||||
const double buehlmann_He_a[] = { 1.6189, 1.383, 1.1919, 1.0458,
|
||||
0.922, 0.8205, 0.7305, 0.6502,
|
||||
|
@ -71,7 +72,8 @@ const double buehlmann_He_factor_expositon_one_second[] = {
|
|||
6.12608039419837E-003, 3.81800836683133E-003, 2.44456078654209E-003, 1.65134647076792E-003,
|
||||
1.13084424730725E-003, 7.97503165599123E-004, 5.62552521860549E-004, 3.96776399429366E-004,
|
||||
2.80360036664540E-004, 2.09299583354805E-004, 1.63410794820518E-004, 1.27869320250551E-004,
|
||||
1.00198406028040E-004, 7.83611475491108E-005, 6.13689891868496E-005, 4.81280465299827E-005};
|
||||
1.00198406028040E-004, 7.83611475491108E-005, 6.13689891868496E-005, 4.81280465299827E-005
|
||||
};
|
||||
|
||||
#define WV_PRESSURE 0.0627 // water vapor pressure in bar
|
||||
#define DECO_STOPS_MULTIPLIER_MM 3000.0
|
||||
|
@ -94,8 +96,7 @@ static double tissue_tolerance_calc(const struct dive *dive)
|
|||
double gf_low = buehlmann_config.gf_low;
|
||||
double surface = get_surface_pressure_in_mbar(dive, true) / 1000.0;
|
||||
|
||||
for (ci = 0; ci < 16; ci++)
|
||||
{
|
||||
for (ci = 0; ci < 16; ci++) {
|
||||
double tolerated;
|
||||
|
||||
tissue_inertgas_saturation = tissue_n2_sat[ci] + tissue_he_sat[ci];
|
||||
|
@ -120,8 +121,7 @@ static double tissue_tolerance_calc(const struct dive *dive)
|
|||
|
||||
tolerated_by_tissue[ci] = tolerated;
|
||||
|
||||
if (tolerated > ret_tolerance_limit_ambient_pressure)
|
||||
{
|
||||
if (tolerated > ret_tolerance_limit_ambient_pressure) {
|
||||
ci_pointing_to_guiding_tissue = ci;
|
||||
ret_tolerance_limit_ambient_pressure = tolerated;
|
||||
}
|
||||
|
|
18
device.c
18
device.c
|
@ -72,10 +72,14 @@ static int fill_samples(struct sample *s, int max_d, int avg_d, int max_t, doubl
|
|||
if (t1 < 0 || t1 > t2 || t2 > t3 || t3 > t4 || t4 > max_t)
|
||||
return 0;
|
||||
|
||||
s[1].time.seconds = t1; s[1].depth.mm = max_d;
|
||||
s[2].time.seconds = t2; s[2].depth.mm = max_d;
|
||||
s[3].time.seconds = t3; s[3].depth.mm = max_d * d_frac;
|
||||
s[4].time.seconds = t4; s[4].depth.mm = max_d * d_frac;
|
||||
s[1].time.seconds = t1;
|
||||
s[1].depth.mm = max_d;
|
||||
s[2].time.seconds = t2;
|
||||
s[2].depth.mm = max_d;
|
||||
s[3].time.seconds = t3;
|
||||
s[3].depth.mm = max_d * d_frac;
|
||||
s[4].time.seconds = t4;
|
||||
s[4].depth.mm = max_d * d_frac;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -88,8 +92,10 @@ static void fill_samples_no_avg(struct sample *s, int max_d, int max_t, double s
|
|||
{
|
||||
// shallow or short dives are just trapecoids based on the given slope
|
||||
if (max_d < 10000 || max_t < 600) {
|
||||
s[1].time.seconds = max_d / slope; s[1].depth.mm = max_d;
|
||||
s[2].time.seconds = max_t - max_d / slope; s[2].depth.mm = max_d;
|
||||
s[1].time.seconds = max_d / slope;
|
||||
s[1].depth.mm = max_d;
|
||||
s[2].time.seconds = max_t - max_d / slope;
|
||||
s[2].depth.mm = max_d;
|
||||
} else {
|
||||
s[1].time.seconds = max_d / slope;
|
||||
s[1].depth.mm = max_d;
|
||||
|
|
11
display.h
11
display.h
|
@ -39,13 +39,20 @@ struct graphics_context {
|
|||
struct plot_info pi;
|
||||
};
|
||||
|
||||
typedef enum { SC_SCREEN, SC_PRINT } scale_mode_t;
|
||||
typedef enum {
|
||||
SC_SCREEN,
|
||||
SC_PRINT
|
||||
} scale_mode_t;
|
||||
|
||||
extern struct divecomputer *select_dc(struct divecomputer *main);
|
||||
extern void get_plot_details(struct graphics_context *gc, int time, struct membuffer *mb);
|
||||
|
||||
struct options {
|
||||
enum { PRETTY, TABLE, TWOPERPAGE } type;
|
||||
enum {
|
||||
PRETTY,
|
||||
TABLE,
|
||||
TWOPERPAGE
|
||||
} type;
|
||||
int print_selected;
|
||||
int color_selected;
|
||||
bool notes_up;
|
||||
|
|
27
dive.c
27
dive.c
|
@ -1083,7 +1083,8 @@ static char *merge_text(const char *a, const char *b)
|
|||
}
|
||||
|
||||
#define SORT(a, b, field) \
|
||||
if (a->field != b->field) return a->field < b->field ? -1 : 1
|
||||
if (a->field != b->field) \
|
||||
return a->field < b->field ? -1 : 1
|
||||
|
||||
static int sort_event(struct event *a, struct event *b)
|
||||
{
|
||||
|
@ -1434,7 +1435,8 @@ static unsigned long sample_difference(struct divecomputer *a, struct divecomput
|
|||
* skip the first sample - this way we know can always look at
|
||||
* as/bs[-1] to look at the samples around it in the loop.
|
||||
*/
|
||||
as++; bs++;
|
||||
as++;
|
||||
bs++;
|
||||
asamples--;
|
||||
bsamples--;
|
||||
|
||||
|
@ -1468,8 +1470,10 @@ static unsigned long sample_difference(struct divecomputer *a, struct divecomput
|
|||
bsamples--;
|
||||
} else {
|
||||
diff = compare_sample(as, bs, NULL, 0);
|
||||
as++; bs++;
|
||||
asamples--; bsamples--;
|
||||
as++;
|
||||
bs++;
|
||||
asamples--;
|
||||
bsamples--;
|
||||
}
|
||||
|
||||
/* Invalid comparison point? */
|
||||
|
@ -1559,7 +1563,8 @@ static int similar(unsigned long a, unsigned long b, unsigned long expected)
|
|||
if (a && b) {
|
||||
unsigned long min, max, diff;
|
||||
|
||||
min = a; max = b;
|
||||
min = a;
|
||||
max = b;
|
||||
if (a > b) {
|
||||
min = b;
|
||||
max = a;
|
||||
|
@ -1921,7 +1926,8 @@ static void join_dive_computers(struct divecomputer *res, struct divecomputer *a
|
|||
remove_redundant_dc(res, prefer_downloaded);
|
||||
}
|
||||
|
||||
int taglist_get_tagstring(struct tag_entry *tag_list, char *buffer, int len) {
|
||||
int taglist_get_tagstring(struct tag_entry *tag_list, char *buffer, int len)
|
||||
{
|
||||
int i = 0;
|
||||
struct tag_entry *tmp;
|
||||
tmp = tag_list->next;
|
||||
|
@ -1961,7 +1967,8 @@ struct divetag *taglist_get_tag(struct tag_entry *tag_list, const char *tag)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline void taglist_free_divetag(struct divetag *tag) {
|
||||
static inline void taglist_free_divetag(struct divetag *tag)
|
||||
{
|
||||
if (tag->name != NULL)
|
||||
free(tag->name);
|
||||
if (tag->source != NULL)
|
||||
|
@ -2032,14 +2039,16 @@ struct divetag *taglist_add_tag(struct tag_entry *tag_list, const char *tag)
|
|||
return ret_tag;
|
||||
}
|
||||
|
||||
void taglist_init(struct tag_entry **tag_list) {
|
||||
void taglist_init(struct tag_entry **tag_list)
|
||||
{
|
||||
*tag_list = malloc(sizeof(struct tag_entry));
|
||||
(*tag_list)->next = NULL;
|
||||
(*tag_list)->tag = NULL;
|
||||
}
|
||||
|
||||
/* Clear everything but the first element */
|
||||
void taglist_clear(struct tag_entry *tag_list) {
|
||||
void taglist_clear(struct tag_entry *tag_list)
|
||||
{
|
||||
struct tag_entry *current_tag_entry, *next;
|
||||
current_tag_entry = tag_list->next;
|
||||
while (current_tag_entry != NULL) {
|
||||
|
|
96
dive.h
96
dive.h
|
@ -84,35 +84,43 @@ extern "C" {
|
|||
*/
|
||||
typedef int64_t timestamp_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int seconds;
|
||||
} duration_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int mm;
|
||||
} depth_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int mbar;
|
||||
} pressure_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int mkelvin;
|
||||
} temperature_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int mliter;
|
||||
} volume_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int permille;
|
||||
} fraction_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int grams;
|
||||
} weight_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int udeg;
|
||||
} degrees_t;
|
||||
|
||||
|
@ -121,13 +129,15 @@ struct gasmix {
|
|||
fraction_t he;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
volume_t size;
|
||||
pressure_t workingpressure;
|
||||
const char *description; /* "LP85", "AL72", "AL80", "HP100+" or whatever */
|
||||
} cylinder_type_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
cylinder_type_t type;
|
||||
struct gasmix gasmix;
|
||||
pressure_t start, end, sample_start, sample_end;
|
||||
|
@ -135,7 +145,8 @@ typedef struct {
|
|||
bool used;
|
||||
} cylinder_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
weight_t weight;
|
||||
const char *description; /* "integrated", "belt", "ankle" */
|
||||
} weightsystem_t;
|
||||
|
@ -366,9 +377,16 @@ struct divecomputer {
|
|||
#define W_IDX_PRIMARY 0
|
||||
#define W_IDX_SECONDARY 1
|
||||
|
||||
typedef enum { TF_NONE, NO_TRIP, IN_TRIP, ASSIGNED_TRIP, NUM_TRIPFLAGS } tripflag_t;
|
||||
typedef enum {
|
||||
TF_NONE,
|
||||
NO_TRIP,
|
||||
IN_TRIP,
|
||||
ASSIGNED_TRIP,
|
||||
NUM_TRIPFLAGS
|
||||
} tripflag_t;
|
||||
|
||||
typedef struct dive_trip {
|
||||
typedef struct dive_trip
|
||||
{
|
||||
timestamp_t when;
|
||||
char *location;
|
||||
char *notes;
|
||||
|
@ -509,12 +527,32 @@ extern void insert_trip(dive_trip_t **trip);
|
|||
#undef PASCAL
|
||||
#endif
|
||||
struct units {
|
||||
enum { METERS, FEET } length;
|
||||
enum { LITER, CUFT } volume;
|
||||
enum { BAR, PSI, PASCAL } pressure;
|
||||
enum { CELSIUS, FAHRENHEIT, KELVIN } temperature;
|
||||
enum { KG, LBS } weight;
|
||||
enum { SECONDS, MINUTES } vertical_speed_time;
|
||||
enum {
|
||||
METERS,
|
||||
FEET
|
||||
} length;
|
||||
enum {
|
||||
LITER,
|
||||
CUFT
|
||||
} volume;
|
||||
enum {
|
||||
BAR,
|
||||
PSI,
|
||||
PASCAL
|
||||
} pressure;
|
||||
enum {
|
||||
CELSIUS,
|
||||
FAHRENHEIT,
|
||||
KELVIN
|
||||
} temperature;
|
||||
enum {
|
||||
KG,
|
||||
LBS
|
||||
} weight;
|
||||
enum {
|
||||
SECONDS,
|
||||
MINUTES
|
||||
} vertical_speed_time;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -524,22 +562,14 @@ struct units {
|
|||
* actually use. Similarly, C instead of Kelvin.
|
||||
* And kg instead of g.
|
||||
*/
|
||||
#define SI_UNITS { \
|
||||
.length = METERS, \
|
||||
.volume = LITER, \
|
||||
.pressure = BAR, \
|
||||
.temperature = CELSIUS, \
|
||||
.weight = KG, \
|
||||
.vertical_speed_time = MINUTES \
|
||||
#define SI_UNITS \
|
||||
{ \
|
||||
.length = METERS, .volume = LITER, .pressure = BAR, .temperature = CELSIUS, .weight = KG, .vertical_speed_time = MINUTES \
|
||||
}
|
||||
|
||||
#define IMPERIAL_UNITS { \
|
||||
.length = FEET, \
|
||||
.volume = CUFT, \
|
||||
.pressure = PSI, \
|
||||
.temperature = FAHRENHEIT, \
|
||||
.weight = LBS, \
|
||||
.vertical_speed_time = MINUTES \
|
||||
#define IMPERIAL_UNITS \
|
||||
{ \
|
||||
.length = FEET, .volume = CUFT, .pressure = PSI, .temperature = FAHRENHEIT, .weight = LBS, .vertical_speed_time = MINUTES \
|
||||
}
|
||||
extern const struct units SI_units, IMPERIAL_units;
|
||||
extern struct units xml_parsing_units;
|
||||
|
|
|
@ -133,8 +133,7 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
|
|||
if (is_air(o2, he)) {
|
||||
if (is_air(event_o2 * 10, event_he * 10))
|
||||
used = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (he == event_he * 10 && o2 == event_o2 * 10)
|
||||
used = 1;
|
||||
}
|
||||
|
|
4
file.c
4
file.c
|
@ -225,7 +225,9 @@ timestamp_t parse_date(const char *date)
|
|||
}
|
||||
|
||||
enum csv_format {
|
||||
CSV_DEPTH, CSV_TEMP, CSV_PRESSURE
|
||||
CSV_DEPTH,
|
||||
CSV_TEMP,
|
||||
CSV_PRESSURE
|
||||
};
|
||||
|
||||
static void add_sample_data(struct sample *sample, enum csv_format type, double val)
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
|
||||
extern "C" const char *trGettext(const char *text);
|
||||
|
||||
class gettextFromC
|
||||
{
|
||||
class gettextFromC {
|
||||
Q_DECLARE_TR_FUNCTIONS(gettextFromC)
|
||||
public:
|
||||
static gettextFromC *instance();
|
||||
|
|
|
@ -570,10 +570,14 @@ static unsigned int undo_libdivecomputer_suunto_nr_changes(unsigned int serial)
|
|||
return serial;
|
||||
|
||||
/* Nope, it was converted. */
|
||||
b0 = serial % 100; serial /= 100;
|
||||
b1 = serial % 100; serial /= 100;
|
||||
b2 = serial % 100; serial /= 100;
|
||||
b3 = serial % 100; serial /= 100;
|
||||
b0 = serial % 100;
|
||||
serial /= 100;
|
||||
b1 = serial % 100;
|
||||
serial /= 100;
|
||||
b2 = serial % 100;
|
||||
serial /= 100;
|
||||
b3 = serial % 100;
|
||||
serial /= 100;
|
||||
|
||||
serial = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24);
|
||||
return serial;
|
||||
|
|
|
@ -15,7 +15,8 @@ extern "C" {
|
|||
|
||||
/* don't forget to include the UI toolkit specific display-XXX.h first
|
||||
to get the definition of progressbar_t */
|
||||
typedef struct device_data_t {
|
||||
typedef struct device_data_t
|
||||
{
|
||||
dc_descriptor_t *descriptor;
|
||||
const char *vendor, *product, *devname;
|
||||
const char *model;
|
||||
|
|
18
planner.c
18
planner.c
|
@ -18,8 +18,7 @@ unsigned int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 2100
|
|||
60000, 63000, 66000, 69000, 72000, 75000, 78000, 81000, 84000, 87000,
|
||||
90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000,
|
||||
180000, 190000, 200000, 220000, 240000, 260000, 280000, 300000,
|
||||
320000, 340000, 360000, 380000
|
||||
};
|
||||
320000, 340000, 360000, 380000 };
|
||||
double plangflow, plangfhigh;
|
||||
char *disclaimer;
|
||||
|
||||
|
@ -44,7 +43,6 @@ void dump_plan(struct diveplan *diveplan)
|
|||
printf("\t%3u:%02u: %dmm gas: %d o2 %d h2\n", FRACTION(dp->time, 60), dp->depth, dp->o2, dp->he);
|
||||
dp = dp->next;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -291,7 +289,8 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error
|
|||
if ((idx = add_gas(dive, plano2, planhe)) < 0)
|
||||
goto gas_error_exit;
|
||||
add_gas_switch_event(dive, dc, lasttime, idx);
|
||||
oldo2 = o2; oldhe = he;
|
||||
oldo2 = o2;
|
||||
oldhe = he;
|
||||
}
|
||||
/* Create sample */
|
||||
sample = prepare_sample(dc);
|
||||
|
@ -774,11 +773,15 @@ int validate_gas(const char *text, int *o2_p, int *he_p)
|
|||
return 0;
|
||||
|
||||
if (!strcasecmp(text, translate("gettextFromC", "air"))) {
|
||||
o2 = O2_IN_AIR; he = 0; text += strlen(translate("gettextFromC","air"));
|
||||
o2 = O2_IN_AIR;
|
||||
he = 0;
|
||||
text += strlen(translate("gettextFromC", "air"));
|
||||
} else if (!strncasecmp(text, translate("gettextFromC", "ean"), 3)) {
|
||||
o2 = get_permille(text+3, &text); he = 0;
|
||||
o2 = get_permille(text + 3, &text);
|
||||
he = 0;
|
||||
} else {
|
||||
o2 = get_permille(text, &text); he = 0;
|
||||
o2 = get_permille(text, &text);
|
||||
he = 0;
|
||||
if (*text == '/')
|
||||
he = get_permille(text + 1, &text);
|
||||
}
|
||||
|
@ -821,4 +824,3 @@ int validate_po2(const char *text, int *mbar_po2)
|
|||
*mbar_po2 = po2 * 100;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
9
pref.h
9
pref.h
|
@ -6,7 +6,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* can't use 'bool' for the boolean values - different size in C and C++ */
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
short po2;
|
||||
short pn2;
|
||||
short phe;
|
||||
|
@ -40,7 +41,11 @@ struct preferences {
|
|||
bool display_unused_tanks;
|
||||
bool zoomed_plot;
|
||||
};
|
||||
enum unit_system_values { METRIC, IMPERIAL, PERSONALIZE };
|
||||
enum unit_system_values {
|
||||
METRIC,
|
||||
IMPERIAL,
|
||||
PERSONALIZE
|
||||
};
|
||||
|
||||
extern struct preferences prefs, default_prefs;
|
||||
|
||||
|
|
36
profile.c
36
profile.c
|
@ -102,8 +102,7 @@ int evn_allocated;
|
|||
int evn_used;
|
||||
|
||||
#if WE_DONT_USE_THIS /* we need to implement event filters in Qt */
|
||||
int evn_foreach(void (*callback)(const char *, bool *, void *), void *data)
|
||||
{
|
||||
int evn_foreach(void (*callback)(const char *, bool *, void *), void *data) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < evn_used; i++) {
|
||||
|
@ -152,7 +151,8 @@ int setup_temperature_limits(struct graphics_context *gc)
|
|||
mintemp = pi->mintemp;
|
||||
maxtemp = pi->maxtemp;
|
||||
|
||||
gc->leftx = 0; gc->rightx = maxtime;
|
||||
gc->leftx = 0;
|
||||
gc->rightx = maxtime;
|
||||
/* Show temperatures in roughly the lower third, but make sure the scale
|
||||
is at least somewhat reasonable */
|
||||
delta = maxtemp - mintemp;
|
||||
|
@ -361,7 +361,8 @@ struct pr_track_struct {
|
|||
pr_track_t *next;
|
||||
};
|
||||
|
||||
static pr_track_t *pr_track_alloc(int start, int t_start) {
|
||||
static pr_track_t *pr_track_alloc(int start, int t_start)
|
||||
{
|
||||
pr_track_t *pt = malloc(sizeof(pr_track_t));
|
||||
pt->start = start;
|
||||
pt->end = 0;
|
||||
|
@ -1128,7 +1129,8 @@ static void populate_pressure_information(struct dive *dive, struct divecomputer
|
|||
}
|
||||
|
||||
/* calculate DECO STOP / TTS / NDL */
|
||||
static void calculate_ndl_tts(double tissue_tolerance, struct plot_data *entry, struct dive *dive, double surface_pressure) {
|
||||
static void calculate_ndl_tts(double tissue_tolerance, struct plot_data *entry, struct dive *dive, double surface_pressure)
|
||||
{
|
||||
/* FIXME: This should be configurable */
|
||||
/* ascent speed up to first deco stop */
|
||||
const int ascent_s_per_step = 1;
|
||||
|
@ -1276,13 +1278,17 @@ static void calculate_gas_information(struct dive *dive, struct plot_info *pi)
|
|||
* END just uses N2 */
|
||||
entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
|
||||
entry->ead = (entry->depth + 10000) *
|
||||
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure - 10000;
|
||||
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure -
|
||||
10000;
|
||||
entry->end = (entry->depth + 10000) *
|
||||
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 - 10000;
|
||||
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 -
|
||||
10000;
|
||||
entry->eadd = (entry->depth + 10000) *
|
||||
(entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure *
|
||||
N2_DENSITY + entry->phe / amb_pressure * HE_DENSITY) /
|
||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -10000;
|
||||
N2_DENSITY +
|
||||
entry->phe / amb_pressure * HE_DENSITY) /
|
||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -
|
||||
10000;
|
||||
if (entry->mod < 0)
|
||||
entry->mod = 0;
|
||||
if (entry->ead < 0)
|
||||
|
@ -1337,13 +1343,17 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *
|
|||
* END just uses N2 */
|
||||
entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
|
||||
entry->ead = (entry->depth + 10000) *
|
||||
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure - 10000;
|
||||
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure -
|
||||
10000;
|
||||
entry->end = (entry->depth + 10000) *
|
||||
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 - 10000;
|
||||
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 -
|
||||
10000;
|
||||
entry->eadd = (entry->depth + 10000) *
|
||||
(entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure *
|
||||
N2_DENSITY + entry->phe / amb_pressure * HE_DENSITY) /
|
||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -10000;
|
||||
N2_DENSITY +
|
||||
entry->phe / amb_pressure * HE_DENSITY) /
|
||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -
|
||||
10000;
|
||||
if (entry->mod < 0)
|
||||
entry->mod = 0;
|
||||
if (entry->ead < 0)
|
||||
|
|
|
@ -5,7 +5,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum { STABLE, SLOW, MODERATE, FAST, CRAZY } velocity_t;
|
||||
typedef enum {
|
||||
STABLE,
|
||||
SLOW,
|
||||
MODERATE,
|
||||
FAST,
|
||||
CRAZY
|
||||
} velocity_t;
|
||||
|
||||
struct membuffer;
|
||||
struct divecomputer;
|
||||
|
|
10
qt-gui.cpp
10
qt-gui.cpp
|
@ -131,8 +131,7 @@ void init_ui(int *argcp, char ***argvp)
|
|||
if (qtTranslator->load(loc, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
|
||||
application->installTranslator(qtTranslator);
|
||||
} else {
|
||||
qDebug() << "can't find Qt localization for locale" << uiLang <<
|
||||
"searching in" << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
qDebug() << "can't find Qt localization for locale" << uiLang << "searching in" << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
}
|
||||
ssrfTranslator = new QTranslator;
|
||||
if (ssrfTranslator->load(loc, "subsurface", "_") ||
|
||||
|
@ -306,12 +305,10 @@ QString get_temperature_string(temperature_t temp, bool showunit)
|
|||
return ""; //temperature not defined
|
||||
} else if (prefs.units.temperature == units::CELSIUS) {
|
||||
double celsius = mkelvin_to_C(temp.mkelvin);
|
||||
return QString("%1%2%3").arg(celsius, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE): "")
|
||||
.arg(showunit ? translate("gettextFromC","C") : "");
|
||||
return QString("%1%2%3").arg(celsius, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE) : "").arg(showunit ? translate("gettextFromC", "C") : "");
|
||||
} else {
|
||||
double fahrenheit = mkelvin_to_F(temp.mkelvin);
|
||||
return QString("%1%2%3").arg(fahrenheit, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE): "")
|
||||
.arg(showunit ? translate("gettextFromC","F") : "");
|
||||
return QString("%1%2%3").arg(fahrenheit, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE) : "").arg(showunit ? translate("gettextFromC", "F") : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -492,7 +489,6 @@ int parseTemperatureToMkelvin(const QString& text)
|
|||
mkelvin = 0;
|
||||
}
|
||||
return mkelvin;
|
||||
|
||||
}
|
||||
|
||||
QString get_dive_date_string(timestamp_t when)
|
||||
|
|
|
@ -9,11 +9,11 @@ SubsurfaceAbout::SubsurfaceAbout(QWidget *parent, Qt::WindowFlags f) : QDialog(p
|
|||
|
||||
setWindowModality(Qt::ApplicationModal);
|
||||
|
||||
ui.aboutLabel->setText(tr("<span style='font-size: 18pt; font-weight: bold;'>" \
|
||||
"Subsurface %1 </span><br><br>" \
|
||||
"Multi-platform divelog software<br>" \
|
||||
"<span style='font-size: 8pt'>" \
|
||||
"Linus Torvalds, Dirk Hohndel, Tomaz Canabrava, and others, 2011-2014" \
|
||||
ui.aboutLabel->setText(tr("<span style='font-size: 18pt; font-weight: bold;'>"
|
||||
"Subsurface %1 </span><br><br>"
|
||||
"Multi-platform divelog software<br>"
|
||||
"<span style='font-size: 8pt'>"
|
||||
"Linus Torvalds, Dirk Hohndel, Tomaz Canabrava, and others, 2011-2014"
|
||||
"</span>").arg(VERSION_STRING));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,11 @@ class SubsurfaceAbout : public QDialog {
|
|||
|
||||
public:
|
||||
explicit SubsurfaceAbout(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void on_licenseButton_clicked();
|
||||
void on_websiteButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::SubsurfaceAbout ui;
|
||||
};
|
||||
|
|
|
@ -8,7 +8,8 @@ void Class::updateModel() \
|
|||
QStringList list; \
|
||||
struct dive *dive; \
|
||||
int i = 0; \
|
||||
for_each_dive(i, dive) { \
|
||||
for_each_dive(i, dive) \
|
||||
{ \
|
||||
QString buddy(dive->diveStructMember); \
|
||||
if (!list.contains(buddy)) { \
|
||||
list.append(buddy); \
|
||||
|
@ -23,9 +24,11 @@ void Class::updateModel() \
|
|||
QSet<QString> set; \
|
||||
struct dive *dive; \
|
||||
int i = 0; \
|
||||
for_each_dive(i, dive) { \
|
||||
for_each_dive(i, dive) \
|
||||
{ \
|
||||
QString buddy(dive->diveStructMember); \
|
||||
foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) { \
|
||||
foreach(const QString &value, buddy.split(",", QString::SkipEmptyParts)) \
|
||||
{ \
|
||||
set.insert(value.trimmed()); \
|
||||
} \
|
||||
} \
|
||||
|
|
|
@ -44,8 +44,7 @@ void DiveComputerManagementDialog::tryRemove(const QModelIndex& index)
|
|||
this, TITLE_OR_TEXT(
|
||||
tr("Remove the selected Dive Computer?"),
|
||||
tr("Are you sure that you want to \n remove the selected dive computer?")),
|
||||
QMessageBox::Ok | QMessageBox::Cancel
|
||||
);
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
|
||||
if (response == QMessageBox::Ok)
|
||||
model->remove(index);
|
||||
|
|
|
@ -14,7 +14,8 @@ public:
|
|||
void update();
|
||||
void init();
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void tryRemove(const QModelIndex &index);
|
||||
void accept();
|
||||
void reject();
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#include <iostream>
|
||||
|
||||
|
||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
||||
sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(this)
|
||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(this)
|
||||
{
|
||||
setItemDelegate(new DiveListDelegate(this));
|
||||
setUniformRowHeights(true);
|
||||
|
@ -387,14 +386,7 @@ void DiveListView::reloadHeaderActions()
|
|||
QString settingName = QString("showColumn%1").arg(i);
|
||||
QAction *a = new QAction(title, header());
|
||||
bool showHeaderFirstRun = !(
|
||||
i == DiveTripModel::MAXCNS
|
||||
|| i == DiveTripModel::NITROX
|
||||
|| i == DiveTripModel::OTU
|
||||
|| i == DiveTripModel::TEMPERATURE
|
||||
|| i == DiveTripModel::TOTALWEIGHT
|
||||
|| i == DiveTripModel::SUIT
|
||||
|| i == DiveTripModel::CYLINDER
|
||||
|| i == DiveTripModel::SAC );
|
||||
i == DiveTripModel::MAXCNS || i == DiveTripModel::NITROX || i == DiveTripModel::OTU || i == DiveTripModel::TEMPERATURE || i == DiveTripModel::TOTALWEIGHT || i == DiveTripModel::SUIT || i == DiveTripModel::CYLINDER || i == DiveTripModel::SAC);
|
||||
bool shown = s.value(settingName, showHeaderFirstRun).toBool();
|
||||
a->setCheckable(true);
|
||||
a->setChecked(shown);
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
#include <QLineEdit>
|
||||
#include "models.h"
|
||||
|
||||
class DiveListView : public QTreeView
|
||||
{
|
||||
class DiveListView : public QTreeView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveListView(QWidget *parent = 0);
|
||||
|
@ -32,7 +31,8 @@ public:
|
|||
void restoreSelection();
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
QList<dive_trip_t *> selectedTrips();
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void toggleColumnVisibilityByIndex();
|
||||
void reloadHeaderActions();
|
||||
void headerClicked(int);
|
||||
|
|
|
@ -12,8 +12,7 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
|
|||
{ NULL, }
|
||||
};
|
||||
|
||||
DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
|
||||
selector(true),
|
||||
ui(new Ui::DiveLogImportDialog)
|
||||
{
|
||||
|
|
|
@ -6,19 +6,20 @@
|
|||
#include "../dive.h"
|
||||
#include "../divelist.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class DiveLogImportDialog;
|
||||
}
|
||||
|
||||
class DiveLogImportDialog : public QDialog
|
||||
{
|
||||
class DiveLogImportDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiveLogImportDialog(QStringList *fn, QWidget *parent = 0);
|
||||
~DiveLogImportDialog();
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_knownImports_currentIndexChanged(int index);
|
||||
void unknownImports();
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
#define MAX_DEPTH M_OR_FT(150, 450)
|
||||
#define MIN_DEPTH M_OR_FT(20, 60)
|
||||
|
||||
QString gasToStr(const int o2Permille, const int hePermille) {
|
||||
QString gasToStr(const int o2Permille, const int hePermille)
|
||||
{
|
||||
uint o2 = (o2Permille + 5) / 10, he = (hePermille + 5) / 10;
|
||||
QString result = is_air(o2Permille, hePermille) ? QObject::tr("AIR")
|
||||
: he == 0 ? QString("EAN%1").arg(o2, 2, 10, QChar('0'))
|
||||
: QString("%1/%2").arg(o2).arg(he);
|
||||
QString result = is_air(o2Permille, hePermille) ? QObject::tr("AIR") : he == 0 ? QString("EAN%1").arg(o2, 2, 10, QChar('0')) : QString("%1/%2").arg(o2).arg(he);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -85,8 +84,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent) : QGraphicsView(parent
|
|||
fromPercent(10, Qt::Horizontal),
|
||||
fromPercent(85, Qt::Vertical),
|
||||
fromPercent(90, Qt::Horizontal),
|
||||
fromPercent(85, Qt::Vertical)
|
||||
);
|
||||
fromPercent(85, Qt::Vertical));
|
||||
timeLine->setOrientation(Qt::Horizontal);
|
||||
timeLine->setTickSize(fromPercent(1, Qt::Vertical));
|
||||
timeLine->setTextColor(getColor(TIME_TEXT));
|
||||
|
@ -101,8 +99,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent) : QGraphicsView(parent
|
|||
fromPercent(10, Qt::Horizontal),
|
||||
fromPercent(10, Qt::Vertical),
|
||||
fromPercent(10, Qt::Horizontal),
|
||||
fromPercent(85, Qt::Vertical)
|
||||
);
|
||||
fromPercent(85, Qt::Vertical));
|
||||
depthLine->setOrientation(Qt::Vertical);
|
||||
depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
|
||||
depthLine->setColor(getColor(DEPTH_GRID));
|
||||
|
@ -314,7 +311,8 @@ void DivePlannerGraphics::pointsRemoved(const QModelIndex& , int start, int end)
|
|||
drawProfile();
|
||||
}
|
||||
|
||||
bool intLessThan(int a, int b) {
|
||||
bool intLessThan(int a, int b)
|
||||
{
|
||||
return a <= b;
|
||||
}
|
||||
void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
|
||||
|
@ -544,8 +542,7 @@ void DivePlannerGraphics::drawProfile()
|
|||
b.x(),
|
||||
b.y(),
|
||||
b.x(),
|
||||
b.height() + b.y()
|
||||
);
|
||||
b.height() + b.y());
|
||||
|
||||
pat.setColorAt(1, profile_color[DEPTH_BOTTOM].first());
|
||||
pat.setColorAt(0, profile_color[DEPTH_TOP].first());
|
||||
|
@ -574,13 +571,9 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
|
|||
double xpos = timeLine->valueAt(mappedPos);
|
||||
double ypos = depthLine->valueAt(mappedPos);
|
||||
|
||||
xpos = (xpos > timeLine->maximum()) ? timeLine->posAtValue(timeLine->maximum())
|
||||
: (xpos < timeLine->minimum()) ? timeLine->posAtValue(timeLine->minimum())
|
||||
: timeLine->posAtValue(xpos);
|
||||
xpos = (xpos > timeLine->maximum()) ? timeLine->posAtValue(timeLine->maximum()) : (xpos < timeLine->minimum()) ? timeLine->posAtValue(timeLine->minimum()) : timeLine->posAtValue(xpos);
|
||||
|
||||
ypos = (ypos > depthLine->maximum()) ? depthLine->posAtValue(depthLine->maximum())
|
||||
: ( ypos < depthLine->minimum()) ? depthLine->posAtValue(depthLine->minimum())
|
||||
: depthLine->posAtValue(ypos);
|
||||
ypos = (ypos > depthLine->maximum()) ? depthLine->posAtValue(depthLine->maximum()) : (ypos < depthLine->minimum()) ? depthLine->posAtValue(depthLine->minimum()) : depthLine->posAtValue(ypos);
|
||||
|
||||
verticalLine->setPos(xpos, fromPercent(0, Qt::Vertical));
|
||||
horizontalLine->setPos(fromPercent(0, Qt::Horizontal), ypos);
|
||||
|
@ -1041,14 +1034,19 @@ QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
|
|||
if (role == Qt::DisplayRole) {
|
||||
divedatapoint p = divepoints.at(index.row());
|
||||
switch (index.column()) {
|
||||
case CCSETPOINT: return (double) p.po2 / 1000;
|
||||
case DEPTH: return rint(get_depth_units(p.depth, NULL, NULL));
|
||||
case DURATION: return p.time / 60;
|
||||
case GAS: return dpGasToStr(p);
|
||||
case CCSETPOINT:
|
||||
return (double)p.po2 / 1000;
|
||||
case DEPTH:
|
||||
return rint(get_depth_units(p.depth, NULL, NULL));
|
||||
case DURATION:
|
||||
return p.time / 60;
|
||||
case GAS:
|
||||
return dpGasToStr(p);
|
||||
}
|
||||
} else if (role == Qt::DecorationRole) {
|
||||
switch (index.column()) {
|
||||
case REMOVE : return QIcon(":trash");
|
||||
case REMOVE:
|
||||
return QIcon(":trash");
|
||||
}
|
||||
} else if (role == Qt::FontRole) {
|
||||
return defaultModelFont();
|
||||
|
@ -1063,15 +1061,18 @@ bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& v
|
|||
if (role == Qt::EditRole) {
|
||||
divedatapoint &p = divepoints[index.row()];
|
||||
switch (index.column()) {
|
||||
case DEPTH: p.depth = units_to_depth(value.toInt()); break;
|
||||
case DURATION: p.time = value.toInt() * 60; break;
|
||||
case DEPTH:
|
||||
p.depth = units_to_depth(value.toInt());
|
||||
break;
|
||||
case DURATION:
|
||||
p.time = value.toInt() * 60;
|
||||
break;
|
||||
case CCSETPOINT: {
|
||||
int po2 = 0;
|
||||
QByteArray gasv = value.toByteArray();
|
||||
if (validate_po2(gasv.data(), &po2))
|
||||
p.po2 = po2;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case GAS:
|
||||
QByteArray gasv = value.toByteArray();
|
||||
if (validate_gas(gasv.data(), &o2, &he)) {
|
||||
|
@ -1089,10 +1090,14 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta
|
|||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case DEPTH: return tr("Final Depth");
|
||||
case DURATION: return tr("Duration");
|
||||
case GAS: return tr("Used Gas");
|
||||
case CCSETPOINT: return tr("CC Set Point");
|
||||
case DEPTH:
|
||||
return tr("Final Depth");
|
||||
case DURATION:
|
||||
return tr("Duration");
|
||||
case GAS:
|
||||
return tr("Used Gas");
|
||||
case CCSETPOINT:
|
||||
return tr("CC Set Point");
|
||||
}
|
||||
} else if (role == Qt::FontRole) {
|
||||
return defaultModelFont();
|
||||
|
@ -1513,7 +1518,7 @@ ExpanderGraphics::ExpanderGraphics(QGraphicsItem* parent) : QGraphicsRectItem(pa
|
|||
QPixmap p;
|
||||
#define CREATE(item, pixmap) \
|
||||
p = QPixmap(QString(pixmap)); \
|
||||
item->setPixmap(p); \
|
||||
item->setPixmap(p);
|
||||
|
||||
CREATE(icon, ":icon_time");
|
||||
CREATE(bg, ":round_base");
|
||||
|
|
|
@ -16,8 +16,19 @@ class DivePlannerPointsModel : public QAbstractTableModel{
|
|||
Q_OBJECT
|
||||
public:
|
||||
static DivePlannerPointsModel *instance();
|
||||
enum Sections{REMOVE, DEPTH, DURATION, GAS, CCSETPOINT, COLUMNS};
|
||||
enum Mode { NOTHING, PLAN, ADD };
|
||||
enum Sections {
|
||||
REMOVE,
|
||||
DEPTH,
|
||||
DURATION,
|
||||
GAS,
|
||||
CCSETPOINT,
|
||||
COLUMNS
|
||||
};
|
||||
enum Mode {
|
||||
NOTHING,
|
||||
PLAN,
|
||||
ADD
|
||||
};
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
@ -44,7 +55,8 @@ public:
|
|||
QStringList &getGasList();
|
||||
QVector<QPair<int, int> > collectGases(dive *d);
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 0, int ccpoint = 0);
|
||||
void addCylinder_clicked();
|
||||
void setGFHigh(const int gfhigh);
|
||||
|
@ -64,6 +76,7 @@ public slots:
|
|||
signals:
|
||||
void planCreated();
|
||||
void planCanceled();
|
||||
|
||||
private:
|
||||
explicit DivePlannerPointsModel(QObject *parent = 0);
|
||||
bool addGas(int o2, int he);
|
||||
|
@ -84,10 +97,12 @@ public:
|
|||
Button(QObject *parent = 0, QGraphicsItem *itemParent = 0);
|
||||
void setText(const QString &text);
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
QGraphicsPixmapItem *icon;
|
||||
QGraphicsSimpleTextItem *text;
|
||||
|
@ -101,6 +116,7 @@ public:
|
|||
QGraphicsPixmapItem *icon;
|
||||
Button *increaseBtn;
|
||||
Button *decreaseBtn;
|
||||
|
||||
private:
|
||||
QGraphicsPixmapItem *bg;
|
||||
QGraphicsPixmapItem *leftWing;
|
||||
|
@ -111,12 +127,15 @@ class DiveHandler : public QObject, public QGraphicsEllipseItem{
|
|||
Q_OBJECT
|
||||
public:
|
||||
DiveHandler();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
private:
|
||||
int parentIndex();
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void selfRemove();
|
||||
void changeGas();
|
||||
};
|
||||
|
@ -157,6 +176,7 @@ class DivePlannerGraphics : public QGraphicsView {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DivePlannerGraphics(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
@ -166,9 +186,11 @@ protected:
|
|||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||
bool isPointOutOfBoundaries(const QPointF &point);
|
||||
qreal fromPercent(qreal percent, Qt::Orientation orientation);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void settingsChanged();
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void keyEscAction();
|
||||
void keyDeleteAction();
|
||||
void keyUpAction();
|
||||
|
@ -182,6 +204,7 @@ private slots:
|
|||
void drawProfile();
|
||||
void pointInserted(const QModelIndex &, int start, int end);
|
||||
void pointsRemoved(const QModelIndex &, int start, int end);
|
||||
|
||||
private:
|
||||
void moveActiveHandler(const QPointF &MappedPos, const int pos);
|
||||
|
||||
|
@ -232,11 +255,13 @@ class DivePlannerWidget : public QWidget {
|
|||
public:
|
||||
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void settingsChanged();
|
||||
void atmPressureChanged(const QString &pressure);
|
||||
void bottomSacChanged(const QString &bottomSac);
|
||||
void decoSacChanged(const QString &decosac);
|
||||
|
||||
private:
|
||||
Ui::DivePlanner ui;
|
||||
};
|
||||
|
|
|
@ -32,7 +32,8 @@ struct mydescriptor {
|
|||
unsigned int model;
|
||||
};
|
||||
|
||||
namespace DownloadFromDcGlobal {
|
||||
namespace DownloadFromDcGlobal
|
||||
{
|
||||
const char *err_string;
|
||||
};
|
||||
|
||||
|
@ -111,8 +112,7 @@ void DownloadFromDCWidget::updateState(states state)
|
|||
|
||||
// user pressed cancel but the application isn't doing anything.
|
||||
// means close the window
|
||||
else if ((currentState == INITIAL || currentState == CANCELLED || currentState == DONE || currentState == ERROR)
|
||||
&& state == CANCELLING) {
|
||||
else if ((currentState == INITIAL || currentState == CANCELLED || currentState == DONE || currentState == ERROR) && state == CANCELLING) {
|
||||
timer->stop();
|
||||
reject();
|
||||
ui.ok->setText(tr("OK"));
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
virtual void run();
|
||||
|
||||
QString error;
|
||||
|
||||
private:
|
||||
device_data_t *data;
|
||||
};
|
||||
|
@ -35,7 +36,8 @@ public:
|
|||
DONE,
|
||||
};
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void on_ok_clicked();
|
||||
void on_cancel_clicked();
|
||||
void on_search_clicked();
|
||||
|
@ -76,7 +78,6 @@ public:
|
|||
bool preferDownloaded();
|
||||
void updateState(states state);
|
||||
states currentState;
|
||||
|
||||
};
|
||||
|
||||
#endif // DOWNLOADFROMDIVECOMPUTER_H
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
// IF Entry
|
||||
struct IFEntry {
|
||||
// Raw fields
|
||||
|
@ -52,7 +53,8 @@ namespace {
|
|||
};
|
||||
|
||||
// Helper functions
|
||||
unsigned int parse32(const unsigned char *buf, bool intel) {
|
||||
unsigned int parse32(const unsigned char *buf, bool intel)
|
||||
{
|
||||
if (intel)
|
||||
return ((unsigned)buf[3] << 24) |
|
||||
((unsigned)buf[2] << 16) |
|
||||
|
@ -65,7 +67,8 @@ namespace {
|
|||
buf[3];
|
||||
}
|
||||
|
||||
unsigned short parse16(const unsigned char *buf, bool intel) {
|
||||
unsigned short parse16(const unsigned char *buf, bool intel)
|
||||
{
|
||||
if (intel)
|
||||
return ((unsigned)buf[1] << 8) | buf[0];
|
||||
return ((unsigned)buf[0] << 8) | buf[1];
|
||||
|
@ -75,7 +78,8 @@ namespace {
|
|||
const unsigned num_components,
|
||||
const unsigned data,
|
||||
const unsigned base,
|
||||
const unsigned len) {
|
||||
const unsigned len)
|
||||
{
|
||||
string value;
|
||||
if (num_components <= 4)
|
||||
value.assign((const char *)&data, num_components);
|
||||
|
@ -86,7 +90,8 @@ namespace {
|
|||
return value;
|
||||
}
|
||||
|
||||
double parseEXIFRational(const unsigned char *buf, bool intel) {
|
||||
double parseEXIFRational(const unsigned char *buf, bool intel)
|
||||
{
|
||||
double numerator = 0;
|
||||
double denominator = 1;
|
||||
|
||||
|
@ -101,7 +106,8 @@ namespace {
|
|||
const unsigned offs,
|
||||
const bool alignIntel,
|
||||
const unsigned base,
|
||||
const unsigned len) {
|
||||
const unsigned len)
|
||||
{
|
||||
IFEntry result;
|
||||
|
||||
// Each directory entry is composed of:
|
||||
|
@ -146,7 +152,8 @@ namespace {
|
|||
//
|
||||
// Locates the EXIF segment and parses it using parseFromEXIFSegment
|
||||
//
|
||||
int EXIFInfo::parseFrom(const unsigned char *buf, unsigned len) {
|
||||
int EXIFInfo::parseFrom(const unsigned char *buf, unsigned len)
|
||||
{
|
||||
// Sanity check: all JPEG files start with 0xFFD8 and end with 0xFFD9
|
||||
// This check also ensures that the user has supplied a correct value for len.
|
||||
if (!buf || len < 4)
|
||||
|
@ -184,7 +191,8 @@ int EXIFInfo::parseFrom(const unsigned char *buf, unsigned len) {
|
|||
return parseFromEXIFSegment(buf + offs, len - offs);
|
||||
}
|
||||
|
||||
int EXIFInfo::parseFrom(const string &data) {
|
||||
int EXIFInfo::parseFrom(const string &data)
|
||||
{
|
||||
return parseFrom((const unsigned char *)data.data(), data.length());
|
||||
}
|
||||
|
||||
|
@ -194,7 +202,8 @@ int EXIFInfo::parseFrom(const string &data) {
|
|||
// PARAM: 'buf' start of the EXIF TIFF, which must be the bytes "Exif\0\0".
|
||||
// PARAM: 'len' length of buffer
|
||||
//
|
||||
int EXIFInfo::parseFromEXIFSegment(const unsigned char *buf, unsigned len) {
|
||||
int EXIFInfo::parseFromEXIFSegment(const unsigned char *buf, unsigned len)
|
||||
{
|
||||
bool alignIntel = true; // byte alignment (defined in EXIF header)
|
||||
unsigned offs = 0; // current offset into buffer
|
||||
if (!buf || len < 6)
|
||||
|
@ -513,7 +522,8 @@ int EXIFInfo::parseFromEXIFSegment(const unsigned char *buf, unsigned len) {
|
|||
return PARSE_EXIF_SUCCESS;
|
||||
}
|
||||
|
||||
void EXIFInfo::clear() {
|
||||
void EXIFInfo::clear()
|
||||
{
|
||||
// Strings
|
||||
ImageDescription = "";
|
||||
Make = "";
|
||||
|
|
|
@ -112,7 +112,8 @@ class EXIFInfo {
|
|||
// 5: multi-segment
|
||||
unsigned ImageWidth; // Image width reported in EXIF data
|
||||
unsigned ImageHeight; // Image height reported in EXIF data
|
||||
struct Geolocation_t { // GPS information embedded in file
|
||||
struct Geolocation_t
|
||||
{ // GPS information embedded in file
|
||||
double Latitude; // Image latitude expressed as decimal
|
||||
double Longitude; // Image longitude expressed as decimal
|
||||
double Altitude; // Altitude in meters, relative to sea level
|
||||
|
@ -124,7 +125,8 @@ class EXIFInfo {
|
|||
char direction;
|
||||
} LatComponents, LonComponents; // Latitude, Longitude expressed in deg/min/sec
|
||||
} GeoLocation;
|
||||
EXIFInfo() {
|
||||
EXIFInfo()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,10 +20,12 @@ public:
|
|||
void repopulateLabels();
|
||||
void centerOn(struct dive *dive);
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
|
||||
protected:
|
||||
/* reimp */ void resizeEvent(QResizeEvent *event);
|
||||
/* reimp */ void mousePressEvent(QMouseEvent *event);
|
||||
/* reimp */ void contextMenuEvent(QContextMenuEvent *);
|
||||
|
||||
private:
|
||||
GeoDataDocument *loadedDives;
|
||||
KMessageWidget *messageWidget;
|
||||
|
@ -31,12 +33,12 @@ private:
|
|||
int currentZoomLevel;
|
||||
bool editingDiveLocation;
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit);
|
||||
void mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit);
|
||||
void fixZoom();
|
||||
void prepareForGetDiveCoordinates();
|
||||
|
||||
};
|
||||
|
||||
#endif // GLOBE_H
|
||||
|
|
|
@ -13,23 +13,62 @@
|
|||
|
||||
typedef enum {
|
||||
/* SAC colors. Order is important, the SAC_COLORS_START_IDX define above. */
|
||||
SAC_1, SAC_2, SAC_3, SAC_4, SAC_5, SAC_6, SAC_7, SAC_8, SAC_9,
|
||||
SAC_1,
|
||||
SAC_2,
|
||||
SAC_3,
|
||||
SAC_4,
|
||||
SAC_5,
|
||||
SAC_6,
|
||||
SAC_7,
|
||||
SAC_8,
|
||||
SAC_9,
|
||||
|
||||
/* Velocity colors. Order is still important, ref VELOCITY_COLORS_START_IDX. */
|
||||
VELO_STABLE, VELO_SLOW, VELO_MODERATE, VELO_FAST, VELO_CRAZY,
|
||||
VELO_STABLE,
|
||||
VELO_SLOW,
|
||||
VELO_MODERATE,
|
||||
VELO_FAST,
|
||||
VELO_CRAZY,
|
||||
|
||||
/* gas colors */
|
||||
PO2, PO2_ALERT, PN2, PN2_ALERT, PHE, PHE_ALERT, PP_LINES,
|
||||
PO2,
|
||||
PO2_ALERT,
|
||||
PN2,
|
||||
PN2_ALERT,
|
||||
PHE,
|
||||
PHE_ALERT,
|
||||
PP_LINES,
|
||||
|
||||
/* Other colors */
|
||||
TEXT_BACKGROUND, ALERT_BG, ALERT_FG, EVENTS, SAMPLE_DEEP, SAMPLE_SHALLOW,
|
||||
SMOOTHED, MINUTE, TIME_GRID, TIME_TEXT, DEPTH_GRID, MEAN_DEPTH, HR_TEXT, HR_PLOT, DEPTH_TOP,
|
||||
DEPTH_BOTTOM, TEMP_TEXT, TEMP_PLOT, SAC_DEFAULT, BOUNDING_BOX, PRESSURE_TEXT, BACKGROUND,
|
||||
CEILING_SHALLOW, CEILING_DEEP, CALC_CEILING_SHALLOW, CALC_CEILING_DEEP
|
||||
TEXT_BACKGROUND,
|
||||
ALERT_BG,
|
||||
ALERT_FG,
|
||||
EVENTS,
|
||||
SAMPLE_DEEP,
|
||||
SAMPLE_SHALLOW,
|
||||
SMOOTHED,
|
||||
MINUTE,
|
||||
TIME_GRID,
|
||||
TIME_TEXT,
|
||||
DEPTH_GRID,
|
||||
MEAN_DEPTH,
|
||||
HR_TEXT,
|
||||
HR_PLOT,
|
||||
DEPTH_TOP,
|
||||
DEPTH_BOTTOM,
|
||||
TEMP_TEXT,
|
||||
TEMP_PLOT,
|
||||
SAC_DEFAULT,
|
||||
BOUNDING_BOX,
|
||||
PRESSURE_TEXT,
|
||||
BACKGROUND,
|
||||
CEILING_SHALLOW,
|
||||
CEILING_DEEP,
|
||||
CALC_CEILING_SHALLOW,
|
||||
CALC_CEILING_DEEP
|
||||
} color_indice_t;
|
||||
|
||||
|
||||
|
||||
/* profile_color[color indice] = COLOR(screen color, b/w printer color, color printer}} printer & screen colours could be different */
|
||||
|
||||
extern QMap<color_indice_t, QVector<QColor> > profile_color;
|
||||
|
|
|
@ -54,8 +54,7 @@ struct GroupedLineEdit::Private {
|
|||
QVector<QColor> colors;
|
||||
};
|
||||
|
||||
GroupedLineEdit::GroupedLineEdit(QWidget* parent)
|
||||
: QPlainTextEdit(parent),
|
||||
GroupedLineEdit::GroupedLineEdit(QWidget *parent) : QPlainTextEdit(parent),
|
||||
d(new Private)
|
||||
{
|
||||
setWordWrapMode(QTextOption::NoWrap);
|
||||
|
@ -153,8 +152,7 @@ QSize GroupedLineEdit::sizeHint() const
|
|||
40,
|
||||
document()->findBlock(0).layout()->lineAt(0).height() +
|
||||
document()->documentMargin() * 2 +
|
||||
frameWidth() * 2
|
||||
);
|
||||
frameWidth() * 2);
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
@ -199,8 +197,7 @@ void GroupedLineEdit::paintEvent(QPaintEvent *e)
|
|||
start_x - 1.0 - double(horizontalScrollBar()->value()),
|
||||
1.0,
|
||||
end_x - start_x + 2.0,
|
||||
double(viewport()->height() - 2)
|
||||
);
|
||||
double(viewport()->height() - 2));
|
||||
if (!i.hasNext())
|
||||
i.toFront();
|
||||
path.addRoundedRect(rectangle, 5.0, 5.0);
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
#include <QPlainTextEdit>
|
||||
#include <QStringList>
|
||||
|
||||
class GroupedLineEdit : public QPlainTextEdit
|
||||
{
|
||||
class GroupedLineEdit : public QPlainTextEdit {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -65,6 +64,7 @@ signals:
|
|||
protected:
|
||||
virtual void paintEvent(QPaintEvent *e);
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
Private *d;
|
||||
|
|
|
@ -174,16 +174,12 @@ int KMessageWidgetPrivate::bestContentHeight() const
|
|||
//---------------------------------------------------------------------
|
||||
// KMessageWidget
|
||||
//---------------------------------------------------------------------
|
||||
KMessageWidget::KMessageWidget(QWidget* parent)
|
||||
: QFrame(parent)
|
||||
, d(new KMessageWidgetPrivate)
|
||||
KMessageWidget::KMessageWidget(QWidget *parent) : QFrame(parent), d(new KMessageWidgetPrivate)
|
||||
{
|
||||
d->init(this);
|
||||
}
|
||||
|
||||
KMessageWidget::KMessageWidget(const QString& text, QWidget* parent)
|
||||
: QFrame(parent)
|
||||
, d(new KMessageWidgetPrivate)
|
||||
KMessageWidget::KMessageWidget(const QString &text, QWidget *parent) : QFrame(parent), d(new KMessageWidgetPrivate)
|
||||
{
|
||||
d->init(this);
|
||||
setText(text);
|
||||
|
@ -251,8 +247,7 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type)
|
|||
"border: 1px solid %4;"
|
||||
"margin: %5px;"
|
||||
"}"
|
||||
".QLabel { color: %6; }"
|
||||
).arg(bg0.name())
|
||||
".QLabel { color: %6; }").arg(bg0.name())
|
||||
.arg(bg1.name())
|
||||
.arg(bg2.name())
|
||||
.arg(border.name())
|
||||
|
@ -261,10 +256,8 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type)
|
|||
We know our border is 1px, so we subtract this from the frame
|
||||
normal QStyle FrameWidth to get our margin
|
||||
*/
|
||||
|
||||
.arg(style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this) - 1)
|
||||
.arg(fg.name())
|
||||
);
|
||||
.arg(fg.name()));
|
||||
}
|
||||
|
||||
QSize KMessageWidget::sizeHint() const
|
||||
|
@ -419,4 +412,3 @@ void KMessageWidget::setIcon(const QIcon& icon)
|
|||
d->iconLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,7 @@ class KMessageWidgetPrivate;
|
|||
* @author Aurélien Gâteau <agateau@kde.org>
|
||||
* @since 4.7
|
||||
*/
|
||||
class KMessageWidget : public QFrame
|
||||
{
|
||||
class KMessageWidget : public QFrame {
|
||||
Q_OBJECT
|
||||
Q_ENUMS(MessageType)
|
||||
|
||||
|
@ -138,7 +137,8 @@ public:
|
|||
*/
|
||||
QIcon icon() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public
|
||||
Q_SLOTS:
|
||||
void setText(const QString &text);
|
||||
|
||||
void setWordWrap(bool wordWrap);
|
||||
|
@ -209,8 +209,7 @@ class QToolButton;
|
|||
class QTimeLine;
|
||||
#include <QIcon>
|
||||
|
||||
class KMessageWidgetPrivate
|
||||
{
|
||||
class KMessageWidgetPrivate {
|
||||
public:
|
||||
void init(KMessageWidget *);
|
||||
|
||||
|
|
|
@ -137,7 +137,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
Q_FOREACH(QGroupBox * box, findChildren<QGroupBox *>()) {
|
||||
box->setStyleSheet(gnomeCss);
|
||||
}
|
||||
|
||||
}
|
||||
ui.cylinders->view()->horizontalHeader()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
|
@ -178,8 +177,7 @@ void MainTab::toggleTriggeredColumn()
|
|||
view->showColumn(col);
|
||||
if (view->columnWidth(col) <= 15)
|
||||
view->setColumnWidth(col, 80);
|
||||
}
|
||||
else
|
||||
} else
|
||||
view->hideColumn(col);
|
||||
}
|
||||
|
||||
|
@ -630,7 +628,6 @@ void MainTab::acceptChanges()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (current_dive->divetrip) {
|
||||
current_dive->divetrip->when = current_dive->when;
|
||||
|
@ -810,7 +807,8 @@ void MainTab::rejectChanges()
|
|||
}
|
||||
#undef EDIT_TEXT2
|
||||
|
||||
#define EDIT_SELECTED_DIVES( WHAT ) do { \
|
||||
#define EDIT_SELECTED_DIVES(WHAT) \
|
||||
do { \
|
||||
if (editMode == NONE) \
|
||||
return; \
|
||||
\
|
||||
|
@ -825,14 +823,12 @@ void MainTab::rejectChanges()
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
void markChangedWidget(QWidget *w) {
|
||||
void markChangedWidget(QWidget *w)
|
||||
{
|
||||
QPalette p;
|
||||
qreal h, s, l, a;
|
||||
qApp->palette().color(QPalette::Text).getHslF(&h, &s, &l, &a);
|
||||
p.setBrush(QPalette::Base, ( l <= 0.3 ) ? QColor(Qt::yellow).lighter()
|
||||
:( l <= 0.6 ) ? QColor(Qt::yellow).light()
|
||||
:/* else */ QColor(Qt::yellow).darker(300)
|
||||
);
|
||||
p.setBrush(QPalette::Base, (l <= 0.3) ? QColor(Qt::yellow).lighter() : (l <= 0.6) ? QColor(Qt::yellow).light() : /* else */ QColor(Qt::yellow).darker(300));
|
||||
w->setPalette(p);
|
||||
}
|
||||
|
||||
|
@ -876,8 +872,7 @@ void MainTab::saveTags()
|
|||
QString tag;
|
||||
taglist_clear(mydive->tag_list);
|
||||
foreach(tag, ui.tagWidget->getBlockStringList())
|
||||
taglist_add_tag(mydive->tag_list, tag.toUtf8().data());
|
||||
);
|
||||
taglist_add_tag(mydive->tag_list, tag.toUtf8().data()););
|
||||
}
|
||||
|
||||
void MainTab::on_tagWidget_textChanged()
|
||||
|
|
|
@ -45,11 +45,16 @@ struct Completers{
|
|||
QCompleter *tags;
|
||||
};
|
||||
|
||||
class MainTab : public QTabWidget
|
||||
{
|
||||
class MainTab : public QTabWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum EditMode { NONE, DIVE, TRIP, ADD, MANUALLY_ADDED_DIVE };
|
||||
enum EditMode {
|
||||
NONE,
|
||||
DIVE,
|
||||
TRIP,
|
||||
ADD,
|
||||
MANUALLY_ADDED_DIVE
|
||||
};
|
||||
|
||||
MainTab(QWidget *parent);
|
||||
~MainTab();
|
||||
|
@ -61,7 +66,8 @@ public:
|
|||
void initialUiSetup();
|
||||
bool isEditing();
|
||||
void updateCoordinatesText(qreal lat, qreal lon);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void addCylinder_clicked();
|
||||
void addWeight_clicked();
|
||||
void updateDiveInfo(int dive = selected_dive);
|
||||
|
@ -88,6 +94,7 @@ public slots:
|
|||
void displayMessage(QString str);
|
||||
void enableEdition(EditMode newEditMode = NONE);
|
||||
void toggleTriggeredColumn();
|
||||
|
||||
private:
|
||||
Ui::MainTab ui;
|
||||
WeightModel *weightModel;
|
||||
|
|
|
@ -29,16 +29,33 @@ class MainTab;
|
|||
class ProfileGraphicsView;
|
||||
class QWebView;
|
||||
|
||||
enum MainWindowTitleFormat { MWTF_DEFAULT, MWTF_FILENAME };
|
||||
enum MainWindowTitleFormat {
|
||||
MWTF_DEFAULT,
|
||||
MWTF_FILENAME
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {COLLAPSED, EXPANDED};
|
||||
enum StackWidgetIndexes{ PROFILE, PLANNERPROFILE};
|
||||
enum InfoWidgetIndexes{ MAINTAB, PLANNERWIDGET};
|
||||
enum CurrentState{ VIEWALL, GLOBE_MAXIMIZED, INFO_MAXIMIZED, PROFILE_MAXIMIZED, LIST_MAXIMIZED};
|
||||
enum {
|
||||
COLLAPSED,
|
||||
EXPANDED
|
||||
};
|
||||
enum StackWidgetIndexes {
|
||||
PROFILE,
|
||||
PLANNERPROFILE
|
||||
};
|
||||
enum InfoWidgetIndexes {
|
||||
MAINTAB,
|
||||
PLANNERWIDGET
|
||||
};
|
||||
enum CurrentState {
|
||||
VIEWALL,
|
||||
GLOBE_MAXIMIZED,
|
||||
INFO_MAXIMIZED,
|
||||
PROFILE_MAXIMIZED,
|
||||
LIST_MAXIMIZED
|
||||
};
|
||||
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
|
@ -60,7 +77,8 @@ public:
|
|||
void importFiles(const QStringList importFiles);
|
||||
void cleanUpEmpty();
|
||||
QTabWidget *tabWidget();
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
/* file menu action */
|
||||
void recentFileTriggered(bool checked);
|
||||
void on_actionNew_triggered();
|
||||
|
@ -127,7 +145,8 @@ private slots:
|
|||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void readSettings();
|
||||
void refreshDisplay(bool recreateDiveList = true);
|
||||
void showProfile();
|
||||
|
|
|
@ -28,11 +28,9 @@ QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem& option, const QMode
|
|||
#define IDX(_XX) mymodel->index(currCombo.currRow, (_XX))
|
||||
static bool keyboardFinished = false;
|
||||
|
||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
|
||||
QStyledItemDelegate(parent),
|
||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent),
|
||||
parentWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
|
@ -129,7 +127,8 @@ void ComboBoxDelegate::testActivation(const QString& currText)
|
|||
}
|
||||
|
||||
// HACK, send a fake event so Qt thinks we hit 'enter' on the line edit.
|
||||
void ComboBoxDelegate::fakeActivation() {
|
||||
void ComboBoxDelegate::fakeActivation()
|
||||
{
|
||||
/* this test is needed because as soon as I show the selector,
|
||||
* the first item gots selected, this sending an activated signal,
|
||||
* calling this fakeActivation code and setting as the current,
|
||||
|
@ -324,8 +323,7 @@ AirTypesDelegate::AirTypesDelegate(QObject* parent) : ComboBoxDelegate(GasSelect
|
|||
{
|
||||
}
|
||||
|
||||
ProfilePrintDelegate::ProfilePrintDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
ProfilePrintDelegate::ProfilePrintDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ class QPainter;
|
|||
|
||||
class DiveListDelegate : public QStyledItemDelegate {
|
||||
public:
|
||||
explicit DiveListDelegate(QObject *parent = 0): QStyledItemDelegate(parent){}
|
||||
explicit DiveListDelegate(QObject *parent = 0)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
|
@ -17,6 +20,7 @@ public:
|
|||
explicit StarWidgetsDelegate(QWidget *parent = 0);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
private:
|
||||
QWidget *parentWidget;
|
||||
};
|
||||
|
@ -29,12 +33,14 @@ public:
|
|||
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
virtual bool eventFilter(QObject *object, QEvent *event);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void testActivation(const QString &currString = QString());
|
||||
//HACK: try to get rid of this in the future.
|
||||
void fakeActivation();
|
||||
void fixTabBehavior();
|
||||
virtual void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
||||
|
||||
protected:
|
||||
QAbstractItemModel *model;
|
||||
};
|
||||
|
@ -45,7 +51,8 @@ public:
|
|||
explicit TankInfoDelegate(QObject *parent = 0);
|
||||
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
|
@ -55,7 +62,8 @@ public:
|
|||
explicit WSInfoDelegate(QObject *parent = 0);
|
||||
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
|
@ -64,7 +72,8 @@ class AirTypesDelegate : public ComboBoxDelegate{
|
|||
public:
|
||||
explicit AirTypesDelegate(QObject *parent = 0);
|
||||
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
|
@ -72,8 +81,7 @@ public slots:
|
|||
* this delegate is used to modify the look of the table that is printed
|
||||
* bellow profiles.
|
||||
*/
|
||||
class ProfilePrintDelegate : public QStyledItemDelegate
|
||||
{
|
||||
class ProfilePrintDelegate : public QStyledItemDelegate {
|
||||
public:
|
||||
explicit ProfilePrintDelegate(QObject *parent = 0);
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
|
374
qt-ui/models.cpp
374
qt-ui/models.cpp
|
@ -66,8 +66,7 @@ void CleanerTableModel::setHeaderDataStrings(const QStringList& newHeaders)
|
|||
CylindersModel::CylindersModel(QObject *parent) : current(0), rows(0)
|
||||
{
|
||||
// enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
|
||||
setHeaderDataStrings( QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") <<
|
||||
tr("StartPress") << tr("EndPress") << trUtf8("O" UTF8_SUBSCRIPT_2 "%") << tr("He%")
|
||||
setHeaderDataStrings(QStringList() << "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") << trUtf8("O" UTF8_SUBSCRIPT_2 "%") << tr("He%")
|
||||
// while the planner is disabled, we don't need this column: << tr("Switch at")
|
||||
);
|
||||
}
|
||||
|
@ -99,8 +98,12 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
|||
case Qt::FontRole: {
|
||||
QFont font = defaultModelFont();
|
||||
switch (index.column()) {
|
||||
case START: font.setItalic(!cyl->start.mbar); break;
|
||||
case END: font.setItalic(!cyl->end.mbar); break;
|
||||
case START:
|
||||
font.setItalic(!cyl->start.mbar);
|
||||
break;
|
||||
case END:
|
||||
font.setItalic(!cyl->end.mbar);
|
||||
break;
|
||||
}
|
||||
ret = font;
|
||||
break;
|
||||
|
@ -740,7 +743,8 @@ void WSInfoModel::update()
|
|||
rows = -1;
|
||||
}
|
||||
struct ws_info_t *info = ws_info;
|
||||
for (info = ws_info; info->name; info++, rows++);
|
||||
for (info = ws_info; info->name; info++, rows++)
|
||||
;
|
||||
|
||||
if (rows > -1) {
|
||||
beginInsertRows(QModelIndex(), 0, rows);
|
||||
|
@ -850,7 +854,8 @@ void TankInfoModel::update()
|
|||
rows = -1;
|
||||
}
|
||||
struct tank_info_t *info = tank_info;
|
||||
for (info = tank_info; info->name; info++, rows++);
|
||||
for (info = tank_info; info->name; info++, rows++)
|
||||
;
|
||||
|
||||
if (rows > -1) {
|
||||
beginInsertRows(QModelIndex(), 0, rows);
|
||||
|
@ -1035,38 +1040,92 @@ QVariant DiveItem::data(int column, int role) const
|
|||
case DiveTripModel::SORT_ROLE:
|
||||
Q_ASSERT(dive != NULL);
|
||||
switch (column) {
|
||||
case NR: retVal = (qulonglong) dive->when; break;
|
||||
case DATE: retVal = (qulonglong) dive->when; break;
|
||||
case RATING: retVal = dive->rating; break;
|
||||
case DEPTH: retVal = dive->maxdepth.mm; break;
|
||||
case DURATION: retVal = dive->duration.seconds; break;
|
||||
case TEMPERATURE: retVal = dive->watertemp.mkelvin; break;
|
||||
case TOTALWEIGHT: retVal = total_weight(dive); break;
|
||||
case SUIT: retVal = QString(dive->suit); break;
|
||||
case CYLINDER: retVal = QString(dive->cylinder[0].type.description); break;
|
||||
case NITROX: retVal = nitrox_sort_value(dive); break;
|
||||
case SAC: retVal = dive->sac; break;
|
||||
case OTU: retVal = dive->otu; break;
|
||||
case MAXCNS: retVal = dive->maxcns; break;
|
||||
case LOCATION: retVal = QString(dive->location); break;
|
||||
case NR:
|
||||
retVal = (qulonglong)dive->when;
|
||||
break;
|
||||
case DATE:
|
||||
retVal = (qulonglong)dive->when;
|
||||
break;
|
||||
case RATING:
|
||||
retVal = dive->rating;
|
||||
break;
|
||||
case DEPTH:
|
||||
retVal = dive->maxdepth.mm;
|
||||
break;
|
||||
case DURATION:
|
||||
retVal = dive->duration.seconds;
|
||||
break;
|
||||
case TEMPERATURE:
|
||||
retVal = dive->watertemp.mkelvin;
|
||||
break;
|
||||
case TOTALWEIGHT:
|
||||
retVal = total_weight(dive);
|
||||
break;
|
||||
case SUIT:
|
||||
retVal = QString(dive->suit);
|
||||
break;
|
||||
case CYLINDER:
|
||||
retVal = QString(dive->cylinder[0].type.description);
|
||||
break;
|
||||
case NITROX:
|
||||
retVal = nitrox_sort_value(dive);
|
||||
break;
|
||||
case SAC:
|
||||
retVal = dive->sac;
|
||||
break;
|
||||
case OTU:
|
||||
retVal = dive->otu;
|
||||
break;
|
||||
case MAXCNS:
|
||||
retVal = dive->maxcns;
|
||||
break;
|
||||
case LOCATION:
|
||||
retVal = QString(dive->location);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Qt::DisplayRole:
|
||||
Q_ASSERT(dive != NULL);
|
||||
switch (column) {
|
||||
case NR: retVal = dive->number; break;
|
||||
case DATE: retVal = displayDate(); break;
|
||||
case DEPTH: retVal = displayDepth(); break;
|
||||
case DURATION: retVal = displayDuration(); break;
|
||||
case TEMPERATURE: retVal = displayTemperature(); break;
|
||||
case TOTALWEIGHT: retVal = displayWeight(); break;
|
||||
case SUIT: retVal = QString(dive->suit); break;
|
||||
case CYLINDER: retVal = QString(dive->cylinder[0].type.description); break;
|
||||
case NITROX: retVal = QString(get_nitrox_string(dive)); break;
|
||||
case SAC: retVal = displaySac(); break;
|
||||
case OTU: retVal = dive->otu; break;
|
||||
case MAXCNS: retVal = dive->maxcns; break;
|
||||
case LOCATION: retVal = QString(dive->location); break;
|
||||
case NR:
|
||||
retVal = dive->number;
|
||||
break;
|
||||
case DATE:
|
||||
retVal = displayDate();
|
||||
break;
|
||||
case DEPTH:
|
||||
retVal = displayDepth();
|
||||
break;
|
||||
case DURATION:
|
||||
retVal = displayDuration();
|
||||
break;
|
||||
case TEMPERATURE:
|
||||
retVal = displayTemperature();
|
||||
break;
|
||||
case TOTALWEIGHT:
|
||||
retVal = displayWeight();
|
||||
break;
|
||||
case SUIT:
|
||||
retVal = QString(dive->suit);
|
||||
break;
|
||||
case CYLINDER:
|
||||
retVal = QString(dive->cylinder[0].type.description);
|
||||
break;
|
||||
case NITROX:
|
||||
retVal = QString(get_nitrox_string(dive));
|
||||
break;
|
||||
case SAC:
|
||||
retVal = displaySac();
|
||||
break;
|
||||
case OTU:
|
||||
retVal = dive->otu;
|
||||
break;
|
||||
case MAXCNS:
|
||||
retVal = dive->maxcns;
|
||||
break;
|
||||
case LOCATION:
|
||||
retVal = QString(dive->location);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1221,24 +1280,54 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int
|
|||
|
||||
switch (role) {
|
||||
case Qt::FontRole:
|
||||
ret = defaultModelFont(); break;
|
||||
ret = defaultModelFont();
|
||||
break;
|
||||
case Qt::DisplayRole:
|
||||
switch (section) {
|
||||
case NR: ret = tr("#"); break;
|
||||
case DATE: ret = tr("date"); break;
|
||||
case RATING: ret = UTF8_BLACKSTAR; break;
|
||||
case DEPTH: ret = (get_units()->length == units::METERS) ? tr("m") : tr("ft"); break;
|
||||
case DURATION: ret = tr("min"); break;
|
||||
case TEMPERATURE:ret = QString("%1%2").arg(UTF8_DEGREE).arg((get_units()->temperature == units::CELSIUS) ? "C" : "F"); break;
|
||||
case TOTALWEIGHT:ret = (get_units()->weight == units::KG) ? tr("kg") : tr("lbs"); break;
|
||||
case SUIT: ret = tr("suit"); break;
|
||||
case CYLINDER: ret = tr("cyl"); break;
|
||||
case NITROX: ret = QString("O%1%").arg(UTF8_SUBSCRIPT_2); break;
|
||||
case SAC: ret = tr("SAC"); break;
|
||||
case OTU: ret = tr("OTU"); break;
|
||||
case MAXCNS: ret = tr("maxCNS"); break;
|
||||
case LOCATION: ret = tr("location"); break;
|
||||
}break;
|
||||
case NR:
|
||||
ret = tr("#");
|
||||
break;
|
||||
case DATE:
|
||||
ret = tr("date");
|
||||
break;
|
||||
case RATING:
|
||||
ret = UTF8_BLACKSTAR;
|
||||
break;
|
||||
case DEPTH:
|
||||
ret = (get_units()->length == units::METERS) ? tr("m") : tr("ft");
|
||||
break;
|
||||
case DURATION:
|
||||
ret = tr("min");
|
||||
break;
|
||||
case TEMPERATURE:
|
||||
ret = QString("%1%2").arg(UTF8_DEGREE).arg((get_units()->temperature == units::CELSIUS) ? "C" : "F");
|
||||
break;
|
||||
case TOTALWEIGHT:
|
||||
ret = (get_units()->weight == units::KG) ? tr("kg") : tr("lbs");
|
||||
break;
|
||||
case SUIT:
|
||||
ret = tr("suit");
|
||||
break;
|
||||
case CYLINDER:
|
||||
ret = tr("cyl");
|
||||
break;
|
||||
case NITROX:
|
||||
ret = QString("O%1%").arg(UTF8_SUBSCRIPT_2);
|
||||
break;
|
||||
case SAC:
|
||||
ret = tr("SAC");
|
||||
break;
|
||||
case OTU:
|
||||
ret = tr("OTU");
|
||||
break;
|
||||
case MAXCNS:
|
||||
ret = tr("maxCNS");
|
||||
break;
|
||||
case LOCATION:
|
||||
ret = tr("location");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1308,7 +1397,8 @@ bool DiveTripModel::setData(const QModelIndex& index, const QVariant& value, int
|
|||
DiveItem *diveItem = dynamic_cast<DiveItem *>(item);
|
||||
if (!diveItem)
|
||||
return false;
|
||||
return diveItem->setData(index, value, role);}
|
||||
return diveItem->setData(index, value, role);
|
||||
}
|
||||
|
||||
|
||||
/*####################################################################
|
||||
|
@ -1333,16 +1423,26 @@ QVariant DiveComputerModel::data(const QModelIndex& index, int role) const
|
|||
QVariant ret;
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||
switch (index.column()) {
|
||||
case ID: ret = QString("0x").append(QString::number(node.deviceId, 16)); break;
|
||||
case MODEL: ret = node.model; break;
|
||||
case NICKNAME: ret = node.nickName; break;
|
||||
case ID:
|
||||
ret = QString("0x").append(QString::number(node.deviceId, 16));
|
||||
break;
|
||||
case MODEL:
|
||||
ret = node.model;
|
||||
break;
|
||||
case NICKNAME:
|
||||
ret = node.nickName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index.column() == REMOVE) {
|
||||
switch (role) {
|
||||
case Qt::DecorationRole : ret = QIcon(":trash"); break;
|
||||
case Qt::ToolTipRole : ret = tr("Clicking here will remove this divecomputer."); break;
|
||||
case Qt::DecorationRole:
|
||||
ret = QIcon(":trash");
|
||||
break;
|
||||
case Qt::ToolTipRole:
|
||||
ret = tr("Clicking here will remove this divecomputer.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -1419,11 +1519,28 @@ void DiveComputerModel::keepWorkingList()
|
|||
|
||||
class YearStatisticsItem : public TreeItem {
|
||||
public:
|
||||
enum {YEAR, DIVES, TOTAL_TIME, AVERAGE_TIME, SHORTEST_TIME, LONGEST_TIME, AVG_DEPTH, MIN_DEPTH,
|
||||
MAX_DEPTH, AVG_SAC, MIN_SAC, MAX_SAC, AVG_TEMP, MIN_TEMP, MAX_TEMP, COLUMNS};
|
||||
enum {
|
||||
YEAR,
|
||||
DIVES,
|
||||
TOTAL_TIME,
|
||||
AVERAGE_TIME,
|
||||
SHORTEST_TIME,
|
||||
LONGEST_TIME,
|
||||
AVG_DEPTH,
|
||||
MIN_DEPTH,
|
||||
MAX_DEPTH,
|
||||
AVG_SAC,
|
||||
MIN_SAC,
|
||||
MAX_SAC,
|
||||
AVG_TEMP,
|
||||
MIN_TEMP,
|
||||
MAX_TEMP,
|
||||
COLUMNS
|
||||
};
|
||||
|
||||
QVariant data(int column, int role) const;
|
||||
YearStatisticsItem(stats_t interval);
|
||||
|
||||
private:
|
||||
stats_t stats_interval;
|
||||
};
|
||||
|
@ -1452,17 +1569,39 @@ QVariant YearStatisticsItem::data(int column, int role) const
|
|||
ret = stats_interval.period;
|
||||
}
|
||||
break;
|
||||
case DIVES: ret = stats_interval.selection_size; break;
|
||||
case TOTAL_TIME: ret = get_time_string(stats_interval.total_time.seconds, 0); break;
|
||||
case AVERAGE_TIME: ret = get_minutes(stats_interval.total_time.seconds / stats_interval.selection_size); break;
|
||||
case SHORTEST_TIME: ret = get_minutes(stats_interval.shortest_time.seconds); break;
|
||||
case LONGEST_TIME: ret = get_minutes(stats_interval.longest_time.seconds); break;
|
||||
case AVG_DEPTH: ret = get_depth_string(stats_interval.avg_depth); break;
|
||||
case MIN_DEPTH: ret = get_depth_string(stats_interval.min_depth); break;
|
||||
case MAX_DEPTH: ret = get_depth_string(stats_interval.max_depth); break;
|
||||
case AVG_SAC: ret = get_volume_string(stats_interval.avg_sac); break;
|
||||
case MIN_SAC: ret = get_volume_string(stats_interval.min_sac); break;
|
||||
case MAX_SAC: ret = get_volume_string(stats_interval.max_sac); break;
|
||||
case DIVES:
|
||||
ret = stats_interval.selection_size;
|
||||
break;
|
||||
case TOTAL_TIME:
|
||||
ret = get_time_string(stats_interval.total_time.seconds, 0);
|
||||
break;
|
||||
case AVERAGE_TIME:
|
||||
ret = get_minutes(stats_interval.total_time.seconds / stats_interval.selection_size);
|
||||
break;
|
||||
case SHORTEST_TIME:
|
||||
ret = get_minutes(stats_interval.shortest_time.seconds);
|
||||
break;
|
||||
case LONGEST_TIME:
|
||||
ret = get_minutes(stats_interval.longest_time.seconds);
|
||||
break;
|
||||
case AVG_DEPTH:
|
||||
ret = get_depth_string(stats_interval.avg_depth);
|
||||
break;
|
||||
case MIN_DEPTH:
|
||||
ret = get_depth_string(stats_interval.min_depth);
|
||||
break;
|
||||
case MAX_DEPTH:
|
||||
ret = get_depth_string(stats_interval.max_depth);
|
||||
break;
|
||||
case AVG_SAC:
|
||||
ret = get_volume_string(stats_interval.avg_sac);
|
||||
break;
|
||||
case MIN_SAC:
|
||||
ret = get_volume_string(stats_interval.min_sac);
|
||||
break;
|
||||
case MAX_SAC:
|
||||
ret = get_volume_string(stats_interval.max_sac);
|
||||
break;
|
||||
case AVG_TEMP:
|
||||
if (stats_interval.combined_temp && stats_interval.combined_count) {
|
||||
ret = QString::number(stats_interval.combined_temp / stats_interval.combined_count, 'f', 1);
|
||||
|
@ -1496,21 +1635,51 @@ QVariant YearlyStatisticsModel::headerData(int section, Qt::Orientation orientat
|
|||
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case YEAR: val = tr("Year \n > Month / Trip"); break;
|
||||
case DIVES: val = tr("#"); break;
|
||||
case TOTAL_TIME: val = tr("Duration \n Total"); break;
|
||||
case AVERAGE_TIME: val = tr("\nAverage"); break;
|
||||
case SHORTEST_TIME: val = tr("\nShortest"); break;
|
||||
case LONGEST_TIME: val = tr("\nLongest"); break;
|
||||
case AVG_DEPTH: val = QString(tr("Depth (%1)\n Average")).arg(get_depth_unit()); break;
|
||||
case MIN_DEPTH: val = tr("\nMinimum"); break;
|
||||
case MAX_DEPTH: val = tr("\nMaximum"); break;
|
||||
case AVG_SAC: val = QString(tr("SAC (%1)\n Average")).arg(get_volume_unit()); break;
|
||||
case MIN_SAC: val = tr("\nMinimum"); break;
|
||||
case MAX_SAC: val = tr("\nMaximum"); break;
|
||||
case AVG_TEMP: val = QString(tr("Temp. (%1)\n Average").arg(get_temp_unit())); break;
|
||||
case MIN_TEMP: val = tr("\nMinimum"); break;
|
||||
case MAX_TEMP: val = tr("\nMaximum"); break;
|
||||
case YEAR:
|
||||
val = tr("Year \n > Month / Trip");
|
||||
break;
|
||||
case DIVES:
|
||||
val = tr("#");
|
||||
break;
|
||||
case TOTAL_TIME:
|
||||
val = tr("Duration \n Total");
|
||||
break;
|
||||
case AVERAGE_TIME:
|
||||
val = tr("\nAverage");
|
||||
break;
|
||||
case SHORTEST_TIME:
|
||||
val = tr("\nShortest");
|
||||
break;
|
||||
case LONGEST_TIME:
|
||||
val = tr("\nLongest");
|
||||
break;
|
||||
case AVG_DEPTH:
|
||||
val = QString(tr("Depth (%1)\n Average")).arg(get_depth_unit());
|
||||
break;
|
||||
case MIN_DEPTH:
|
||||
val = tr("\nMinimum");
|
||||
break;
|
||||
case MAX_DEPTH:
|
||||
val = tr("\nMaximum");
|
||||
break;
|
||||
case AVG_SAC:
|
||||
val = QString(tr("SAC (%1)\n Average")).arg(get_volume_unit());
|
||||
break;
|
||||
case MIN_SAC:
|
||||
val = tr("\nMinimum");
|
||||
break;
|
||||
case MAX_SAC:
|
||||
val = tr("\nMaximum");
|
||||
break;
|
||||
case AVG_TEMP:
|
||||
val = QString(tr("Temp. (%1)\n Average").arg(get_temp_unit()));
|
||||
break;
|
||||
case MIN_TEMP:
|
||||
val = tr("\nMinimum");
|
||||
break;
|
||||
case MAX_TEMP:
|
||||
val = tr("\nMaximum");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
|
@ -1595,13 +1764,20 @@ QVariant TablePrintModel::data(const QModelIndex &index, int role) const
|
|||
return QColor(list.at(index.row())->colorBackground);
|
||||
if (role == Qt::DisplayRole)
|
||||
switch (index.column()) {
|
||||
case 0: return list.at(index.row())->number;
|
||||
case 1: return list.at(index.row())->date;
|
||||
case 2: return list.at(index.row())->depth;
|
||||
case 3: return list.at(index.row())->duration;
|
||||
case 4: return list.at(index.row())->divemaster;
|
||||
case 5: return list.at(index.row())->buddy;
|
||||
case 6: return list.at(index.row())->location;
|
||||
case 0:
|
||||
return list.at(index.row())->number;
|
||||
case 1:
|
||||
return list.at(index.row())->date;
|
||||
case 2:
|
||||
return list.at(index.row())->depth;
|
||||
case 3:
|
||||
return list.at(index.row())->duration;
|
||||
case 4:
|
||||
return list.at(index.row())->divemaster;
|
||||
case 5:
|
||||
return list.at(index.row())->buddy;
|
||||
case 6:
|
||||
return list.at(index.row())->location;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -1611,12 +1787,18 @@ bool TablePrintModel::setData(const QModelIndex &index, const QVariant &value, i
|
|||
if (index.isValid()) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case 0: list.at(index.row())->number = value.toString();
|
||||
case 1: list.at(index.row())->date = value.toString();
|
||||
case 2: list.at(index.row())->depth = value.toString();
|
||||
case 3: list.at(index.row())->duration = value.toString();
|
||||
case 4: list.at(index.row())->divemaster = value.toString();
|
||||
case 5: list.at(index.row())->buddy = value.toString();
|
||||
case 0:
|
||||
list.at(index.row())->number = value.toString();
|
||||
case 1:
|
||||
list.at(index.row())->date = value.toString();
|
||||
case 2:
|
||||
list.at(index.row())->depth = value.toString();
|
||||
case 3:
|
||||
list.at(index.row())->duration = value.toString();
|
||||
case 4:
|
||||
list.at(index.row())->divemaster = value.toString();
|
||||
case 5:
|
||||
list.at(index.row())->buddy = value.toString();
|
||||
case 6: {
|
||||
/* truncate if there are more than N lines of text,
|
||||
* we don't want a row to be larger that a single page! */
|
||||
|
|
143
qt-ui/models.h
143
qt-ui/models.h
|
@ -25,8 +25,10 @@ public:
|
|||
explicit CleanerTableModel(QObject *parent = 0);
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
protected:
|
||||
void setHeaderDataStrings(const QStringList &headers);
|
||||
|
||||
private:
|
||||
QStringList headers;
|
||||
};
|
||||
|
@ -38,7 +40,11 @@ Q_OBJECT
|
|||
public:
|
||||
static TankInfoModel *instance();
|
||||
|
||||
enum Column {DESCRIPTION, ML, BAR};
|
||||
enum Column {
|
||||
DESCRIPTION,
|
||||
ML,
|
||||
BAR
|
||||
};
|
||||
TankInfoModel();
|
||||
|
||||
/*reimp*/ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
@ -47,8 +53,10 @@ public:
|
|||
/*reimp*/ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
const QString &biggerString() const;
|
||||
void clear();
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void update();
|
||||
|
||||
private:
|
||||
int rows;
|
||||
QString biggerEntry;
|
||||
|
@ -60,7 +68,10 @@ Q_OBJECT
|
|||
public:
|
||||
static WSInfoModel *instance();
|
||||
|
||||
enum Column {DESCRIPTION, GR};
|
||||
enum Column {
|
||||
DESCRIPTION,
|
||||
GR
|
||||
};
|
||||
WSInfoModel();
|
||||
|
||||
/*reimp*/ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
@ -71,6 +82,7 @@ public:
|
|||
void clear();
|
||||
void update();
|
||||
void updateInfo();
|
||||
|
||||
private:
|
||||
int rows;
|
||||
QString biggerEntry;
|
||||
|
@ -81,7 +93,17 @@ private:
|
|||
class CylindersModel : public CleanerTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, /* DEPTH, */ COLUMNS};
|
||||
enum Column {
|
||||
REMOVE,
|
||||
TYPE,
|
||||
SIZE,
|
||||
WORKINGPRESS,
|
||||
START,
|
||||
END,
|
||||
O2,
|
||||
HE,
|
||||
/* DEPTH, */ COLUMNS
|
||||
};
|
||||
|
||||
explicit CylindersModel(QObject *parent = 0);
|
||||
static CylindersModel *instance();
|
||||
|
@ -98,7 +120,8 @@ public:
|
|||
cylinder_t *cylinderAt(const QModelIndex &index);
|
||||
bool changed;
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void remove(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
|
@ -111,7 +134,11 @@ private:
|
|||
class WeightModel : public CleanerTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column {REMOVE, TYPE, WEIGHT};
|
||||
enum Column {
|
||||
REMOVE,
|
||||
TYPE,
|
||||
WEIGHT
|
||||
};
|
||||
|
||||
explicit WeightModel(QObject *parent = 0);
|
||||
/*reimp*/ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
@ -127,7 +154,8 @@ public:
|
|||
weightsystem_t *weightSystemAt(const QModelIndex &index);
|
||||
bool changed;
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void remove(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
|
@ -141,6 +169,7 @@ private:
|
|||
|
||||
struct TreeItem {
|
||||
Q_DECLARE_TR_FUNCTIONS(TreeItemDT);
|
||||
|
||||
public:
|
||||
virtual ~TreeItem();
|
||||
TreeItem();
|
||||
|
@ -154,8 +183,23 @@ public:
|
|||
};
|
||||
|
||||
struct DiveItem : public TreeItem {
|
||||
enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT,
|
||||
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
||||
enum Column {
|
||||
NR,
|
||||
DATE,
|
||||
RATING,
|
||||
DEPTH,
|
||||
DURATION,
|
||||
TEMPERATURE,
|
||||
TOTALWEIGHT,
|
||||
SUIT,
|
||||
CYLINDER,
|
||||
NITROX,
|
||||
SAC,
|
||||
OTU,
|
||||
MAXCNS,
|
||||
LOCATION,
|
||||
COLUMNS
|
||||
};
|
||||
|
||||
virtual QVariant data(int column, int role) const;
|
||||
int diveId;
|
||||
|
@ -172,8 +216,7 @@ struct DiveItem : public TreeItem {
|
|||
|
||||
struct TripItem;
|
||||
|
||||
class TreeModel : public QAbstractItemModel
|
||||
{
|
||||
class TreeModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -193,11 +236,36 @@ protected:
|
|||
class DiveTripModel : public TreeModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT,
|
||||
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
||||
enum Column {
|
||||
NR,
|
||||
DATE,
|
||||
RATING,
|
||||
DEPTH,
|
||||
DURATION,
|
||||
TEMPERATURE,
|
||||
TOTALWEIGHT,
|
||||
SUIT,
|
||||
CYLINDER,
|
||||
NITROX,
|
||||
SAC,
|
||||
OTU,
|
||||
MAXCNS,
|
||||
LOCATION,
|
||||
COLUMNS
|
||||
};
|
||||
|
||||
enum ExtraRoles{STAR_ROLE = Qt::UserRole + 1, DIVE_ROLE, TRIP_ROLE, SORT_ROLE, DIVE_IDX};
|
||||
enum Layout{TREE, LIST, CURRENT};
|
||||
enum ExtraRoles {
|
||||
STAR_ROLE = Qt::UserRole + 1,
|
||||
DIVE_ROLE,
|
||||
TRIP_ROLE,
|
||||
SORT_ROLE,
|
||||
DIVE_IDX
|
||||
};
|
||||
enum Layout {
|
||||
TREE,
|
||||
LIST,
|
||||
CURRENT
|
||||
};
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
@ -205,17 +273,22 @@ public:
|
|||
DiveTripModel(QObject *parent = 0);
|
||||
Layout layout() const;
|
||||
void setLayout(Layout layout);
|
||||
|
||||
private:
|
||||
void setupModelData();
|
||||
QMap<dive_trip_t *, TripItem *> trips;
|
||||
Layout currentLayout;
|
||||
};
|
||||
|
||||
class DiveComputerModel : public CleanerTableModel
|
||||
{
|
||||
class DiveComputerModel : public CleanerTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {REMOVE, MODEL, ID, NICKNAME};
|
||||
enum {
|
||||
REMOVE,
|
||||
MODEL,
|
||||
ID,
|
||||
NICKNAME
|
||||
};
|
||||
DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject *parent = 0);
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
@ -225,8 +298,10 @@ public:
|
|||
void keepWorkingList();
|
||||
void dropWorkingList();
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void remove(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
int numRows;
|
||||
QMultiMap<QString, DiveComputerNode> dcWorkingMap;
|
||||
|
@ -235,8 +310,24 @@ private:
|
|||
class YearlyStatisticsModel : public TreeModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum { YEAR,DIVES,TOTAL_TIME,AVERAGE_TIME,SHORTEST_TIME,LONGEST_TIME,AVG_DEPTH,MIN_DEPTH,
|
||||
MAX_DEPTH,AVG_SAC,MIN_SAC,MAX_SAC,AVG_TEMP,MIN_TEMP,MAX_TEMP,COLUMNS};
|
||||
enum {
|
||||
YEAR,
|
||||
DIVES,
|
||||
TOTAL_TIME,
|
||||
AVERAGE_TIME,
|
||||
SHORTEST_TIME,
|
||||
LONGEST_TIME,
|
||||
AVG_DEPTH,
|
||||
MIN_DEPTH,
|
||||
MAX_DEPTH,
|
||||
AVG_SAC,
|
||||
MIN_SAC,
|
||||
MAX_SAC,
|
||||
AVG_TEMP,
|
||||
MIN_TEMP,
|
||||
MAX_TEMP,
|
||||
COLUMNS
|
||||
};
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
YearlyStatisticsModel(QObject *parent = 0);
|
||||
|
@ -262,8 +353,7 @@ struct TablePrintItem {
|
|||
unsigned int colorBackground;
|
||||
};
|
||||
|
||||
class TablePrintModel : public QAbstractTableModel
|
||||
{
|
||||
class TablePrintModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
@ -287,8 +377,7 @@ public:
|
|||
* this model is used when printing a data table under a profile. it requires
|
||||
* some exact usage of setSpan(..) on the target QTableView widget.
|
||||
*/
|
||||
class ProfilePrintModel : public QAbstractTableModel
|
||||
{
|
||||
class ProfilePrintModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
@ -309,7 +398,8 @@ public:
|
|||
static GasSelectionModel *instance();
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void repopulate();
|
||||
};
|
||||
|
||||
|
@ -320,6 +410,7 @@ public:
|
|||
static LanguageModel *instance();
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
private:
|
||||
LanguageModel(QObject *parent = 0);
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ public:
|
|||
void emitSettingsChanged();
|
||||
signals:
|
||||
void settingsChanged();
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
void on_chooseFile_clicked();
|
||||
void syncSettings();
|
||||
|
|
|
@ -23,7 +23,8 @@ private:
|
|||
QProgressBar *progressBar;
|
||||
QPrinter printer;
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void previewClicked();
|
||||
void printClicked();
|
||||
void onPaintRequested(QPrinter *);
|
||||
|
|
|
@ -269,8 +269,7 @@ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int
|
|||
table->setShowGrid(false);
|
||||
table->setStyleSheet(
|
||||
"QTableView { border: none }"
|
||||
"QTableView::item { border: 0px; padding-left: 2px; padding-right: 2px; }"
|
||||
);
|
||||
"QTableView::item { border: 0px; padding-left: 2px; padding-right: 2px; }");
|
||||
// return
|
||||
return table;
|
||||
}
|
||||
|
@ -304,8 +303,7 @@ void PrintLayout::printTable()
|
|||
|
||||
// don't show border
|
||||
table.setStyleSheet(
|
||||
"QTableView { border: none }"
|
||||
);
|
||||
"QTableView { border: none }");
|
||||
|
||||
// create and fill a table model
|
||||
TablePrintModel model;
|
||||
|
|
|
@ -23,7 +23,8 @@ private:
|
|||
struct options *printOptions;
|
||||
bool hasSetupSlots;
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void sliderPHeightMoved(int value);
|
||||
void sliderOHeightMoved(int value);
|
||||
void sliderNHeightMoved(int value);
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#include <QPropertyAnimation>
|
||||
#include <QPointF>
|
||||
|
||||
namespace Animations {
|
||||
namespace Animations
|
||||
{
|
||||
|
||||
void hide(QObject *obj)
|
||||
{
|
||||
|
@ -34,5 +35,4 @@ void moveTo(QObject* obj, const QPointF& pos, int msecs)
|
|||
{
|
||||
moveTo(obj, pos.x(), pos.y(), msecs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
class QObject;
|
||||
|
||||
namespace Animations{
|
||||
namespace Animations
|
||||
{
|
||||
void hide(QObject *obj);
|
||||
void moveTo(QObject *obj, qreal x, qreal y, int msecs = 500);
|
||||
void moveTo(QObject *obj, const QPointF &pos, int msecs = 500);
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include <QStyleOption>
|
||||
#include <QSettings>
|
||||
|
||||
static QPen gridPen(){
|
||||
static QPen gridPen()
|
||||
{
|
||||
QPen pen;
|
||||
pen.setColor(getColor(TIME_GRID));
|
||||
pen.setWidth(2);
|
||||
|
@ -73,7 +74,6 @@ DiveCartesianAxis::DiveCartesianAxis() : QObject(),
|
|||
|
||||
DiveCartesianAxis::~DiveCartesianAxis()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setLineSize(qreal lineSize)
|
||||
|
@ -113,7 +113,9 @@ void DiveCartesianAxis::setLinesVisible(bool arg1)
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> void emptyList( QList<T*>& list, double steps){
|
||||
template <typename T>
|
||||
void emptyList(QList<T *> &list, double steps)
|
||||
{
|
||||
if (!list.isEmpty() && list.size() > steps) {
|
||||
while (list.size() > steps) {
|
||||
T *removedItem = list.takeLast();
|
||||
|
|
|
@ -16,7 +16,12 @@ class DiveCartesianAxis : public QObject, public QGraphicsLineItem{
|
|||
Q_PROPERTY(qreal x WRITE setX READ x)
|
||||
Q_PROPERTY(qreal y WRITE setY READ y)
|
||||
public:
|
||||
enum Orientation{TopToBottom, BottomToTop, LeftToRight, RightToLeft};
|
||||
enum Orientation {
|
||||
TopToBottom,
|
||||
BottomToTop,
|
||||
LeftToRight,
|
||||
RightToLeft
|
||||
};
|
||||
DiveCartesianAxis();
|
||||
virtual ~DiveCartesianAxis();
|
||||
void setMinimum(double minimum);
|
||||
|
@ -40,12 +45,14 @@ public:
|
|||
void setLinesVisible(bool arg1);
|
||||
void setLineSize(qreal lineSize);
|
||||
int unitSystem;
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
virtual void updateTicks();
|
||||
|
||||
signals:
|
||||
void sizeChanged();
|
||||
void maxChanged();
|
||||
|
||||
protected:
|
||||
virtual QString textForValue(double value);
|
||||
virtual QColor colorForValue(double value);
|
||||
|
@ -67,11 +74,14 @@ class DepthAxis : public DiveCartesianAxis {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DepthAxis();
|
||||
|
||||
protected:
|
||||
QString textForValue(double value);
|
||||
QColor colorForValue(double value);
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
bool showWithPPGraph;
|
||||
};
|
||||
|
@ -80,6 +90,7 @@ class TimeAxis : public DiveCartesianAxis {
|
|||
Q_OBJECT
|
||||
public:
|
||||
virtual void updateTicks();
|
||||
|
||||
protected:
|
||||
QString textForValue(double value);
|
||||
QColor colorForValue(double value);
|
||||
|
@ -96,8 +107,10 @@ class PartialGasPressureAxis : public DiveCartesianAxis{
|
|||
public:
|
||||
PartialGasPressureAxis();
|
||||
void setModel(DivePlotDataModel *model);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void preferencesChanged();
|
||||
|
||||
private:
|
||||
DivePlotDataModel *model;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
#include <QDebug>
|
||||
|
||||
DiveEventItem::DiveEventItem(QObject *parent) : DivePixmapItem(parent),
|
||||
vAxis(NULL), hAxis(NULL), dataModel(NULL), internalEvent(NULL)
|
||||
vAxis(NULL),
|
||||
hAxis(NULL),
|
||||
dataModel(NULL),
|
||||
internalEvent(NULL)
|
||||
{
|
||||
setFlag(ItemIgnoresTransformations);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ public:
|
|||
void setVerticalAxis(DiveCartesianAxis *axis);
|
||||
void setHorizontalAxis(DiveCartesianAxis *axis);
|
||||
void setModel(DivePlotDataModel *model);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void recalculatePos(bool instant = false);
|
||||
|
||||
private:
|
||||
void setupToolTipString();
|
||||
void setupPixmap();
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
DiveLineItem::DiveLineItem(QGraphicsItem *parent) : QGraphicsLineItem(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DiveLineItem::animatedHide()
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -26,21 +26,36 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
|
|||
plot_data item = pInfo.entry[index.row()];
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case DEPTH: return item.depth;
|
||||
case TIME: return item.sec;
|
||||
case PRESSURE: return item.pressure[0];
|
||||
case TEMPERATURE: return item.temperature;
|
||||
case COLOR: return item.velocity;
|
||||
case USERENTERED: return false;
|
||||
case CYLINDERINDEX: return item.cylinderindex;
|
||||
case SENSOR_PRESSURE: return item.pressure[0];
|
||||
case INTERPOLATED_PRESSURE: return item.pressure[1];
|
||||
case CEILING: return item.ceiling;
|
||||
case SAC: return item.sac;
|
||||
case PN2: return item.pn2;
|
||||
case PHE: return item.phe;
|
||||
case PO2: return item.po2;
|
||||
case HEARTBEAT: return item.heartbeat;
|
||||
case DEPTH:
|
||||
return item.depth;
|
||||
case TIME:
|
||||
return item.sec;
|
||||
case PRESSURE:
|
||||
return item.pressure[0];
|
||||
case TEMPERATURE:
|
||||
return item.temperature;
|
||||
case COLOR:
|
||||
return item.velocity;
|
||||
case USERENTERED:
|
||||
return false;
|
||||
case CYLINDERINDEX:
|
||||
return item.cylinderindex;
|
||||
case SENSOR_PRESSURE:
|
||||
return item.pressure[0];
|
||||
case INTERPOLATED_PRESSURE:
|
||||
return item.pressure[1];
|
||||
case CEILING:
|
||||
return item.ceiling;
|
||||
case SAC:
|
||||
return item.sac;
|
||||
case PN2:
|
||||
return item.pn2;
|
||||
case PHE:
|
||||
return item.phe;
|
||||
case PO2:
|
||||
return item.po2;
|
||||
case HEARTBEAT:
|
||||
return item.heartbeat;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +65,8 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
|
|||
|
||||
if (role == Qt::BackgroundRole) {
|
||||
switch (index.column()) {
|
||||
case COLOR: return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
|
||||
case COLOR:
|
||||
return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
|
@ -75,20 +91,34 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
|
|||
return QVariant();
|
||||
|
||||
switch (section) {
|
||||
case DEPTH: return tr("Depth");
|
||||
case TIME: return tr("Time");
|
||||
case PRESSURE: return tr("Pressure");
|
||||
case TEMPERATURE: return tr("Temperature");
|
||||
case COLOR: return tr("Color");
|
||||
case USERENTERED: return tr("User Entered");
|
||||
case CYLINDERINDEX: return tr("Cylinder Index");
|
||||
case SENSOR_PRESSURE: return tr("Pressure S");
|
||||
case INTERPOLATED_PRESSURE: return tr("Pressure I");
|
||||
case CEILING: return tr("Ceiling");
|
||||
case SAC: return tr("SAC");
|
||||
case PN2: return tr("PN2");
|
||||
case PHE: return tr("PHE");
|
||||
case PO2: return tr("PO2");
|
||||
case DEPTH:
|
||||
return tr("Depth");
|
||||
case TIME:
|
||||
return tr("Time");
|
||||
case PRESSURE:
|
||||
return tr("Pressure");
|
||||
case TEMPERATURE:
|
||||
return tr("Temperature");
|
||||
case COLOR:
|
||||
return tr("Color");
|
||||
case USERENTERED:
|
||||
return tr("User Entered");
|
||||
case CYLINDERINDEX:
|
||||
return tr("Cylinder Index");
|
||||
case SENSOR_PRESSURE:
|
||||
return tr("Pressure S");
|
||||
case INTERPOLATED_PRESSURE:
|
||||
return tr("Pressure I");
|
||||
case CEILING:
|
||||
return tr("Ceiling");
|
||||
case SAC:
|
||||
return tr("SAC");
|
||||
case PN2:
|
||||
return tr("PN2");
|
||||
case PHE:
|
||||
return tr("PHE");
|
||||
case PO2:
|
||||
return tr("PO2");
|
||||
}
|
||||
if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16) {
|
||||
return QString("Ceiling: %1").arg(section - TISSUE_1);
|
||||
|
|
|
@ -12,9 +12,40 @@ struct plot_info;
|
|||
class DivePlotDataModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE,
|
||||
SAC, CEILING, TISSUE_1,TISSUE_2,TISSUE_3,TISSUE_4,TISSUE_5,TISSUE_6,TISSUE_7,TISSUE_8,TISSUE_9,TISSUE_10,
|
||||
TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16, PN2,PHE,PO2, HEARTBEAT, COLUMNS};
|
||||
enum {
|
||||
DEPTH,
|
||||
TIME,
|
||||
PRESSURE,
|
||||
TEMPERATURE,
|
||||
USERENTERED,
|
||||
COLOR,
|
||||
CYLINDERINDEX,
|
||||
SENSOR_PRESSURE,
|
||||
INTERPOLATED_PRESSURE,
|
||||
SAC,
|
||||
CEILING,
|
||||
TISSUE_1,
|
||||
TISSUE_2,
|
||||
TISSUE_3,
|
||||
TISSUE_4,
|
||||
TISSUE_5,
|
||||
TISSUE_6,
|
||||
TISSUE_7,
|
||||
TISSUE_8,
|
||||
TISSUE_9,
|
||||
TISSUE_10,
|
||||
TISSUE_11,
|
||||
TISSUE_12,
|
||||
TISSUE_13,
|
||||
TISSUE_14,
|
||||
TISSUE_15,
|
||||
TISSUE_16,
|
||||
PN2,
|
||||
PHE,
|
||||
PO2,
|
||||
HEARTBEAT,
|
||||
COLUMNS
|
||||
};
|
||||
explicit DivePlotDataModel(QObject *parent = 0);
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
@ -30,6 +61,7 @@ public:
|
|||
double po2Max();
|
||||
void emitDataChanged();
|
||||
void calculateDecompression();
|
||||
|
||||
private:
|
||||
plot_info pInfo;
|
||||
int diveId;
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include <QGraphicsItem>
|
||||
#include <QSettings>
|
||||
|
||||
AbstractProfilePolygonItem::AbstractProfilePolygonItem(): QObject(), QGraphicsPolygonItem(),
|
||||
hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1)
|
||||
AbstractProfilePolygonItem::AbstractProfilePolygonItem() : QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1)
|
||||
{
|
||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged()));
|
||||
}
|
||||
|
@ -110,10 +109,10 @@ void AbstractProfilePolygonItem::modelDataChanged(const QModelIndex& topLeft, co
|
|||
|
||||
DiveProfileItem::DiveProfileItem() : show_reported_ceiling(0), reported_ceiling_in_red(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
if (polygon().isEmpty())
|
||||
return;
|
||||
|
|
|
@ -41,11 +41,15 @@ public:
|
|||
void setHorizontalDataColumn(int column);
|
||||
void setVerticalDataColumn(int column);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
||||
virtual void clear(){}
|
||||
public slots:
|
||||
virtual void clear()
|
||||
{
|
||||
}
|
||||
public
|
||||
slots:
|
||||
virtual void preferencesChanged();
|
||||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
virtual void modelDataRemoved(const QModelIndex &parent, int from, int to);
|
||||
|
||||
protected:
|
||||
/* when the model emits a 'datachanged' signal, this method below should be used to check if the
|
||||
* modified data affects this particular item ( for example, when setting the '3m increment'
|
||||
|
@ -73,6 +77,7 @@ public:
|
|||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
virtual void preferencesChanged();
|
||||
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
|
||||
|
||||
private:
|
||||
unsigned int show_reported_ceiling;
|
||||
unsigned int reported_ceiling_in_red;
|
||||
|
@ -84,6 +89,7 @@ public:
|
|||
DiveTemperatureItem();
|
||||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
private:
|
||||
void createTextItem(int seconds, int mkelvin);
|
||||
};
|
||||
|
@ -94,6 +100,7 @@ public:
|
|||
DiveHeartrateItem();
|
||||
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private:
|
||||
void createTextItem(int seconds, int hr);
|
||||
};
|
||||
|
@ -104,6 +111,7 @@ class DiveGasPressureItem : public AbstractProfilePolygonItem{
|
|||
public:
|
||||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
private:
|
||||
void plot_pressure_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> align);
|
||||
void plot_gas_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> align, int o2, int he);
|
||||
|
@ -118,6 +126,7 @@ public:
|
|||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
virtual void preferencesChanged();
|
||||
|
||||
private:
|
||||
bool is3mIncrement;
|
||||
DiveTextItem *gradientFactor;
|
||||
|
@ -146,8 +155,10 @@ public:
|
|||
void setMeanDepth(int value);
|
||||
void setLine(qreal x1, qreal y1, qreal x2, qreal y2);
|
||||
void setAxis(DiveCartesianAxis *a);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void axisLineChanged();
|
||||
|
||||
private:
|
||||
int meanDepth;
|
||||
DiveTextItem *leftText;
|
||||
|
@ -164,6 +175,7 @@ public:
|
|||
void setThreshouldSettingsKey(const QString &threshouldSettingsKey);
|
||||
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
|
||||
void setColors(const QColor &normalColor, const QColor &alertColor);
|
||||
|
||||
private:
|
||||
QPolygonF alertPoly;
|
||||
QString threshouldKey;
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
DiveRectItem::DiveRectItem(QObject *parent, QGraphicsItem *parentItem) : QObject(parent), QGraphicsRectItem(parentItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
void animatedHide();
|
||||
void animateMoveTo(qreal x, qreal y);
|
||||
const QString &text();
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
int internalAlignFlags;
|
||||
|
|
|
@ -188,7 +188,8 @@ void ToolTipItem::updateTitlePosition()
|
|||
}
|
||||
}
|
||||
|
||||
bool ToolTipItem::isExpanded() const {
|
||||
bool ToolTipItem::isExpanded() const
|
||||
{
|
||||
return status == EXPANDED;
|
||||
}
|
||||
|
||||
|
@ -212,8 +213,7 @@ void ToolTipItem::readPos()
|
|||
QSettings s;
|
||||
s.beginGroup("ProfileMap");
|
||||
QPointF value = scene()->views().at(0)->mapToScene(
|
||||
s.value("tooltip_position").toPoint()
|
||||
);
|
||||
s.value("tooltip_position").toPoint());
|
||||
if (!scene()->sceneRect().contains(value)) {
|
||||
value = QPointF(0, 0);
|
||||
}
|
||||
|
|
|
@ -17,15 +17,22 @@ struct graphics_context;
|
|||
/* To use a tooltip, simply ->setToolTip on the QGraphicsItem that you want
|
||||
* or, if it's a "global" tooltip, set it on the mouseMoveEvent of the ProfileGraphicsView.
|
||||
*/
|
||||
class ToolTipItem :public QObject, public QGraphicsPathItem
|
||||
{
|
||||
class ToolTipItem : public QObject, public QGraphicsPathItem {
|
||||
Q_OBJECT
|
||||
void updateTitlePosition();
|
||||
Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect)
|
||||
|
||||
public:
|
||||
enum Status{COLLAPSED, EXPANDED};
|
||||
enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32, SPACING=4};
|
||||
enum Status {
|
||||
COLLAPSED,
|
||||
EXPANDED
|
||||
};
|
||||
enum {
|
||||
ICON_SMALL = 16,
|
||||
ICON_MEDIUM = 24,
|
||||
ICON_BIG = 32,
|
||||
SPACING = 4
|
||||
};
|
||||
|
||||
explicit ToolTipItem(QGraphicsItem *parent = 0);
|
||||
virtual ~ToolTipItem();
|
||||
|
@ -42,7 +49,8 @@ public:
|
|||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void setTimeAxis(DiveCartesianAxis *axis);
|
||||
void setPlotInfo(const plot_info &plot);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void setRect(const QRectF &rect);
|
||||
|
||||
private:
|
||||
|
|
|
@ -55,8 +55,7 @@ static struct _ItemPos{
|
|||
_Axis heartBeat;
|
||||
} itemPos;
|
||||
|
||||
ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
||||
QGraphicsView(parent),
|
||||
ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
||||
dataModel(new DivePlotDataModel(this)),
|
||||
currentState(INVALID),
|
||||
zoomLevel(0),
|
||||
|
|
|
@ -44,19 +44,36 @@ class AbstractProfilePolygonItem;
|
|||
class ProfileWidget2 : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
|
||||
enum Items{BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
|
||||
enum State {
|
||||
EMPTY,
|
||||
PROFILE,
|
||||
EDIT,
|
||||
ADD,
|
||||
PLAN,
|
||||
INVALID
|
||||
};
|
||||
enum Items {
|
||||
BACKGROUND,
|
||||
PROFILE_Y_AXIS,
|
||||
GAS_Y_AXIS,
|
||||
TIME_AXIS,
|
||||
DEPTH_CONTROLLER,
|
||||
TIME_CONTROLLER,
|
||||
COLUMNS
|
||||
};
|
||||
|
||||
ProfileWidget2(QWidget *parent);
|
||||
void plotDives(QList<dive *> dives);
|
||||
virtual bool eventFilter(QObject *, QEvent *);
|
||||
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
|
||||
|
||||
public slots: // Necessary to call from QAction's signals.
|
||||
public
|
||||
slots: // Necessary to call from QAction's signals.
|
||||
void settingsChanged();
|
||||
void setEmptyState();
|
||||
void setProfileState();
|
||||
void changeGas();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void wheelEvent(QWheelEvent *event);
|
||||
|
@ -70,6 +87,7 @@ private: /*methods*/
|
|||
void setupItemSizes();
|
||||
void addItemsToScene();
|
||||
void setupItemOnScene();
|
||||
|
||||
private:
|
||||
DivePlotDataModel *dataModel;
|
||||
State currentState;
|
||||
|
|
|
@ -61,8 +61,7 @@ QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &v
|
|||
return QGraphicsEllipseItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
RulerItem2::RulerItem2():
|
||||
timeAxis(NULL),
|
||||
RulerItem2::RulerItem2() : timeAxis(NULL),
|
||||
depthAxis(NULL),
|
||||
source(new RulerNodeItem2(pInfo)),
|
||||
dest(new RulerNodeItem2(pInfo)),
|
||||
|
@ -112,7 +111,6 @@ void RulerItem2::recalculate()
|
|||
textItem->resetTransform();
|
||||
textItem->setPos(startPoint);
|
||||
textItem->rotate(globalLine.angle() * -1);
|
||||
|
||||
}
|
||||
|
||||
RulerNodeItem2 *RulerItem2::sourceNode() const
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
struct plot_data;
|
||||
class RulerItem2;
|
||||
|
||||
class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem
|
||||
{
|
||||
class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem {
|
||||
Q_OBJECT
|
||||
friend class RulerItem2;
|
||||
|
||||
public:
|
||||
explicit RulerNodeItem2(struct plot_info &info);
|
||||
void setRuler(RulerItem2 *r);
|
||||
|
@ -30,8 +30,7 @@ private:
|
|||
DiveCartesianAxis *depthAxis;
|
||||
};
|
||||
|
||||
class RulerItem2 : public QGraphicsObject
|
||||
{
|
||||
class RulerItem2 : public QGraphicsObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RulerItem2();
|
||||
|
|
|
@ -43,12 +43,15 @@ extern struct ev_select *ev_namelist;
|
|||
extern int evn_allocated;
|
||||
extern int evn_used;
|
||||
|
||||
#define TOOLBAR_POS \
|
||||
QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \
|
||||
#define TOOLBAR_POS QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \
|
||||
viewport()->geometry().height() - toolBarProxy->boundingRect().height())
|
||||
|
||||
ProfileGraphicsView::ProfileGraphicsView(QWidget *parent) : QGraphicsView(parent),
|
||||
toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0)
|
||||
toolTip(0),
|
||||
diveId(0),
|
||||
diveDC(0),
|
||||
rulerItem(0),
|
||||
toolBarProxy(0)
|
||||
{
|
||||
printMode = false;
|
||||
isGrayscale = false;
|
||||
|
@ -239,9 +242,7 @@ void ProfileGraphicsView::removeEvent()
|
|||
|
||||
if (QMessageBox::question(MainWindow::instance(), TITLE_OR_TEXT(
|
||||
tr("Remove the selected event?"),
|
||||
tr("%1 @ %2:%3").arg(event->name)
|
||||
.arg(event->time.seconds / 60)
|
||||
.arg(event->time.seconds % 60, 2, 10, QChar('0'))),
|
||||
tr("%1 @ %2:%3").arg(event->name).arg(event->time.seconds / 60).arg(event->time.seconds % 60, 2, 10, QChar('0'))),
|
||||
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
|
||||
struct event **ep = ¤t_dc->events;
|
||||
while (ep && *ep != event)
|
||||
|
@ -451,8 +452,10 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
|
|||
|
||||
// NOT PORTED.
|
||||
/* Put the dive computer name in the lower left corner */
|
||||
gc.leftx = 0; gc.rightx = 1.0;
|
||||
gc.topy = 0; gc.bottomy = 1.0;
|
||||
gc.leftx = 0;
|
||||
gc.rightx = 1.0;
|
||||
gc.topy = 0;
|
||||
gc.bottomy = 1.0;
|
||||
|
||||
text_render_options_t computer = { DC_TEXT_SIZE, TIME_TEXT, LEFT, TOP };
|
||||
diveComputer = plot_text(&computer, QPointF(gc.leftx, gc.bottomy), nick);
|
||||
|
@ -508,7 +511,8 @@ void ProfileGraphicsView::plot_depth_scale()
|
|||
|
||||
/* Depth markers: every 30 ft or 10 m*/
|
||||
maxdepth = get_maxdepth(&gc.pi);
|
||||
gc.topy = 0; gc.bottomy = maxdepth;
|
||||
gc.topy = 0;
|
||||
gc.bottomy = maxdepth;
|
||||
marker = M_OR_FT(10, 30);
|
||||
|
||||
/* don't write depth labels all the way to the bottom as
|
||||
|
@ -777,7 +781,6 @@ void ProfileGraphicsView::plot_gas_value(int mbar, int sec, double xalign, doubl
|
|||
gas = QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10);
|
||||
static text_render_options_t tro = { PRESSURE_TEXT_SIZE, PRESSURE_TEXT, xalign, yalign };
|
||||
plot_text(&tro, QPointF(sec, mbar), gas);
|
||||
|
||||
}
|
||||
|
||||
void ProfileGraphicsView::plot_depth_text()
|
||||
|
@ -788,8 +791,10 @@ void ProfileGraphicsView::plot_depth_text()
|
|||
maxtime = get_maxtime(&gc.pi);
|
||||
maxdepth = get_maxdepth(&gc.pi);
|
||||
|
||||
gc.leftx = 0; gc.rightx = maxtime;
|
||||
gc.topy = 0; gc.bottomy = maxdepth;
|
||||
gc.leftx = 0;
|
||||
gc.rightx = maxtime;
|
||||
gc.topy = 0;
|
||||
gc.bottomy = maxdepth;
|
||||
|
||||
plot_text_samples();
|
||||
}
|
||||
|
@ -1135,8 +1140,10 @@ void ProfileGraphicsView::plot_depth_profile()
|
|||
while (maxtime / incr > 12)
|
||||
incr *= 2;
|
||||
|
||||
gc.leftx = 0; gc.rightx = maxtime;
|
||||
gc.topy = 0; gc.bottomy = 1.0;
|
||||
gc.leftx = 0;
|
||||
gc.rightx = maxtime;
|
||||
gc.topy = 0;
|
||||
gc.bottomy = 1.0;
|
||||
|
||||
last_gc = gc;
|
||||
|
||||
|
@ -1165,8 +1172,10 @@ void ProfileGraphicsView::plot_depth_profile()
|
|||
scene()->addItem(timeMarkers);
|
||||
|
||||
/* Depth markers: every 30 ft or 10 m*/
|
||||
gc.leftx = 0; gc.rightx = 1.0;
|
||||
gc.topy = 0; gc.bottomy = maxdepth;
|
||||
gc.leftx = 0;
|
||||
gc.rightx = 1.0;
|
||||
gc.topy = 0;
|
||||
gc.bottomy = maxdepth;
|
||||
marker = M_OR_FT(10, 30);
|
||||
maxline = qMax(gc.pi.maxdepth + marker, maxdepth * 2 / 3);
|
||||
|
||||
|
@ -1180,7 +1189,8 @@ void ProfileGraphicsView::plot_depth_profile()
|
|||
scene()->addItem(item);
|
||||
}
|
||||
|
||||
gc.leftx = 0; gc.rightx = maxtime;
|
||||
gc.leftx = 0;
|
||||
gc.rightx = maxtime;
|
||||
c = getColor(MEAN_DEPTH);
|
||||
|
||||
/* Show mean depth */
|
||||
|
@ -1211,7 +1221,8 @@ void ProfileGraphicsView::plot_depth_profile()
|
|||
#endif
|
||||
|
||||
/* Do the depth profile for the neat fill */
|
||||
gc.topy = 0; gc.bottomy = maxdepth;
|
||||
gc.topy = 0;
|
||||
gc.bottomy = maxdepth;
|
||||
|
||||
entry = gc.pi.entry;
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ struct plot_info;
|
|||
class RulerItem;
|
||||
class ToolTipItem;
|
||||
|
||||
class RulerNodeItem : public QObject, public QGraphicsEllipseItem
|
||||
{
|
||||
class RulerNodeItem : public QObject, public QGraphicsEllipseItem {
|
||||
Q_OBJECT
|
||||
friend class RulerItem;
|
||||
|
||||
public:
|
||||
explicit RulerNodeItem(QGraphicsItem *parent, graphics_context gc);
|
||||
void setRuler(RulerItem *r);
|
||||
|
@ -33,8 +33,7 @@ private:
|
|||
RulerItem *ruler;
|
||||
};
|
||||
|
||||
class RulerItem : public QGraphicsObject
|
||||
{
|
||||
class RulerItem : public QGraphicsObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RulerItem(QGraphicsItem *parent,
|
||||
|
@ -56,8 +55,7 @@ private:
|
|||
int paint_direction;
|
||||
};
|
||||
|
||||
class EventItem : public QGraphicsPixmapItem
|
||||
{
|
||||
class EventItem : public QGraphicsPixmapItem {
|
||||
public:
|
||||
explicit EventItem(struct event *ev, QGraphicsItem *parent = 0, bool grayscale = false);
|
||||
struct event *ev;
|
||||
|
@ -83,11 +81,13 @@ signals:
|
|||
void editingFinished(const QString &text);
|
||||
};
|
||||
|
||||
class ProfileGraphicsView : public QGraphicsView
|
||||
{
|
||||
class ProfileGraphicsView : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Mode{DIVE, PLAN};
|
||||
enum Mode {
|
||||
DIVE,
|
||||
PLAN
|
||||
};
|
||||
|
||||
ProfileGraphicsView(QWidget *parent = 0);
|
||||
void plot(struct dive *d, bool forceRedraw = false);
|
||||
|
@ -102,7 +102,8 @@ protected:
|
|||
void showEvent(QShowEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void refresh();
|
||||
void edit_dive_time(const QString &time);
|
||||
void on_rulerAction();
|
||||
|
@ -112,6 +113,7 @@ public slots:
|
|||
void unhideEvents();
|
||||
void removeEvent();
|
||||
void addBookmark();
|
||||
|
||||
private:
|
||||
void plot_depth_profile();
|
||||
QGraphicsItemGroup *plot_text(text_render_options_t *tro, const QPointF &pos, const QString &text, QGraphicsItem *parent = 0);
|
||||
|
|
|
@ -25,7 +25,8 @@ public:
|
|||
QLabel *minIco, *minValue;
|
||||
QLabel *maxIco, *maxValue;
|
||||
|
||||
MinMaxAvgWidgetPrivate(MinMaxAvgWidget *owner) {
|
||||
MinMaxAvgWidgetPrivate(MinMaxAvgWidget *owner)
|
||||
{
|
||||
avgIco = new QLabel(owner);
|
||||
avgIco->setPixmap(QIcon(":/average").pixmap(16, 16));
|
||||
avgIco->setToolTip(QObject::tr("Average"));
|
||||
|
@ -66,7 +67,6 @@ double MinMaxAvgWidget::minimum() const
|
|||
|
||||
MinMaxAvgWidget::MinMaxAvgWidget(QWidget *parent) : d(new MinMaxAvgWidgetPrivate(this))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MinMaxAvgWidget::~MinMaxAvgWidget()
|
||||
|
@ -167,7 +167,6 @@ void ShiftImageTimesDialog::buttonClicked(QAbstractButton* button)
|
|||
m_amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60;
|
||||
if (ui.backwards->isChecked())
|
||||
m_amount *= -1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
void setMaximum(const QString &maximum);
|
||||
void setAverage(const QString &average);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
QScopedPointer<MinMaxAvgWidgetPrivate> d;
|
||||
};
|
||||
|
@ -38,8 +39,10 @@ class RenumberDialog : public QDialog {
|
|||
Q_OBJECT
|
||||
public:
|
||||
static RenumberDialog *instance();
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
explicit RenumberDialog(QWidget *parent);
|
||||
Ui::RenumberDialog ui;
|
||||
|
@ -49,8 +52,10 @@ class ShiftTimesDialog : public QDialog {
|
|||
Q_OBJECT
|
||||
public:
|
||||
static ShiftTimesDialog *instance();
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
explicit ShiftTimesDialog(QWidget *parent);
|
||||
Ui::ShiftTimesDialog ui;
|
||||
|
@ -63,10 +68,12 @@ public:
|
|||
time_t amount() const;
|
||||
void setOffset(time_t offset);
|
||||
time_t epochFromExiv(EXIFInfo *exif);
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
void syncCameraClicked();
|
||||
void dcDateTimeChanged(const QDateTime &);
|
||||
|
||||
private:
|
||||
Ui::ShiftImageTimesDialog ui;
|
||||
time_t m_amount;
|
||||
|
|
|
@ -70,8 +70,7 @@ void StarWidget::setCurrentStars(int value)
|
|||
Q_EMIT valueChanged(current);
|
||||
}
|
||||
|
||||
StarWidget::StarWidget(QWidget* parent, Qt::WindowFlags f):
|
||||
QWidget(parent, f),
|
||||
StarWidget::StarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f),
|
||||
current(0),
|
||||
readOnly(false)
|
||||
{
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
enum StarConfig {SPACING = 2, IMG_SIZE = 16, TOTALSTARS = 5};
|
||||
enum StarConfig {
|
||||
SPACING = 2,
|
||||
IMG_SIZE = 16,
|
||||
TOTALSTARS = 5
|
||||
};
|
||||
|
||||
class StarWidget : public QWidget
|
||||
{
|
||||
class StarWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StarWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
|
@ -20,7 +23,8 @@ public:
|
|||
signals:
|
||||
void valueChanged(int stars);
|
||||
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void setCurrentStars(int value);
|
||||
void setReadOnly(bool readOnly);
|
||||
|
||||
|
@ -30,6 +34,7 @@ protected:
|
|||
/*reimp*/ void focusInEvent(QFocusEvent *);
|
||||
/*reimp*/ void focusOutEvent(QFocusEvent *);
|
||||
/*reimp*/ void keyPressEvent(QKeyEvent *);
|
||||
|
||||
private:
|
||||
int current;
|
||||
bool readOnly;
|
||||
|
|
|
@ -209,8 +209,7 @@ error_close_zip:
|
|||
return false;
|
||||
}
|
||||
|
||||
WebServices::WebServices(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f)
|
||||
, reply(0)
|
||||
WebServices::WebServices(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), reply(0)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
|
||||
|
@ -345,8 +344,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
|
|||
hide();
|
||||
close();
|
||||
resetState();
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case QDialogButtonBox::RejectRole:
|
||||
if (reply != NULL && reply->isOpen()) {
|
||||
reply->abort();
|
||||
|
@ -420,10 +418,18 @@ void SubsurfaceWebServices::setStatusText(int status)
|
|||
{
|
||||
QString text;
|
||||
switch (status) {
|
||||
case DD_STATUS_ERROR_CONNECT: text = tr("Connection Error: "); break;
|
||||
case DD_STATUS_ERROR_ID: text = tr("Invalid user identifier!"); break;
|
||||
case DD_STATUS_ERROR_PARSE: text = tr("Cannot parse response!"); break;
|
||||
case DD_STATUS_OK: text = tr("Download Success!"); break;
|
||||
case DD_STATUS_ERROR_CONNECT:
|
||||
text = tr("Connection Error: ");
|
||||
break;
|
||||
case DD_STATUS_ERROR_ID:
|
||||
text = tr("Invalid user identifier!");
|
||||
break;
|
||||
case DD_STATUS_ERROR_PARSE:
|
||||
text = tr("Cannot parse response!");
|
||||
break;
|
||||
case DD_STATUS_OK:
|
||||
text = tr("Download Success!");
|
||||
break;
|
||||
}
|
||||
ui.status->setText(text);
|
||||
}
|
||||
|
@ -470,8 +476,7 @@ end:
|
|||
// #
|
||||
// #
|
||||
|
||||
struct DiveListResult
|
||||
{
|
||||
struct DiveListResult {
|
||||
QString errorCondition;
|
||||
QString errorDetails;
|
||||
QByteArray idList; // comma-separated, suitable to be sent in the fetch request
|
||||
|
@ -551,7 +556,8 @@ out:
|
|||
// if there was an XML error, overwrite the result or other error conditions
|
||||
result.errorCondition = invalidXmlError;
|
||||
result.errorDetails = DivelogsDeWebServices::tr("Malformed XML response. Line %1: %2")
|
||||
.arg(reader.lineNumber()).arg(reader.errorString());
|
||||
.arg(reader.lineNumber())
|
||||
.arg(reader.errorString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -823,7 +829,6 @@ void DivelogsDeWebServices::uploadFinished()
|
|||
|
||||
void DivelogsDeWebServices::setStatusText(int status)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DivelogsDeWebServices::downloadError(QNetworkReply::NetworkError)
|
||||
|
@ -869,8 +874,7 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
|
|||
hide();
|
||||
close();
|
||||
resetState();
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case QDialogButtonBox::RejectRole:
|
||||
// these two seem to be causing a crash:
|
||||
// reply->deleteLater();
|
||||
|
|
|
@ -23,13 +23,15 @@ public:
|
|||
|
||||
static QNetworkAccessManager *manager();
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
virtual void startDownload() = 0;
|
||||
virtual void startUpload() = 0;
|
||||
virtual void buttonClicked(QAbstractButton *button) = 0;
|
||||
virtual void downloadTimedOut();
|
||||
|
||||
protected slots:
|
||||
protected
|
||||
slots:
|
||||
void updateProgress(qint64 current, qint64 total);
|
||||
|
||||
protected:
|
||||
|
@ -49,12 +51,15 @@ class SubsurfaceWebServices : public WebServices {
|
|||
public:
|
||||
explicit SubsurfaceWebServices(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void startDownload();
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
void downloadFinished();
|
||||
void downloadError(QNetworkReply::NetworkError error);
|
||||
void startUpload(){} /*no op*/
|
||||
void startUpload()
|
||||
{
|
||||
} /*no op*/
|
||||
private:
|
||||
void setStatusText(int status);
|
||||
void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status);
|
||||
|
@ -68,7 +73,8 @@ public:
|
|||
void downloadDives();
|
||||
void prepareDivesForUpload();
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void startDownload();
|
||||
void buttonClicked(QAbstractButton *button);
|
||||
void saveToZipFile();
|
||||
|
@ -78,6 +84,7 @@ private slots:
|
|||
void downloadError(QNetworkReply::NetworkError error);
|
||||
void uploadError(QNetworkReply::NetworkError error);
|
||||
void startUpload();
|
||||
|
||||
private:
|
||||
void uploadDives(QIODevice *dldContent);
|
||||
explicit DivelogsDeWebServices(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
void fixPlusPosition();
|
||||
void edit(const QModelIndex &index);
|
||||
QTableView *view();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *);
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
|
|
|
@ -38,7 +38,8 @@ void TagWidget::setCompleter(QCompleter *completer)
|
|||
connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionSelected(QString)));
|
||||
}
|
||||
|
||||
QPair<int,int> TagWidget::getCursorTagPosition() {
|
||||
QPair<int, int> TagWidget::getCursorTagPosition()
|
||||
{
|
||||
int i = 0, start = 0, end = 0;
|
||||
/* Parse string near cursor */
|
||||
i = cursorPosition();
|
||||
|
@ -65,9 +66,13 @@ QPair<int,int> TagWidget::getCursorTagPosition() {
|
|||
return qMakePair(start, end);
|
||||
}
|
||||
|
||||
enum ParseState {FINDSTART, FINDEND};
|
||||
enum ParseState {
|
||||
FINDSTART,
|
||||
FINDEND
|
||||
};
|
||||
|
||||
void TagWidget::highlight() {
|
||||
void TagWidget::highlight()
|
||||
{
|
||||
int i = 0, start = 0, end = 0;
|
||||
ParseState state = FINDEND;
|
||||
removeAllBlocks();
|
||||
|
@ -133,7 +138,8 @@ void TagWidget::reparse()
|
|||
}
|
||||
}
|
||||
|
||||
void TagWidget::completionSelected(QString completion) {
|
||||
void TagWidget::completionSelected(QString completion)
|
||||
{
|
||||
QPair<int, int> pos;
|
||||
pos = getCursorTagPosition();
|
||||
if (pos.first >= 0 && pos.second > 0) {
|
||||
|
@ -146,26 +152,30 @@ void TagWidget::completionSelected(QString completion) {
|
|||
emit(textChanged());
|
||||
}
|
||||
|
||||
void TagWidget::setCursorPosition(int position) {
|
||||
void TagWidget::setCursorPosition(int position)
|
||||
{
|
||||
blockSignals(true);
|
||||
GroupedLineEdit::setCursorPosition(position);
|
||||
blockSignals(false);
|
||||
}
|
||||
|
||||
void TagWidget::setText(QString text) {
|
||||
void TagWidget::setText(QString text)
|
||||
{
|
||||
blockSignals(true);
|
||||
GroupedLineEdit::setText(text);
|
||||
blockSignals(false);
|
||||
highlight();
|
||||
}
|
||||
|
||||
void TagWidget::clear() {
|
||||
void TagWidget::clear()
|
||||
{
|
||||
blockSignals(true);
|
||||
GroupedLineEdit::clear();
|
||||
blockSignals(false);
|
||||
}
|
||||
|
||||
void TagWidget::keyPressEvent(QKeyEvent *e) {
|
||||
void TagWidget::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch (e->key()) {
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
|
@ -188,7 +198,8 @@ void TagWidget::keyPressEvent(QKeyEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
void TagWidget::wheelEvent(QWheelEvent *event) {
|
||||
void TagWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (hasFocus()) {
|
||||
GroupedLineEdit::wheelEvent(event);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
#include <QCompleter>
|
||||
#include <QPair>
|
||||
|
||||
class TagWidget : public GroupedLineEdit
|
||||
{
|
||||
class TagWidget : public GroupedLineEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TagWidget(QWidget *parent = 0);
|
||||
|
@ -17,11 +16,14 @@ public:
|
|||
void clear();
|
||||
void setCursorPosition(int position);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
public slots:
|
||||
public
|
||||
slots:
|
||||
void reparse();
|
||||
void completionSelected(QString);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
|
||||
private:
|
||||
QCompleter *m_completer;
|
||||
};
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
|
||||
#include "../helpers.h"
|
||||
|
||||
UserManual::UserManual(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
UserManual::UserManual(QWidget *parent) : QMainWindow(parent),
|
||||
ui(new Ui::UserManual)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -63,7 +62,8 @@ void UserManual::search(QString text, QWebPage::FindFlags flags = 0)
|
|||
}
|
||||
}
|
||||
|
||||
void UserManual::searchTextChanged(QString text) {
|
||||
void UserManual::searchTextChanged(QString text)
|
||||
{
|
||||
bool hasText = text.length() > 0;
|
||||
|
||||
ui->findPrev->setEnabled(hasText);
|
||||
|
|
|
@ -4,19 +4,20 @@
|
|||
#include <QMainWindow>
|
||||
#include <QWebPage>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class UserManual;
|
||||
}
|
||||
|
||||
class UserManual : public QMainWindow
|
||||
{
|
||||
class UserManual : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UserManual(QWidget *parent = 0);
|
||||
~UserManual();
|
||||
|
||||
private slots:
|
||||
private
|
||||
slots:
|
||||
void showSearchPanel();
|
||||
void hideSearchPanel();
|
||||
void searchTextChanged(QString);
|
||||
|
|
41
qthelper.cpp
41
qthelper.cpp
|
@ -9,15 +9,14 @@
|
|||
#define tr(_arg) MainWindow::instance()->information()->tr(_arg)
|
||||
DiveComputerList::DiveComputerList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DiveComputerList::~DiveComputerList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DiveComputerNode::operator == (const DiveComputerNode &a) const {
|
||||
bool DiveComputerNode::operator==(const DiveComputerNode &a) const
|
||||
{
|
||||
return this->model == a.model &&
|
||||
this->deviceId == a.deviceId &&
|
||||
this->firmware == a.firmware &&
|
||||
|
@ -25,7 +24,8 @@ bool DiveComputerNode::operator == (const DiveComputerNode &a) const {
|
|||
this->nickName == a.nickName;
|
||||
}
|
||||
|
||||
bool DiveComputerNode::operator !=(const DiveComputerNode &a) const {
|
||||
bool DiveComputerNode::operator!=(const DiveComputerNode &a) const
|
||||
{
|
||||
return !(*this == a);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,12 @@ QString weight_string(int weight_in_grams)
|
|||
|
||||
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude)
|
||||
{
|
||||
enum { ISO6709D, SECONDS, MINUTES, DECIMAL } gpsStyle = ISO6709D;
|
||||
enum {
|
||||
ISO6709D,
|
||||
SECONDS,
|
||||
MINUTES,
|
||||
DECIMAL
|
||||
} gpsStyle = ISO6709D;
|
||||
int eastWest = 4;
|
||||
int northSouth = 1;
|
||||
QString regExp;
|
||||
|
@ -124,21 +129,39 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
|
|||
gpsStyle = ISO6709D;
|
||||
regExp = QString("(\\d+)[" UTF8_DEGREE "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([NS%1%2])"
|
||||
"\\s*(\\d+)[" UTF8_DEGREE "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([EW%3%4])")
|
||||
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W"));
|
||||
.arg(tr("N"))
|
||||
.arg(tr("S"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"));
|
||||
} else if (gps_text.count(QChar('"')) == 2) {
|
||||
gpsStyle = SECONDS;
|
||||
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?[^EW%3%4]*"
|
||||
"([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?")
|
||||
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
|
||||
.arg(tr("N"))
|
||||
.arg(tr("S"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"));
|
||||
} else if (gps_text.count(QChar('\'')) == 2) {
|
||||
gpsStyle = MINUTES;
|
||||
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?[^EW%3%4]*"
|
||||
"([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?")
|
||||
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
|
||||
.arg(tr("N"))
|
||||
.arg(tr("S"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"));
|
||||
} else {
|
||||
gpsStyle = DECIMAL;
|
||||
regExp = QString("\\s*([-NS%1%2]?)\\s*(\\d+)[,\\.](\\d+)[^-EW%3%4\\d]*([-EW%5%6]?)\\s*(\\d+)[,\\.](\\d+)")
|
||||
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
|
||||
.arg(tr("N"))
|
||||
.arg(tr("S"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"))
|
||||
.arg(tr("E"))
|
||||
.arg(tr("W"));
|
||||
}
|
||||
QRegExp r(regExp);
|
||||
if (r.indexIn(gps_text) != -1) {
|
||||
|
|
|
@ -13,7 +13,8 @@ extern QTranslator *qtTranslator, *ssrfTranslator;
|
|||
|
||||
class DiveComputerNode {
|
||||
public:
|
||||
DiveComputerNode(QString m, uint32_t d, QString s, QString f, QString n) : model(m), deviceId(d), serialNumber(s), firmware(f), nickName(n) {};
|
||||
DiveComputerNode(QString m, uint32_t d, QString s, QString f, QString n)
|
||||
: model(m), deviceId(d), serialNumber(s), firmware(f), nickName(n) {};
|
||||
bool operator==(const DiveComputerNode &a) const;
|
||||
bool operator!=(const DiveComputerNode &a) const;
|
||||
bool changesValues(const DiveComputerNode &b) const;
|
||||
|
|
26
sha1.c
26
sha1.c
|
@ -62,7 +62,11 @@
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#define setW(x, val) (*(volatile unsigned int *)&W(x) = (val))
|
||||
#elif defined(__GNUC__) && defined(__arm__)
|
||||
#define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0)
|
||||
#define setW(x, val) \
|
||||
do { \
|
||||
W(x) = (val); \
|
||||
__asm__("" :: : "memory"); \
|
||||
} while (0)
|
||||
#else
|
||||
#define setW(x, val) (W(x) = (val))
|
||||
#endif
|
||||
|
@ -81,7 +85,10 @@
|
|||
defined(__s390__) || defined(__s390x__)
|
||||
|
||||
#define get_be32(p) ntohl(*(unsigned int *)(p))
|
||||
#define put_be32(p, v) do { *(unsigned int *)(p) = htonl(v); } while (0)
|
||||
#define put_be32(p, v) \
|
||||
do { \
|
||||
*(unsigned int *)(p) = htonl(v); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
|
@ -90,12 +97,14 @@
|
|||
(*((unsigned char *)(p) + 1) << 16) | \
|
||||
(*((unsigned char *)(p) + 2) << 8) | \
|
||||
(*((unsigned char *)(p) + 3) << 0))
|
||||
#define put_be32(p, v) do { \
|
||||
#define put_be32(p, v) \
|
||||
do { \
|
||||
unsigned int __v = (v); \
|
||||
*((unsigned char *)(p) + 0) = __v >> 24; \
|
||||
*((unsigned char *)(p) + 1) = __v >> 16; \
|
||||
*((unsigned char *)(p) + 2) = __v >> 8; \
|
||||
*((unsigned char *)(p) + 3) = __v >> 0; } while (0)
|
||||
*((unsigned char *)(p) + 3) = __v >> 0; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -109,10 +118,13 @@
|
|||
#define SHA_SRC(t) get_be32((unsigned char *)block + (t) * 4)
|
||||
#define SHA_MIX(t) SHA_ROL(W((t) + 13) ^ W((t) + 8) ^ W((t) + 2) ^ W(t), 1);
|
||||
|
||||
#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \
|
||||
unsigned int TEMP = input(t); setW(t, TEMP); \
|
||||
#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) \
|
||||
do { \
|
||||
unsigned int TEMP = input(t); \
|
||||
setW(t, TEMP); \
|
||||
E += TEMP + SHA_ROL(A, 5) + (fn) + (constant); \
|
||||
B = SHA_ROR(B, 2); } while (0)
|
||||
B = SHA_ROR(B, 2); \
|
||||
} while (0)
|
||||
|
||||
#define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C ^ D) & B) ^ D), 0x5a827999, A, B, C, D, E)
|
||||
#define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C ^ D) & B) ^ D), 0x5a827999, A, B, C, D, E)
|
||||
|
|
3
sha1.h
3
sha1.h
|
@ -8,7 +8,8 @@
|
|||
#ifndef SHA1_H
|
||||
#define SHA1_H
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
unsigned long long size;
|
||||
unsigned int H[5];
|
||||
unsigned int W[16];
|
||||
|
|
|
@ -66,11 +66,13 @@ static void process_dive(struct dive *dp, stats_t *stats)
|
|||
if (!duration)
|
||||
return;
|
||||
stats->avg_depth.mm = (1.0 * old_tt * stats->avg_depth.mm +
|
||||
duration * dp->meandepth.mm) / stats->total_time.seconds;
|
||||
duration * dp->meandepth.mm) /
|
||||
stats->total_time.seconds;
|
||||
if (dp->sac > 2800) { /* less than .1 cuft/min (2800ml/min) is bogus */
|
||||
sac_time = stats->total_sac_time + duration;
|
||||
stats->avg_sac.mliter = (1.0 * stats->total_sac_time * stats->avg_sac.mliter +
|
||||
duration * dp->sac) / sac_time ;
|
||||
duration * dp->sac) /
|
||||
sac_time;
|
||||
if (dp->sac > stats->max_sac.mliter)
|
||||
stats->max_sac.mliter = dp->sac;
|
||||
if (stats->min_sac.mliter == 0 || dp->sac < stats->min_sac.mliter)
|
||||
|
@ -354,8 +356,7 @@ char *get_gaslist(struct dive *dive)
|
|||
}
|
||||
if (is_air(o2, he))
|
||||
strncpy(buf + offset, translate("gettextFromC", "air"), MAXBUF - offset);
|
||||
else
|
||||
if (he == 0)
|
||||
else if (he == 0)
|
||||
snprintf(buf + offset, MAXBUF - offset,
|
||||
translate("gettextFromC", "EAN%d"), (o2 + 5) / 10);
|
||||
else
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int period;
|
||||
duration_t total_time;
|
||||
/* avg_time is simply total_time / nr -- let's not keep this */
|
||||
|
|
|
@ -79,12 +79,14 @@ const char *monthname(int mon)
|
|||
*/
|
||||
bool imported = false;
|
||||
|
||||
static void print_version() {
|
||||
static void print_version()
|
||||
{
|
||||
printf("Subsurface v%s, ", VERSION_STRING);
|
||||
printf("built with libdivecomputer v%s\n", dc_version(NULL));
|
||||
}
|
||||
|
||||
static void print_help() {
|
||||
static void print_help()
|
||||
{
|
||||
print_version();
|
||||
printf("\nUsage: subsurface [options] [logfile ...] [--import logfile ...]");
|
||||
printf("\n\noptions include:");
|
||||
|
|
8
time.c
8
time.c
|
@ -29,8 +29,10 @@ void utc_mkdate(timestamp_t timestamp, struct tm *tm)
|
|||
val = timestamp /= 60;
|
||||
|
||||
/* Do the simple stuff */
|
||||
tm->tm_min = val % 60; val /= 60;
|
||||
tm->tm_hour = val % 24; val /= 24;
|
||||
tm->tm_min = val % 60;
|
||||
val /= 60;
|
||||
tm->tm_hour = val % 24;
|
||||
val /= 24;
|
||||
|
||||
/* Jan 1, 1970 was a Thursday (tm_wday=4) */
|
||||
tm->tm_wday = (val + 4) % 7;
|
||||
|
@ -94,5 +96,3 @@ timestamp_t utc_mktime(struct tm *tm)
|
|||
return (year * 365 + (year + 1) / 4 + mdays[month] + day) * 24 * 60 * 60UL +
|
||||
tm->tm_hour * 60 * 60 + tm->tm_min * 60 + tm->tm_sec;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ static void uemis_add_string(const char *buffer, char **text)
|
|||
static void uemis_get_weight(char *buffer, weightsystem_t *weight, int diveid)
|
||||
{
|
||||
weight->weight.grams = uemis_get_weight_unit(diveid) ?
|
||||
lbs_to_grams(ascii_strtod(buffer, NULL)) : ascii_strtod(buffer, NULL) * 1000;
|
||||
lbs_to_grams(ascii_strtod(buffer, NULL)) :
|
||||
ascii_strtod(buffer, NULL) * 1000;
|
||||
weight->description = strdup(translate("gettextFromC", "unknown"));
|
||||
}
|
||||
|
||||
|
@ -159,7 +160,6 @@ static int number_of_file(char *path)
|
|||
if (entry->d_type == DT_REG) /* If the entry is a regular file */
|
||||
#endif
|
||||
count++;
|
||||
|
||||
}
|
||||
#ifdef WIN32
|
||||
_wclosedir(dirp);
|
||||
|
@ -892,4 +892,3 @@ bail:
|
|||
free(deviceid);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
15
uemis.c
15
uemis.c
|
@ -31,7 +31,8 @@ static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$
|
|||
/*
|
||||
* decodeblock -- decode 4 '6-bit' characters into 3 8-bit binary bytes
|
||||
*/
|
||||
static void decodeblock (unsigned char in[4], unsigned char out[3]) {
|
||||
static void decodeblock(unsigned char in[4], unsigned char out[3])
|
||||
{
|
||||
out[0] = (unsigned char)(in[0] << 2 | in[1] >> 4);
|
||||
out[1] = (unsigned char)(in[1] << 4 | in[2] >> 2);
|
||||
out[2] = (unsigned char)(((in[2] << 6) & 0xc0) | in[3]);
|
||||
|
@ -40,7 +41,8 @@ static void decodeblock (unsigned char in[4], unsigned char out[3]) {
|
|||
/*
|
||||
* decode a base64 encoded stream discarding padding, line breaks and noise
|
||||
*/
|
||||
static void decode(uint8_t *inbuf, uint8_t *outbuf, int inbuf_len) {
|
||||
static void decode(uint8_t *inbuf, uint8_t *outbuf, int inbuf_len)
|
||||
{
|
||||
uint8_t in[4], out[3], v;
|
||||
int i, len, indx_in = 0, indx_out = 0;
|
||||
|
||||
|
@ -57,8 +59,7 @@ static void decode(uint8_t *inbuf, uint8_t *outbuf, int inbuf_len) {
|
|||
len++;
|
||||
if (v)
|
||||
in[i] = (v - 1);
|
||||
}
|
||||
else
|
||||
} else
|
||||
in[i] = 0;
|
||||
}
|
||||
if (len) {
|
||||
|
@ -73,7 +74,8 @@ static void decode(uint8_t *inbuf, uint8_t *outbuf, int inbuf_len) {
|
|||
/*
|
||||
* convert the base64 data blog
|
||||
*/
|
||||
static int uemis_convert_base64(char *base64, uint8_t **data) {
|
||||
static int uemis_convert_base64(char *base64, uint8_t **data)
|
||||
{
|
||||
int len, datalen;
|
||||
|
||||
len = strlen(base64);
|
||||
|
@ -280,7 +282,8 @@ static void uemis_event(struct dive *dive, struct divecomputer *dc, struct sampl
|
|||
/*
|
||||
* parse uemis base64 data blob into struct dive
|
||||
*/
|
||||
void uemis_parse_divelog_binary(char *base64, void *datap) {
|
||||
void uemis_parse_divelog_binary(char *base64, void *datap)
|
||||
{
|
||||
int datalen;
|
||||
int i;
|
||||
uint8_t *data;
|
||||
|
|
3
uemis.h
3
uemis.h
|
@ -17,7 +17,8 @@ int uemis_get_weight_unit(int diveid);
|
|||
void uemis_mark_divelocation(int diveid, int divespot, char **location, degrees_t *longitude, degrees_t *latitude);
|
||||
void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude);
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
uint16_t dive_time;
|
||||
uint16_t water_pressure; // (in cbar)
|
||||
uint16_t dive_temperature; // (in dC)
|
||||
|
|
Loading…
Add table
Reference in a new issue