Commit graph

1939 commits

Author SHA1 Message Date
Berthold Stoeger
a0cd89f850 Core: split copy_cylinders() in two functions
copy_cylinders() copied the cylinders of one dive onto another dive
and then reset to the original gas values. Presumably, when copy and
pasting cylinders from one dive to another, only the types should
be copied, not the gases.

Moreover, the function could either copy all or only the used cylinders.

Firstly, the code was bogus: when restoring the pressures the indices
were mixed up: the old indices were used. Thus, when there where
uncopied cylinders, not all pressure values were restored.

Secondly, it is not clear that all callers actually want to restore
the pressure data. It rather appears the two (out of three) callers
actually just want to copy the cylinders.

Therefore, split the function in
  1) copy_cylinders(): copy the cylinders with pressure data
  2) copy_cylinder_types(): copy only the cylinder information

Since there is only one caller of copy_cylinder_types(), the "used_only"
argument can be removed. Since all cylinders are copied there is
no point in storing the pressure data. Don't overwrite it in
the first place.

The resulting two functions should be distinctly easier to understand.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-27 11:55:05 -07:00
Dirk Hohndel
52cb38e540 Bluetooth: autodetect Shearwater NERD models
This should allow it to work with Subsurface-mobile as well.

Fixes #2187

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-19 21:50:36 -07:00
Berthold Stoeger
94521c9958 Cleanup: remove bogus mark_divelist_changed() calls
The parsers / downloaders parse into a separate table and do
not directly change the divelist. Therefore, they shouldn't
call mark_divelist_changed().

Likewise split_dive_at() doesn't modify the dive list and
therefore shouldn't call this function.

Calling the function has the unwanted side-effect that undoing
the change will not clear the *-symbol in the title of the
main window.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-19 21:44:13 -07:00
Berthold Stoeger
3bb60e8ffe Cleanup: remove unused weightsystem_none() function
This function was used to count the number of weightsystems
used in a dive. Since the weightsysems are now collected
in a dynamic table it became unused. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
a5e7f4253a Core: dynamically resize weight table
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.

The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
efdb3503ea Core: Implement same_weightsystem() function to compare weights
This will be used later when joining and editing dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-18 06:00:58 -07:00
Berthold Stoeger
ca4103ea6a Cleanup: declare functions in profile.h as extern
We seem to do this in other C-headers, so for consistency also do
it here.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
f145b116f0 Cleanup: make the plot-pressure type an enum
Sadly, this doesn't give any type safety. But at least it documents
the function arguments.

Make the last item in the enum as a number-of-pressure-entries
sentinel. Use that to size the pressure-values array.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
39ede7e9e8 Cleanup: introduce function to set pressure values
Instead of assigning the the lvalue of the SENSOR_PRESSURE
macro, introduce a general function to set pressure values.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
68147c4225 Cleanup: update comment in core/gaspressures.c
The comment to populate_pressure_information() was mentioning
gas pressures that didn't exist. Remove these parts.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
469cc68b02 Cleanup: replace pressure reading macros by inline functions
Replace the INTERPOLATED_PRESSURE and SENSOR_PRESSURE macros by
inline functions. Generate a common inline function that reads
a pressure value for a dynamic sensor.

Not all SENSOR_PRESSURE macros can be replaced, because the
macro is also used to set the value and C sadly doesn't know
the concept of "return reference from a function".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
29005b578d Cleanup: turn GET_PRESSURE macro into inline function
There is absolutely no reason to use a macro here.
The only argument that can be made is consistency with
the other pressure-macros, but those too are questionable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
1eafd500e3 Cleanup: remove non-existing pressures in debug_print_pressures()
DILUENT_PRESSURE and INTERPOLATED_DILUENT_PRESSURE do not exist
anymore. No point in trying to output them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
34b3a13f38 Cleanup: remove unused macro SAC_WINDOW
Last user was removed in ae1e9b11a5

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:50:22 -07:00
Berthold Stoeger
8f119dcf72 Cleanup: remove includes from qthelper.h
To reduce interdependencies, remove the dive.h and divelist.h
includes in qthelper.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
0136d76cf4 Cleanup: move deco function declarations to deco.h
Another tiny step in making dive.h smaller: move function
declarations to deco.h if these functions are defined in deco.c
and don't directly concern dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
b720f36978 Cleanup: fix include weirdness concerning string_to_*() functions
The string_to_*() functions were declared in dive.h and qthelper.h.
Moreover in one file they were declared with C in the other with
C++ linkage. This only works because qthelper.h includes dive.h
first.

Fix this anomaly by declaring the functions only in qthelper.h,
but moving them from the C++ to the C part.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
b862e028c6 Cleanup: move cylinderuse_from_text() to equipment.c
Since this function doesn't act on a dive and is only related
to cylinders, move it to equipment.c and equipment.h.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Dirk Hohndel
3e5d60d95a Bluetooth: recognize Ratio iX3m GPS dive computers
We cannot tell them apart by Bluetooth name, so pick one of the names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-15 11:18:32 -07:00
Linus Torvalds
36121fd8ae Fix up XML saving of remaining bottom time data
While testing the cylinder type saving fix, I noticed that the RBT
saving was broken.  Instead of saving RBT whenever it changed, we'd save
it when it was non-zero.  Which doesn't match the git save format, and
also doesn't match what we do when loading an xml file (where we default
to the previous RBT value, and a sample RBT will modify it).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-14 22:17:13 +02:00
Linus Torvalds
c685c05ff4 Fix cylinder gas type saving when we have bogus gas use data
Steve Williams reported a crash when saving a previously loaded dive as
xml, and gave a gdb backtrace.

It turns out that if we can't parse the cylinder use type (OC, diluent,
oxygen, unused) we initialize the cylinder use to an invalid type, and
then when we save it, we mess up.

Fix it up by doing proper limit checking before accessing the
"cylinderuse_text[]" array when saving.

Reported-by: Steve <stevewilliams@internode.on.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-14 22:17:13 +02:00
Berthold Stoeger
92dc441f02 Thumbnailer: improve error message
In the error messages shown when failing to start ffmpeg, instruct
the user to set the correct executable in the preferences.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-11 00:24:23 +09:00
Berthold Stoeger
9eb860d45d Git: handle excess of cylinders or weightsystems gracefully
Currently, the git parser happily trashes memory if a git repository
contains too many weightsystems or cylinders. This should only happen
in testing, but nevertheless try to handle it gracefully and ignore
excess cylinders / weightsystems.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-10 05:11:47 +03:00
Berthold Stoeger
ae60fdf815 Cleanup: call calculate_max_limits_new() in create_plot_info_new()
All callers of create_plot_info_new() called calculate_max_limits_new()
a line before. Thus, simply call the latter in the former.

This allows us to automatically free the plot data in create_plot_info_new().
The old code overwrote the corresponding field with NULL.

As a side-effect, this removes a bogus static variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 11:23:35 -07:00
Berthold Stoeger
69be1e23f2 Cleanup: fix memory management of the plot data
There was a global variable last_pi_entry_new, which stored the
recently allocated plot data. This was freed when new plot data
was generated.

A very scary proposition: You can never have two plot datas at
the same time! But exactly that happens when you export for
example subtitles.

The only reason why this didn't lead to very crazy behavior
is that at least on my Linux machine, the calloc() call would
just return the previously freed memory.

Fix this mess by removing the global variable and freeing the
data in the callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 11:23:35 -07:00
Berthold Stoeger
5e9ffe3005 Cleanup: remove unused get_screen_dpi() function
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 04:10:14 -07:00
Berthold Stoeger
675288f711 Cleanup: remove unused declarations from display.h
A number of declarations were not used anywhere. Remove them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-06 04:10:14 -07:00
Robert C. Helling
5c1446a87a Planner: Wait minimum switch time when bailing out to OC
Bailing out does not happen instantly. Rather wait for
the minimum stop switch duration before ascending.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-06-28 15:58:52 +02:00
Berthold Stoeger
d60ec98e8e Cleanup: remove includes from extern "C" block
In "core/save-html.h", the "core/dive.h" header was included in the
extern "C" block. This is invalid, because "core/dive.h" included
from C++ code contains Qt macros that expand to C++ templates. These
in turn must not have extern "C" linkage, since a plain C-linker
cannot handle such things.

The only reason this worked is that in all cases "core/save-html.h"
was included after "core/dive.h". The include of the latter in the
former had therefore not effect.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-28 20:18:02 +09:00
Berthold Stoeger
9e1d83ca56 Import: use TRIP_THRESHOLD when checking for trip-overlap
When checking for trip-overlap on import, only really overlapping trips
have been considered, i.e. when dives had overlapping times.

Instead use the TRIP_THRESHOLD so that on download dives are added to
the same trip if in a two-days time frame.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-28 20:13:49 +09:00
Berthold Stoeger
2e230da361 Cleanup: unify selection signals
For historic reasons, there where three distinct signals concerning
dive-selection from the undo-machinery:
1) divesSelected: sent newly selected dives
2) currentDiveChanged: sent if the current dive changed
3) selectionChanged: sent at the end of a command if either the selection
   or the current dive changed

Since now the undo-commands do a full reset of the selection, merge these
three signals into a single signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
e1abf9485c Undo: unify selection behavior in dive-list commands
Some commands tried to retain the current selection on undo/redo,
others set the selection to the modified dives.

The latter was introduced because it was easier in some cases, but
it is probably more user-friendly because the user gets feedback
on the change.

Therefore, unify to always select the affected dives on undo()/redo().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
27944a52b1 Undo: don't send signals batched by trip
Since the default view is batched by trips, signals were sent trip-wise.
This seemed like a good idea at first, but when more and more parts used
these signals, it became a burden. Therefore push the batching to the
part of the code where it is needed: the trip view.

The divesAdded and divesDeleted are not yet converted, because these
are combined with trip addition/deletion. This should also be detangled,
but not now.

Since the dive-lists were sorted in the processByTrip function, the
dive-list model now does its own sorting. This will have to be
audited.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
12a13d722a Undo: sort dives by dive_less_than() in signals
In signals dives were sorted by date. This criterion is not be unique.
Therefore sort by the dive_less_than() function of the core to avoid
any inconsistencies between the Qt-models and the core data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
b7ff069b02 Cleanup: remove unused macros WEIGHT_IDX_PRIMARY and _SECONDARY
Last users were removed in 34db6dc2be.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
7bfec6fa19 Cleanup: use total_weight() in DiveObjectHelper::sumWeight()
Don't reimplement the summation of weights.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
3e88bd686f Cleanup: remove unused parameter used from find_best_gasmix_match()
The last direct user of the used parameter was removed in
16276faa45, the last actual user in
e2bbd0ceec.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
219c230506 Cleanup: constify two equipment helper functions
add_cylinder_description() and add_weightsystem_description() don't
modify their input parameter. constify them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
d129085b59 Cleanup: use add_to_dive_table() in record_dive_to_table()
This was reimplementing functionality that was already there.
Simply call the already existing function.

Thus, we don't have to export the grow_dive_table function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
3df32044ee Cleanup: generate clear_*_table() functions by macro
In analogy to the other table functions, generate these by
a macro as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
f4ef1c4bc8 Cleanup: localize enum and table in divelist.c
The cns_table was only used in divelist.c. Make it of static
linkage accordingly.

The cns_table_headers enum is likewise only used in divelist.c.
Therefore move it from the header to the .c file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
821f68550d Cleanup: make local variables and functions in deco.c static
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
e2937f0614 Cleanup: move function declaration into header file
The function declarations of regressiona(), regressionb() and
reset_regression() were given in an independent translation unit.
Move them into the proper header file. To ensure consistent function
signatures is the whole point of header files, after all.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
5514047b43 Cleanup: remove unused global variables plangflow and plangfhigh
The last user was removed in 1093d6235b.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
ef8c5cd9ab Cleanup: make lookup table in planner.c of static linkage
The lookup tables decostoplevels_metric and decostoplevels_imperial
in planner.c were not used outside the translation unit. Make them
static.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
afd6c66346 Cleanup: remove unused function find_dive_including
Last caller was removed in 7eb422d988.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
af5aa8a23d Cleanup: Make gaspressures.h a regular include file
gaspressure.h had definitions of non-exported structs, but did
not declare the only function exported by gaspressure.c.

Therefore, move the struct definitions into gaspressure.c and
the declarations of the populate_pressure_information() function
from profile.c to gaspressures.h.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
619d3fb1fd Cleanup: move gas-functions to own translation unit
But only functions that operate only on gases. Functions concerning
cylinders or dives remain in dive.c or are moved to equipment.c

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
8352274758 Cleanup: remove unused macro FOR_EACH_PICTURE_NON_PTR
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
ce065968f0 Cleanup: remove bogus inline modifier
gas_density() was declared extern in the header and defined inline
in the translation unit. I didn't even realize that this oxymoron
is valid. Remove inline and an Java-style function definition.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
bff80cf462 Cleanup: move unit-related functions to own translation unit
Create a units.c translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
7f4d9db962 Cleanup: move trip-related functions into own translation unit
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
f1c2cd375e Cleanup: move TRIP_THRESHOLD into divelist.c
This macro was not used elsewhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
529bdef0d6 Cleanup: create equipment.h header
There is an equipment.c file, but no corresponding header. Move the
corresponding functions into a newly created header. This does not
improve compile time since, at least for now, equipment.h is included
in dive.h. But it makes things more consistent.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
27d7f27409 Cleanup: fix comment to STRUCTURED_LIST_FREE
The comment said "Clear everything but the first element" but
actually the macro freed the whole list including the first element.
For dive computers it was explicitly called on the second element.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
6200909ba4 Cleanup: move tag functions into own translation unit
Make dive.h a bit slimmer. It's only a drop in the bucket - but at
least when modifying tag functions not the *whole* application is
rebuilt anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
46c69fccb7 Cleanup: fix includes in membuffer.h
Headers should not have to be included in a certain order.
Therefore include stdarg.h and stdio.h in membuffer.h, since
the latter uses FILE and va_list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
e3304d8d7d Cleanup: use taglist_copy() instead of STRUCTURED_LIST_COPY
There is a function for copying tag-lists, use that instead of the
raw STRUCTURED_LIST_COPY macro-invocation. This will help in moving
tag functions into their own translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
9b787e0606 Coding style: remove Java-style function definitions in dive.c
These stuck out like a sore thumb - let's go C-style instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
d3cd85b343 Cleanup: remove unused function dump_taglist()
This was probably used for debugging but has no callers anymore.
Let's remove it. If needed, it can be trivially readded.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Dirk Hohndel
16fc94301e Android: add Cressi Cartesio and Goa as potentially supported
Assuming they are connected to an FTDI cable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-15 11:35:32 -07:00
Berthold Stoeger
a20c22d907 Undo: hide multi-dive-edit warning message on subsequent edit
When a different field is edited, hide any old multi-dive-edit
warning message. The reason is that we might want to add an "undo"
button to the message. But this will undo the wrong command if
we don't hide the message.

Sadly, this means that we can't use animated show / hide, because
an animatedHide() followed immediately by an animatedShow() does
not necessarily show the message. In other words, and animatedShow()
does not interupt a started animatedHide()!?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00
willemferguson
58985cd8ae Correct typo in Information box
Correct type in SCR delta pO2 display in Information box

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-06-07 09:42:39 +02:00
Berthold Stoeger
cf3bb91ec0 Cleanup: remove unnecessary include in downloadfromdcthread.cpp
No QRegularExpressions were used in that file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-06 14:52:42 +03:00
willemferguson
a592b4e143 Add delta-pO2 disply in Information Box
Add display of the difference between pO2 in rebreather loop and the
equivalent OC pO2: this is the oxygen drop over the mouthpiece for
SCR dives. Obviously this is only displayed for SCR dives.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-06-03 22:56:06 +02:00
Linus Torvalds
ba31c56c78 Add BLE detection for the new Oceanic Geo 4.0
Note that we don't really have libdivecomputer support for it yet, only
newly added model numbers etc.  But the name detection should make it
easier for people to at least download a memory dump.

In addition to the libdivecomputer model number updates, this also has a
merge of Jef's upstram libdivecomputer changes.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-06-01 05:25:23 +03:00
Robert C. Helling
4767349111 Update deco disclaimer
Our disclaimer is no longer "new". It is still true that people
should not blindly follow it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-05-29 15:04:33 +03:00
Berthold Stoeger
4fe9b39cdb Core: let count_divecomputers() operate on an arbitrary dive
Currently, count_divecomputers only works on the current_dive.
Instead, let it take a pointer to an arbitrary dive. This is
in preparation for being smarter in the undo code concerning
which dive computer to show on deletion.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20 21:23:16 -07:00
Berthold Stoeger
ac590235c9 Cleanup: rename clone_dive() to move_dive()
This function clones a dive and clear out the old dive. This
corresponds to move semantics. Name the function accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20 21:23:16 -07:00
Berthold Stoeger
0bc96905bf Undo: make "delete dive computer" undoable
Simply reuse the code for "move dive computer" by creating
a DiveComputerBase base class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20 21:23:16 -07:00
Berthold Stoeger
eba6e76b96 Undo: make "move dive computer to front" undoable
Instead of the elegant solution that just modifies the dive,
keep two copies and add either the old or the new copy. This
is primitive, but it trivially keeps the dives in the right order.
The order might change on renumbering the dive computers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-20 21:23:16 -07:00
Berthold Stoeger
77b5d714fb Core: consider dive computers when sorting dives
When splitting out dive computers, the dives were sorted in
an arbitrary way (according to an internal id), since all
data are identical.

Therefore, consider the dive-computer model names when sorting
dives. Equal dives are now sorted alphabetically by model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-17 07:55:34 -07:00
willemferguson
a969d1dd45 Implement height-to-pressure functions in planner
The units.h file has two functions to convert atm pressure to mbar
and also to convert mbar to atm pressure. Implement these two
functions in the planner.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-05-17 09:46:05 +02:00
Linus Torvalds
9590709e8c Add support for the new Suunto D5
This is just a trivial update to recognize the BT name, and a
libdivecomputer submodule update to get the updates to libdivecomputer
to recognize the new USB IDs etc.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-17 09:42:05 +02:00
Dirk Hohndel
2feedf46fa Cleanup: small coding style fixes
And addressing a cut and paste error in a comment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-05-15 07:42:14 -07:00
willemferguson
1bdf00b2b4 Convert the atmospheric pressure in the Information Tab to an editable field
The Information tab shows the atmospheric pressure. Make this value editable
and also ensure that changes to it are undo-able.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-05-15 07:37:14 -07:00
Berthold Stoeger
75767c456a Turn application state into enum
The application state was encoded in a QByteArray. Thus, there was
no compile-time checking. Typos would lead to silent failures.

Turn the application state into an enum. Use the enum-class construct,
so that the values don't polute the global namespace. Moreover,
this makes them strongly typed, i.e. they don't auto-convert to
integers.

A disadvantage is that the enums now have to be cast to int
explicitly when used to index an array.

Replace two hash-maps in MainWindow to arrays of fixed sizes.

Move the application-state details into their own files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-12 12:33:55 -07:00
Berthold Stoeger
114b3d9d47 Core: consider dive-number on sorting
A user reports a problem when dives have the same time but different
numbers. The dives appear sorted randomly (effectively they are sorted
by an internal unique-id).

Try to sort by number for dives at the same date in this case.

Fixes #2086

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-12 12:28:06 -07:00
Berthold Stoeger
e362afe43c Cleanup: remove UTF8 macros
At some places we use UTF8 string literals. Therefore, we effectively
only support UTF8 build systems. We might just as well remove all
the other UTF_* macros and use direct string literals.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-12 12:25:43 -07:00
Berthold Stoeger
bab7033ccb Dive site: create new dive site at location from GPS data
Some dive computers save GPS data. Currently, this is stored
by libdivecomputer in an "extra field". When generating a
new dive site for a dive try to use this data to place the
dive site.

To do so, create a "dive_get_gps_location()" function. This
function can be extended later to use e.g. event. When creating
a dive site, use the result of this function over a potential
pre-existing dive site.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:35:11 -07:00
Berthold Stoeger
c529cfd361 Cleanup: remove for_each_gps_location macro
This macro had no users.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:35:11 -07:00
Berthold Stoeger
6586ba5579 Cleanup: move parse_location() declaration into header file
The parse_location() function was used in three places. In two
of them, the declaration was in the translation unit. Instead,
move the declaration into a header file, to avoid duplication
and the possibility of inconsistencies.

The "units.h" header was chosen as this is where location_t
is defined.

Moreover, make the string argument to parse_location() "const
char *", so that it can be used on non-owned buffers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:35:11 -07:00
Dirk Hohndel
144de49ad4 Mobile: add checkbox to force downloading all dives
This has been a feature people have asked for quite frequently. It is
taking up some valuable screen real estate - so the question could
become if there should be a switch to enable / disable it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-05-11 11:40:07 -07:00
Doug Junkins
98b3a326bd Add "Import dive sites" menu to mainwindow
Adds "Import->Import dive sites" menu to mainwindow.cpp and adds the
on_actionImportDiveSites_triggered() method to prompt for the filename
to import from. The files are parsed and then any dive and trip data is
cleared before opening a dialog box to select which sites are to be
imported.

Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-05-06 10:48:44 +02:00
Berthold Stoeger
9442e17ba8 Cleanup: remove unused macro SURFACE_PRESSURE_STRING
The last user was removed in c3f07b9f81.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-05 08:36:21 -07:00
Doug Junkins
14a763a6a0 Bugfix for algorithm in get_distance()
Fixed bug in the Haversine function in get_distance() based on algorithm
at https://www.movable-type.co.uk/scripts/latlong.html and added bounds
to the 'a' term to avoid floating point errors for antipodal points.

Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-04-30 23:32:50 +02:00
William Perry
9bb7bbef84 Support for Scubapro G2 HUD discovery via bluetooth
Signed-off-by: William M Perry <wmperry@gmail.com>
2019-04-28 09:39:50 +02:00
Linus Torvalds
866ca76a58 qt-ble: return DC_STATUS_TIMEOUT rather than DC_STATUS_IO on timeout
This didn't use to matter, because none of the BLE-using backends did
retry on timeout until recently.

But Jef started doing packet sending retry for the Mares Icon backend,
and now we should make sure to distinguish the "IO failed" from "IO
timed out" cases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-18 05:42:54 +12:00
Robert C. Helling
52105e5217 Write dive data as video subtitles
This commit adds an entry to the dive media context
menu which offers to write a subtitle file. This
creates an .ass file for the selected videos.

In an attempt to to clutter the screen too much, don't
show irrelevant entries (zero temperature or
NDL and show TTS only for dives with stops).

VLC is able to show these subtitles directly, they
can be integrated into the video file with ffmpeg.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-04-16 20:38:19 +02:00
Berthold Stoeger
15b2dbede4 Mobile: reinstate roleNames function in ConnectionListModel
Commit c69ca4df80 removed the roleNames
function, which is not needed according to the docs, as a default function
is provided. For unknown reasons this broke the QML combo box.

Reinstate the function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-16 23:43:14 +12:00
Robert C. Helling
aa86d47e47 Don't show surface gas in gas use list
Skip gas use calculation for the gas that was used in
the surface segment added by the planner in the end.

Reported-by: philippe@philmassart.net
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-04-16 02:00:35 +12:00
Linus Torvalds
606c3a0245 make sure to clear dives on dive split failure
The dive splitting code returns an error code when splitting fails, but
it turns out that the C++ UI code doesn't actually look at the error
code, and instead expected the resulting dives to be NULL if an error
happened and the split didn't succeed for whatever reason.

Which is kind of lazy of it, but we might as well clear the resulting
dives and make the UI code happy.  This should fix the problem that
Celia Marlowe reported on the Subsurface google groups forum.

Reported-by: Celia Marlowe
Acked-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fixes: 145f70aab5 ("Undo: implement split-out of dive computer")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-15 11:22:44 +12:00
Dirk Hohndel
88a9b8abf5 FTDI support: ignore case when comparing magic device name
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-15 10:30:33 +12:00
Berthold Stoeger
88dc32fdfc Core: turn add_single_dive() to append_dive()
The only external caller of add_single_dive() used it to append a
dive to the global dive list. Rename the function accordingly and
remove the index parameter.

The internal caller can use the local insert_dive() function, which
doesn't consider selection. That shouldn't be a problem, as the
caller is doing import.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15 10:24:31 +12:00
Berthold Stoeger
1bc977452d Cleanup: free dive table in trips and dive sites
Trips and dive sites were changed to use dive tables instead
of linked lists. But the memory used for the tables wasn't freed.
Do this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15 10:21:10 +12:00
Doug Junkins
27927f74a1 Add export option to export dive sites.
Selecting "Selected dives" exports the dive sites for the selected
dives. Selecting "All dives" exports all dive sites.

XML format is the subsection of the divelog XML that describes the
sites headed with a <divesites> section like:

  <divesites program='subsurface' version='3'>
  </divesites>

Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-04-13 08:18:32 -07:00
Berthold Stoeger
b024ca101e Dive site: make UUID generation deterministic
Instead of using a random UUID, use an SHA1 hash of name, description
and notes (if defined). This is necessary for testing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
d5953318ca Cleanup: replace QString("") by QString()
That should be more effective.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
779c4eb5d0 Cleanup: remove redundant checks for null dive site
The dive_site_has_gps_location() function already checks for the null
dive site. Remove redundant checks.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Doug Junkins
9b5eab4ca1 Remove check for whether a site is used before saving it.
Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
58f2e5f77c Undo: use QUndoStack::isClean() to determine unsaved changes
Properly implement the unsaved-changes flag(s). Since we currently have
two kinds of changes, there are two flags:
1) dive_list_changed in divelist.c marks non-undoable changes. This flag
   is only cleared on save or load.
2) QUndoStack::isClean() is used to determine the state of undoable
   changes. Every time the user returns to the state where they saved,
   this flag is cleared.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
d7d408a99e Undo: implement undo of dive trip editing
This is copying the dive editing code. It uses an OO design with
virtual functions for getting and setting the values. It doesn't
use templates though, as both fields of strig type. This feels
a bit over-engineered, but it is 1) consistent with the dive edit
code and 2) the number / types of dive trip fields might increase.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9fd87fa080 Undo: update cylinder and weight models on paste
When pasting (or undoing paste) the cylinders or weights may change.
Send the appropriate signals and update the models accordingly.
Currently, this means copying from current dive to displayed dive,
but hopefully we can get rid of "displayed_dive" in the not so
distant future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9ed5cf16a4 Coding style: remove Java-style function definition
Remove a few cases of
	void fun() {
		...
	}

While touching these functions, fix a few other whitespace
coding style violations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
92e6e2bba1 Core: introduce taglist_copy() function
Taglists were only copied in dive.c using the STRUCTURED_LIST_COPY
macro. Export that functionality in a function. This will be
needed for undo of dive-pasting.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
cddd5942f8 Undo: update dive list after edit command
The dive list was not updated automatically when an edit command was
executed. There was already a signal to do that, viz. divesChanged().
But that signal worked by-trip and didn't have a dive-field specifier.

The edit-commands used the divesEdited() signal that isn't by-trip
but has a dive-field specifier.

Unify these two signals to be by-trip and with dive-field specifier.
This needs common code to generate the by-trip list that is moved to
a command_private.h header.

Since there might now be multiple signals (one per trip) actually
check in the main-tab whether the current trip is affected to
avoid multiple update of fields. This has the positive(?) effect
of not doing any update if the current dive isn't changed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
c82f4487f9 Undo: implement undo of depth and duration editing
This was a bit different from the other editing commands:
1) Only the current dive is edited not all selected dives.
   Therefore, create a function that turns the current dive
   into a one-element list.
2) The profile has to be replot. Here, likewise, create a
   function to do that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
6f574c53a3 Undo: implement undo of dive site editing
This one is a bit more tricky. There are two modes: set dive site
and set newly created dive site. This is realized using an OO model
with derived classed. Quite convoluted - but it seems to work.

Moreover, editing a dive site is not simply setting a value,
but the list of dives in a dive site has to be kept up to date.

Finally, we have to inform the dive site list of the changed
number of dives. Therefore add a new signal diveSiteDivesChanged.
To send only one signal per dive site, hook into the undo() and
redo() functions and call the functions of the base class there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
a12adf8e2a Pedantic: K are an absolute scale, which are not given in degrees
Since somewhere in the 1960s. "Fix" a few comments.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
45ef879546 Undo: update notes field if changed by undo commands
To keep the UI in a consistent state, update the notes field if
it is changed by an undo command. To that purpose, add a new
signal to diveListNotifier with a list of dives and a field-id
as payload.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
59239cec02 Undo: make dive site merging undoable
This one was rather trivial, as there is no actual merging
done. Quite simply, a number of dive sites are removed and
their dive added to a different dive site.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
0e1b0cf1da Undo: Implement undo of dive site name editing
Implement an undo command that edits the name of a dive site.
Connect it to the dive site table, so that names can be edited
directly in the table.

Send signals on undo / redo so that the dive site table and
the dive site edit widget can be updated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
59e602447b Dive site: inform model of dive site addition / deletion
Introduce two DiveListNotifier signals which are sent by
the undo commands if dives are added to / removed from the
core.

The signal has the dive site and the index in the global
dive site table as payload. Thus, the model has only to
remove the appropriate rows.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
84f7179367 Cleanup: macroize dive site table functions, keep table sorted
Turn the table functions of the dive site handling into macros
as was already used for dives and dive trips. This has the effect
that the table is kept sorted by UUID.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
a6f65d744f Cleanup: move table-macros into own header
dive- and trip-table functions are generated in dive.c by macros.
Move this macros to a new "core/table.h" header file.

Thus, these functions can be used for other tables (e.g. dive site)
and the trip function can be moved to a separate translation unit
(divelist.c being quite large already).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
efb770c979 Cleanup: autogenerate remove_dive() and remove_trip()
The other dive- and trip-table functions were already autogenerated.
Let's do the same for these two.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
dc9427d16a Cleanup: rename unregister_trip() to remove_trip()
For consistency with remove_dive(). Moreover, swap parameter order
in remove_dive() so that both functions use the same parameter order.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
8dcc33d8ab Undo: keep frontend informed of changes to dive site count
Add a new signal to DiveListNotifier. Send signal if dives are
added or removed and therefore the dive count of a dive site
changes. The dive sites are collected and the signal is sent
at the end of the command.

Add code to update the table view.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
992ad2fa27 Dive sites: simplify nr_of_dives_at_dive_site()
1) The second parameter (selected_only) was always false. Therefore,
   remove it.

2) Simplify the function by simply returning the reference count.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9e9821551f Dive site: use ref-counts to see if dive site is used
Checking for dive site usage is now simply checking the number
of dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
e2df38d868 Dive site: add dive site ref-counting
Instead of setting dive->dive_site directly, call the
add_dive_to_dive_site() and unregister_dive_from_dive_site()
functions. In the parser this turned out to be a bit tricky.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
c22fd9f4fd Dive sites: prepare for dive site ref-counting
Add a dive site table to each dive site to keep track of dives
that have been added to a dive site. Add two functions to add
dives to / remove dives from dive sites.

Since dive sites now contain a dive table, the order of includes
had to be changed: "divesite.h" now includes "dive.h" and not
vice-versa. This caused some include churn.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f2cdca7bcc Cleanup: move declaration of get_stylesheet() to qthelper.h
The function is defined in qthelper.c and thus not all users
of dive.h have to suck in the xslt headers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
25234c0513 Cleanup: remove "libxml/tree.h" include from "dive.h"
Apparently it wasn't used anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f3e1187e65 Cleanup: move parse-function declarations out of "dive.h"
Move the declaration of these functions to "file.h" and "parse.h"
according to the translation unit they are defined in. Thus, not
all users of "dive.h" have to suck in "sqlite3.h".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
7c64822b9b Cleanup: remove "sha1.h" include in "dive.h"
No point in pulling that in for all users of "dive.h"

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
31291b1c56 Dive site: set UUID only on save or load
Since the UUID will be overwritten on save and is only used on save
and load, set it only on save or load. For other created dive sites,
leave the UUID field uninitialized.

This means that the UUID will change between saves. Let's see how
the git saver handles that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
ac1602f512 Dive site: ensure that no two dive sites have same UUID
We absolutely want to avoid dive site with the same UUID.
But that could happen when reimporting a log where the
dive sites diverged.

Therefore, on adding a dive site to a table, change the UUID
if it already exists. Since dives are associated to dive
sites with pointers, this should have no negative impact.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
a2be015a43 Undo: consider dive site in AddDive()
If a dive site was added for a new dive, remove it on undo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
e1caae0111 Cleanup: let get_dive_site_idx() compare pointers
The code used dive site uuids, which are not really used anymore.
The only caller of this function does certainly not use a copy,
so let's compare pointers instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
82af1b2377 Undo: make undo-system dive site-aware
As opposed to dive trips, dive sites were always directly added
to the global table, even on import. Instead, parse the divesites
into a distinct table and merge them on import.

Currently, this does not do any merging of dive sites, i.e. dive
sites are considered as either equal or different. Nevertheless,
merging of data should be rather easy to implement and simply
follow the code of the dive merging.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
37146c5742 Parser: parse into custom dive site table
To extend the undo system to dive sites, the importers and downloaders
must not parse directly into the global dive site table. Instead,
pass a dive_site_table argument to parse into.

For now, always pass the global dive_site_table so that this commit
should not cause any functional change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f6e7bdc5ef Dive site: add dive site table parameter to dive site functions
To enable undo of dive site functions, it is crucial to work
with different dive site tables. Therefore add a dive site table
parameter to dive site functions. For now, always pass the global
dive site table. Thus, this commit shouldn't alter any functionality.

After this change, a simple search for dive_site_table reveals all
places where the global dive site table is accessed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Rolf Eike Beer
36644dc9f7 optimize selectedDivesGasUsed()
-return the result instead of storing in a parameter, we now know that the list
 contains only those results that are generated in the function
-allocate the result with the correct length right from the start
-do not iterate over keys of a map and then do a map lookup to get the value but
 use an iterator that gives us both right from the start
-remove one call alltogether as the results were not used there

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Rolf Eike Beer
cf86ece73e use qDeleteAll()
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Rolf Eike Beer
e3d43b5696 replace deprecated qSort() with std::sort()
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Rolf Eike Beer
2e59196e6b use the default constructor for empty QString and QByteArray constants
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Rolf Eike Beer
ee0acb0d40 use QStringLiteral for constants
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Rolf Eike Beer
c4c8094e32 get rid of some foreach and Q_FOREACH constructs
See https://www.kdab.com/goodbye-q_foreach/

This is reduced to the places where the container is const or can be made const
without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7)
and std::as_const (C++17) are not available in all supported setups.

Also do some minor cleanups along the way.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Berthold Stoeger
0eb00ed700 Cleanup: provide our own qOverload<> implementation.
This is only in Qt 5.7 and therefore can't be used in Qt 5.5 and 5.6
builds. Moreover, we can't simply reuse Qt's version owing to
licensing concerns.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-11 11:17:56 +03:00
Linus Torvalds
baeb0ba280 Merge extra_data list when merging two dives of the same dive computer
When merging two dives into a longer one, merge the dive computer
extra_data list too.

We just pick all the extra-data (but avoid entirely duplicate key/value
entries).

Note that this can cause confusing extra-data, in that both dives migth
have things like "battery percentage at beginning/end of dive" keys, and
if the values are different, you'll now get *both* of those values, but
that's better than randomly just taking one of them.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-07 20:11:32 +02:00
Berthold Stoeger
145f70aab5 Undo: implement split-out of dive computer
Allow splitting out a dive computer into a distinct dive. This
is realized by generating a base class from SplitDive.

This turned out to be more cumbersome than expected: we don't
know a-priori which of the split dives will come first. Since
the undo-command saves the indices where the dives will be insert,
these have to be calculated. This is an premature optimization,
which makes more pain than necessary. Let's remove it and
simply determine the insertion index when executing the command.

Original code by Linus Torvalds <torvalds@linux-foundation.org>.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-04 09:38:12 -07:00
Robert C. Helling
8c9e5becb2 Export profile data
This introduces a csv file that contains the data from
the structs defined in profile.c, in particular all
deco information computed for the dive profle (including
NDL, TTS, ceilings, surface GFs etc).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-04-04 09:33:56 -07:00
Berthold Stoeger
a89b36c661 Cleanup: don't instantiate a QPref object
QPref has only static functions. There seems to be no point in
instantiating a singleton of this object. Remove the instance()
method and remove the Q_OBJECT macro.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-04 09:29:45 -07:00
Berthold Stoeger
e9fa298d06 Cleanup: make qPref::registerQML() static
This member function does not access any other member of the object.
Make it static.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-04 09:29:45 -07:00
Berthold Stoeger
2ead52b139 Cleanup: remove qPref::canonical_version() and qPref::mobile_version()
These two member functions were never used, but cause frequent
recompilation of the qPref.cpp file. Remove them for now until
their usefulness becomes evident.

These were the only functions tested in test_qPref.qml. Therefore
remove this test-file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-04 09:29:45 -07:00
Miika Turkia
043d07213a Initial support for Mares import
This import is based on one sample I received. It was exported from some
Mares software. Imported data is somewhat limited, but we do get the
depth and temperature profiles. (I would love to receive some more
sample logs to validate the import and to enhance the data we are
grabbing.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-04-02 07:47:11 -07:00
Robert C. Helling
30746e5d3f Make sure surface air is not considered a deco gas
it creapt in through the gaschange events.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-03-29 06:51:12 -07:00
Robert C. Helling
178eaa9a67 Add UI element for final surface segment in planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-03-29 06:51:12 -07:00
Robert C. Helling
5e494ce761 Show a bit of surface degassing in the planner
to display the deco parameters at the surface,
in particular tissue saturation and heat map.

Suggeted-by: Matthias Heinrichs <info@heinrichsweikamp.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-03-29 06:51:12 -07:00
Rolf Eike Beer
7635ee3e77 CMake: add headers to targets
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-03-27 14:07:32 -07:00
Rolf Eike Beer
ac0650865c ConfigureDiveComputer::saveXMLBackup(): factor out writing gas details
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-03-27 07:36:33 -07:00
Rolf Eike Beer
9ea32a0158 avoid duplicate and inconsistent applying of QDir::separator()
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-03-27 07:36:33 -07:00
Rolf Eike Beer
bf9a526d63 slightly optimize ConnectionListModel
-avoid object copies
-use some more bullet proof C++11 constructs
-avoid using a QRegExp, simple string matches are faster

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-03-27 07:36:33 -07:00
Rolf Eike Beer
5ad52db451 drop support for Qt 5.4 and before
The oldest version tested on TravisCI is Qt 5.5, which is also what is in
Ubuntu 16.04. Drop all the older cruft, noone should use that anymore.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-03-27 07:36:33 -07:00
Berthold Stoeger
643a964d09 Cleanup: unconstify string argument to add_to_string()
add_to_string() frees the original string that is passed in. This
should therefore not be of "const char *" type, as the contents
of the string *will* be modified (or more precisely: destroyed).

Same for the congener smtk_concat_str().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-27 13:58:15 +01:00
Berthold Stoeger
40a3e562b0 Cleanup: provide printGPSCoords in C and C++ versions
printGPSCoords() returned a newly allocated C-style string. Most
callers simply made a QString out of it and freed the C-style string.
This is paradoxical, as printGPSCoords internally works with QStrings
and converts them to C-style on return.

Therefore, let printGPSCoords() return a QString and create a
printGPSCoordsC() wrapper for the two C-callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-27 13:58:15 +01:00
Berthold Stoeger
04593e8ec4 Cleanup: fix printGPSCoords signature and leaks
The printGPSCoords() function returns a copied C-style string. Since
the owndership is transferred to the caller, the correct return type
is "char *" instead of "const char *".

Thus a number of casts when calling free can be removed.

Moreover a number of callers didn't free the string and thus were
leaking memory. Fix them. Ultimately we might want two versions
of the function: one for QString, one for C-style strings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-24 21:57:13 -07:00
Dirk Hohndel
c69ca4df80 Core: simplify ConnectionListModel
The complicated setup with the AddressRole is unnecessary. All we want to be
able to do is get the index of a specific text in the list. In hindsight I am
puzzled why I implemented this in such a complex fashion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-20 09:07:17 -07:00
Dirk Hohndel
8e43d2b8d2 Misc: replace some FIXME comments
All these aren't actually things that need fixing, they are observations about
the code.

Given that LGTM.com reports FIXME comments as Alerts, let's change the ones
that aren't about things that need fixing to something more harmless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-19 09:56:48 -07:00
Robert C. Helling
c7abca2f42 Desktop: fix yet another variable name conflict
Addresses LGTM.com issue.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-18 19:40:32 -07:00
Robert C. Helling
d228eb35d5 Core: let TTS calculation use correct ascent velocities
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-18 19:40:32 -07:00
Robert C. Helling
3af4164d0c Core: change FIXME language
Addresses LGTM.com issue.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-18 19:40:32 -07:00
Robert C. Helling
34bddaf3a8 Core: fix another variable name conflict
Addresses LGTM.com issue.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-18 19:40:32 -07:00
Robert C. Helling
79df0ded3c Core: remove variable name conflict
Addresses LGTM.com issue.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-18 19:40:32 -07:00
Berthold Stoeger
2cbc393f4d Cleanup: remove bit field demux in datatrak.c
To test single bits, datatrak.c would transform bytes into
malloc()ed char[8] buffers. Instead, simply introduce a function
to test individual bits. This should make it distinctly easier for
the compiler to optimize away.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-18 15:59:27 -07:00
Berthold Stoeger
6c561b33d7 Cleanup: unglobalize variables in datatrak.c
It's a drop in the bucket, but let's remove some unnecessary
global variables. With one exception these variables were only
used in one function anyway. The other one can be passed as a
parameter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-18 15:59:27 -07:00
Berthold Stoeger
41375a205c Cleanup: remove unused global variables from datatrak.c
lector_bytes and lector_word were used nowhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-18 15:59:27 -07:00
Dirk Hohndel
69248141c5 Core: remove variable name conflict
Having a parameter with the same name as a global variable is potentially
confusing.

Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
b457965f50 Core: remove variable name conflict
Having a parameter representing a location with the same name as a global
variable representing our locale is confusing.

Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
8bbc375fab Core: remove variable name conflict
Having a parameter with the same name as a global variable is potentially
confusing.

Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
6a6c62ecf5 Core: remove function list comment
We don't do this anywhere else.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
a31a9d0911 Core: remove variable name conflict
Having a char parameter with the same name as a global char * variable is confusing.

Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
2d26300402 Core: cast before multiplication to avoid potential overflow
Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
47f92b92ac Core: cast to the correct type
While in the specific calculations here there isn't really a risk that float
might overflow, it seems odd to cast to float in order to assign to double.

This caused an Alert via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 15:11:31 -07:00
Dirk Hohndel
f3d98518d5 Bluetooth: don't free a resource created by new
Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 11:23:49 -07:00
Dirk Hohndel
87eb95d004 Core: fix missing argument to report_error
The format requires a string argument.

Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 11:23:49 -07:00
Doug Junkins
4613321e3e Add backend support for statistics by depth and temperature
Added stats_t structures to summarize dive statistics by depth and
by temperature.

Process each dive to add the dive stats to the proper depth and
temperature bucket. Buckets are defined using constants
STATS_MAX_DEPTH, STATS_DEPTH_BUCKET, STATS_MAX_TEMP, and
STATS_TEMP_BUCKET which are defined in statistics.h

Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-03-12 00:53:51 +01:00
Berthold Stoeger
9b5f6e16e1 Import: fix infinite loop
Owing to a variable reuse in a nested loop, importing dive logs
with new trips could lead to an infinite loop. Use a fresh index "j".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-05 13:03:43 -08:00
Berthold Stoeger
01e8a54f58 Cleanup: remove DownloadFromDCThread::tripTable
Since ff9506b21b the downloaders don't
add dives to a new trip and therefore the tripTable field of
DownloadFromDCThread became pointless. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 15:31:48 -08:00
Berthold Stoeger
65267599f7 Cleanup: remove outdated comment in libdivecomputer.h
The comment was mentioning a "progressbar_t", which doesn't exist
anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 15:31:48 -08:00
Berthold Stoeger
91ff7b68f0 Cleanup: remove dc_user_device_t::preexisting
This field appears to be unused for a long time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 15:31:48 -08:00
Berthold Stoeger
8cde21a41d Cleanup: remove dc_user_device_t::trip
Since ff9506b21b the downloaders don't
add dives to a new trip and therefore the trip field of dc_user_device_t
became pointless. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 15:31:48 -08:00
Berthold Stoeger
a729911893 Uemis: remove trip deletion on dive deletion
Since ff9506b21b the downloaders don't
add dives to a new trip, but the import code does. Remove the
code in the Uemis downloader that would remove a dive from the trip.
The code has been broken recently anyway (instead of testing for trip,
it tested for the notrip flag, which make no sense whatsoever).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 15:31:48 -08:00
Berthold Stoeger
416401a301 Cleanup: put all function declarations in file.h in extern "C"
Some of the functions declarations were not in 'extern "C"',
despite being C functions. This worked only because they weren't
called from C++. Nevertheless, it seems like a dangerous proposition
to have the same function declared once as C and once as C++.
Therefore, always put them in extern "C" (if compiling in C++ mode,
evidently).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 07:27:10 -08:00
Berthold Stoeger
155260e6d9 Cleanup: make dt_dive_parser() local to datatrak.c
The function is only used in this translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 07:27:10 -08:00
Berthold Stoeger
dd0ded1a9e Cleanup: remove deletion of webservice dive sites
In the XML and git savers, unchanged webservice-dive sites were
deleted. Since the webservice is not functional anymore, remove
this code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 07:27:10 -08:00
Berthold Stoeger
3c2dd7f7c6 Cleanup: move get_divesite_idx() to divesite.c
This function was defined in divelist.c, whereas it's better located
in divesite.c. Move it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 07:27:10 -08:00
Berthold Stoeger
9c87c0dafd Cleanup: make dive_set_geodata_from_picture() local to dive.c
The function dive_set_geodata_from_picture() is only used in
dive.c. Make it local to that translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 07:27:10 -08:00
Berthold Stoeger
0893f87beb Cleanup: uninline get_dive_site_by_uuid
There seems to be no compelling reason to have this function inlined.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-28 07:27:10 -08:00
Dirk Hohndel
9d582c5512 Mobile: only show dive computers in the Bluetooth connection list
And offer an option to show all devices in the settings. This is intentionally
not stored in the preferences as this should never be needed. We don't support
BT or BLE dive computers that we don't recognize. This is a last resort in case
a new firmware were to change the name or some other weird issue causes us not
to recognize a dive computer - and that should be fixed instead of worked
around.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14 09:05:58 -08:00
Dirk Hohndel
f35a0f3b09 Desktop: only show dive computers in the Bluetooth device list
By default we'll only show devices that we believe to be dive computers,
but the user can override that with the recently introduced check box.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14 09:05:58 -08:00
Berthold Stoeger
2743e59415 Cleanup: remove unsused function clear_dive_site()
The last caller was removed in 11a211fb02

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-09 10:36:01 -08:00
Berthold Stoeger
28234ec58d Cleanup: remove unused function create_dive_site_from_current_dive()
The last caller was removed in 11a211fb02

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-09 10:36:01 -08:00
Berthold Stoeger
62fc8b0429 Cleanup: make create_divesite_uuid() of static linkage
This function was not used outside of core/divesite.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-09 10:36:01 -08:00
Berthold Stoeger
8a8063c1cd Profile: add "synchronous" mode for picture plotting
The thumbnails were fetched in the background to achieve a
snappier UI. The problem with that is that on LaTeX etc.
export only placeholder thumbnails were shown.

Therefore, implement a synchronous mode. This only tries
to fetch cached thumbnails or calculate thumbnails for
images. Videos and remote files are not supported.

Fixes #1963

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-07 16:06:43 +01:00
Robert C. Helling
c9d8b4f605 Add button to toggle deco info in info box
The info box can get longish. Offer the user to turn
off display of deco information (surface GF and
individual ceilings).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-02-05 14:18:14 +01:00
Robert C. Helling
4c048ed526 Include surface GF in infobox
The most recent firmware of Shearwater computers shows this.

This is a measure of absolute amout of tissue loadings in an
easy to digest unit. Therefore it is useful to have.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-02-05 14:18:14 +01:00
Lubomir I. Ivanov
a1ffe115cf facebook: remove the featute from the code base
Remove from:
- unit tests
- desktop widgets
- preferences
- core intergration
- cmakefiles
- build scripts
- icons
- docs

Also remove the plugins and social network integration.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2019-02-01 17:16:43 -08:00
Dirk Hohndel
2f9bf92a17 Bluetooth: don't crash if BT is turned off
At least on a Mac we can get here without a discoveryAgent if BT is off,
so don't derefence the NULL pointer in that case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-23 14:41:17 +13:00
Dirk Hohndel
01649503fb BLE debug: make things less verbose
Unless run with '-v -v -v'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-22 11:14:03 +13:00
Dirk Hohndel
a71b7e51d2 libdivecomputer: small wording change in a warning
While in theory the DEVINFO event should give us the correct detected
product, it's also possible that the code that usually detects the
product gave up and returns an unknown model.

Try to have the message reflect that situation more accurately.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-22 11:01:40 +13:00
Berthold Stoeger
891fcbf520 Import: control process_imported_dives() by flags
process_imported_dives() takes four boolean parameters. Replace these
by flags. This makes the function calls much more descriptive. Morover,
it becomes easier to add or remove flags.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
ff9506b21b Import: don't add to new trip while downloading
Since process_imported_dives() can add dives to a newly generated
trip, this need not be done in the downloading code. This makes
data flow distinctly simpler, as no trip table and no add-new-trip
flag has to be passed down to the libdivecomputer glue code.

Moreover, since now the trip creation is done at the import step
rather than the download step, the latest status of the "add to
new trip" checkbox will be considered.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
1cd0863cca Import: add add_to_new_trip flag to process_imported_dives()
If this flag is set, dives that are not assigned to a trip will
be assigned to a new trip. This flag is set if the user checked
"add to new trip" in the download dialog of the desktop version.

Currently this is a no-op as the dives will already have been
added to a new trip by the downloading code. This will be removed
in a subsequent commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
31eb86c733 Dive import: fix logic of process_imported_dives()
The logic in process_imported_dives() was faulty: Dives are merged
trip-wise in a loop. But if only autogenerated trips were supposed
to be merged, the trip would not be added.

Change the logic to always add the trip if it is not merged. To make
the loop easier to read, factor out the merge-trip-into-existing-trips
logic into a separate function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
11d19abc74 Dive download: add trip_table to device_data_t
Since recent commits, dive-trips are not added directly to the core,
but into separate trip tables (see ec37c71f5e).
These commits did not finish the work for the download-from-dc
case.

Add an extra trip_table field to device_data_t. If trips are created
(user selected "Download into new trip"), the trip will be created
in that table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
239e6f237f Cleanup: remove unused variables
Commit 4d06ddd723 removed deletion of
unused dive sites on save. The corresponding variables were not
removed leading to compiler warnings. Remove the variables too.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Robert C. Helling
5f04fecd00 Don't allow empty username for git
When no real name is set in /etc/passwd the username ends
up being ",,,". Git does not like that. Actually, only the
part before the first comma is the name, the rest is office
and phone number. We don't want those.

Before we only testing for the username being a NULL pointer.

Reported-by: Keith Grimes
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-16 02:38:30 +01:00
Robert C. Helling
2c794348c1 Planner: Add checkbox to force OC bailout
This adds a checkbox for rebreather modes of the planner
that force the ascent to be in OC mode. Before, one had
to add a one minute last segment with the mode change but
this is not practical when manually searching for the
maximal bottom time given gas reserves.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-13 15:02:07 -08:00
Berthold Stoeger
0249e12589 Import: split process_imported_dives() function
Split the process_imported_dives() function in two:
1) process_imported_dives() processes the dives and generates
   a list of dives and trips to be added and removed.
2) add_imported_dives() calls process_imported_dives() and
   does the actual removal / addition of dives and trips.

The goal is to split preparation and actual work, to
make dive import undo-able.

The code adds extra checks to never merge into the same
dive twice, as this would lead to a double-free() bug.
This should in principle never happen, as dives that
compare equal according to is_same_dive() are merged
in the imported-dives list, but perhaps in some pathologival
corner-cases is_same_dive() turns out to be non-transitive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
fd196f143a Core: don't copy dive-id on merge dive
The installment of the divelist-undo system has made it unnecessary
to adopt the uniq-id of the merged-into dive. On the contrary, we
want to avoid two dives with the same dive-id in the divelist at
all costs, since get_divenr() still uses the id and thus may fetch
the wrong dive.

Therefore, don't copy the dive-id on merge.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
0dfc59f38c Import: add merge_all_trips parameter to process_imported_dives()
When importing log-files we generally want to merge trips. But
when downloading and the user chose "generate new trip", that
new trip should not be merged into existing trips.

Therefore, add a "merge_all_trips" parameter to process_imported_dives().
If false only autogenerated trips [via autogroup] will be merged.
In the future we might want to let the user choose if trips
should be merged when importing log-files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
1593f2ebad Import: merge dives trip-wise
The old way of merging log-files was not well defined: Trips
were recognized as the same if and only if the first dives
started at the same instant. Later dives did not matter.

Change this to merge dives if they are overlapping.
Moreover, on parsing and download generate trips in a separate
trip-table.

This will be fundamental for undo of dive-import: Firstly, we
don't want to mix trips of imported and not-yet imported dives.
Secondly, by merging trip-wise, we can autogroup the dives
in the import-data to trips and merge these at once. This will
simplify the code to decide to which trip dives should be
autogrouped.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
f542dc4030 Import: add trip_table argument to DiveImportedModel::repopulate()
In the future we want to download trips into a distinct trip-table
instead of the global trip-table to allow for undo of import.

Therefore add a trip_table argument to DiveImportedModel::repopulate()
and a trip_table member to DiveImportedModel. To correctly set these,
add a DownloadThread::trips() function, which currently simply returns
the global trip table.

Finally, make "struct trip_table *" a Q_METATYPE, so that the corresponding
arguments can be passed from QML.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
7e33369dc8 Parser: add trip_table parameter to parsing functions
To allow parsing into arbitrary trip_tables, add the corresponding
parameter to the parsing functions and the parser state. Currently,
all callers pass the global trip_table so there should be no change
in functionality. These arguments will be replaced in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
ec37c71f5e Core: add trip_table parameter to trip-functions
Currently trips are added to the global trip table. If we want to
make dive-import undoable, we should be able to parse trips of a
log-file into a distinct table. Therefore, add a trip_table
parameter to
	- insert_trip()
	- create_and_hookup_trip_from_dive()
	- autogroup_dives()
	- unregister_trip()
	- remove_dive_from_trip()

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
517fb7a462 Core: keep trips in table(s)
Currently, all trips are kept in a linked list. Replace the list
by a table in analogy to dive_table. Use this to keep the trip_table
sorted as suggested by dump_trip_list(). When inserting a trip into
the table do that after adding the dives, to avoid warnings coming
out of dump_trip_list().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
54fcda4c32 Core: fix dump_trip_list() function
In 64e6e435f8 the trip->when field
was replaced by a function. This forgot to adapt dump_trip_list(),
which is only compiled if DEBUG_TRIP is defined. Fix the function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
2c77142696 Core: macroize dive_table functions
Generate dive table functions by macros so that they can be reused
for trip tables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
d1971a64f9 Core: Rename functions to more generic names
Rename
 - dive_get_insertion_index() -> dive_table_get_insertion_index()
 - unregister_dive_from_table() -> remove_from_dive_table()
 - get_idx_in_table() -> get_idx_in_dive_table()
 - sort_table() -> sort_dive_table()
This will make it more straight-forward to generate these functions
from macros.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
2802d42969 Cleanup: Make add_dive_to_table local to divelist.c
This function was not used outside of divelist.c, therefore make it
local. Moreover rename it to add_to_divetable so that the name
is generic and can be generated by a macro.

Moreover, remove the special case idx = -1, which would determine
the insertion index. Instead let the single caller who used this
feature do this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
825fcc8547 Dive list: add table parameter to autogroup_dives()
Currently autogroup_dives() groups all dives in the global dive
list. Add a table parameter so that dives in any table can be
grouped. Thus it will be possible to pre-group dives on import,
which will be used for undo of import.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
f8327ed51b Core: move autogroup() into divelist.c
After loading or importing, the caller usually called autogroup()
to autogroup dives if so wished by the user. This has already led
to bugs, when autogroup() was forgotten.

Instead, call autogroup() directly in the process_loaded_dives()
and process_imported_dives() functions. Not only does this prevent
forgetting the call - it also means that autogrouping can be
changed without changing every caller.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Robert C. Helling
123f3ef7ec Filter for logged/planned dives
Add filter for dives having a planned dive computer or
a logged dive computer.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-08 10:39:06 +01:00
Robert C. Helling
c349692d98 Helper function to determined planned dives
... to reduce code duplication.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-08 10:39:06 +01:00
Berthold Stoeger
4d06ddd723 Dive sites: don't delete unused dive sites on save
Unused dive sites were deleted on save. This clashed with the undo
system in the following scenario:

1) Delete single-use dive site.
2) Save (dive site deleted)
3) Undo (reference to freed dive site)

Therefore, as a quick-fix, keep the referenced dive site around.
Note that this also means that empty dive sites must not be
deleted, as it might refer to a dive in the undo system. Instead
only clear references to empty dive sites in the global dive
table. Factor this functionality out, as it was common to the
XML and git savers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-07 09:33:24 -08:00
Dirk Hohndel
da52440963 Merge branch 'shearwater_cloud' of https://github.com/mturkia/subsurface 2019-01-07 09:31:12 -08:00
Miika Turkia
fd5aad7192 Use state structure for sample rate info
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-01-03 06:56:48 +02:00
Miika Turkia
9c42345494 Use correct value for PO2
averagePPO2 appears to be correct value instead of currentPPO2SetPoint.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-01-01 15:32:27 +02:00
Miika Turkia
5930cb52de Grab correct setpoint on Shearwater cloud import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-31 06:21:53 +02:00
Miika Turkia
01365b8c4b Use different time field as it seems to be more correct
The starTimestamp is 4 hours apart on 2 different DCs within the sample
log. DiveDate on the dive_logs table seems to be correct, but must be
converted from human readable format.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-30 16:31:51 +02:00
Miika Turkia
5e0f105114 Sample rate varies between dives
Seems that Shearwater cloud stores sample rate into the database and
it is not constant within the log.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-29 22:39:55 +02:00
Miika Turkia
2bc7aa5fc7 Initial support for Shearwater Cloud
This works to some extent to part of a sample log I received. However,
still quite a bit more work is needed.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-29 21:32:55 +02:00
Miika Turkia
a0d7b76dd0 Shearwater import: dive id might be large than int
I encountered this while implementing Shearwater Cloud import, but it
makes sense to increase the size for dive id for Shearwater Desktop as
well.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-29 21:31:12 +02:00
Lubomir I. Ivanov
d4d9b840cc windows.c: fix wrong usage of wcslen() for utf8 conversation
wcslen() returns the number of characters in a wchar_t string.
In the case of WideCharToMultiByte() an estimate for the size of
the utf8 buffer is needed. Using wcslen() is incorrect for such a buffer,
because for any non-ASCII character the estimate will be off by 1 byte.

Call the following instead to obtain the proper UTF8 buffer size
for the conversation:
  WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL);

Also fix some missing "\n" in fprintf() calls.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-12-29 18:27:21 +01:00
Jan Mulder
09a7736ae1 Core: fix BT on Linux, workaround Qt bug on 5.12.0
After upgrading to Qt 5.12.0, download over BT from a DC did not work
any more. On the console the message "Connecting to port is not
supported (Uuid required)". Linus noticed earlier that we do rather
strange processing in this part of the code related to selecting port 1
or port 5. This all seems not needed (any more), but broader testing is
advised. This being stripped from the code, the mentioned error from Qt
persisted. That is strange in itself, as we did not reference port
numbers any more.

Step 2 in this commit is actually using an uuid to the call to
connectToService. Choosing an uuid seems relatively straightforward as
we can use the same one we already use for Android. That is the default
BT RFCOMM Serial Port Profile uuid. Interestingly, when changing to this
uuid we run immediately in a Qt runtime error telling us "QDBusPendingReply:
type ManagedObjectList is not registered with QtDBus.". For these 2
unexpected Qt messages, QTBUG-72742 was made. Studying the Qt source
code at this point reveals a possible workaround. Simply create a local
QBluetoothLocalDevice object, which, behind the scenes registers the Qt
internal ManagedObjectList with QtDBus.

In the meantime, Qt agrees that QTBUG-72742 is valid, and that a fix is
to be expected in a future version. At that point in time, the
declaration of the QBluetoothLocalDevice can be deleted again.

In the end, interfacing over BT works again.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-27 15:15:07 -08:00
Jan Mulder
ffec5f4991 Bluetooth: all states other than HostPoweredOff qualify as valid
This is an attempt to fix issue #1896. While this seems a Qt issue in
combination with very specific Android devices, this might be a fix. Do
not check for a very specific state of the local BT controller, but just
check if it is powered on.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-23 21:43:57 +01:00
Berthold Stoeger
99d29a7838 Cleanup: remove unused parameter was_autogen
In commit 6bf4120dbb the trip-flags
were replaced by a simple boolean. This made the was_autogen
parameter to the remove_dive_from_trip() and unregister_dive_from_trip()
functions unused. Remove these parameters.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-23 20:00:45 +01:00
Dirk Hohndel
6ba1cf8cf7 core: recognize Oceanic Pro Plus X over BLE
Just like with the Aqualung i770R in 7697003498 this name follows the
pattern of a model number in ASCII encoding, followed by the serial
number of the device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 12:41:43 -08:00
Berthold Stoeger
bfe69239df Import: unglobalize downloadTable
To make data flow more clear, unglobalize the downloadTable object.
Make it a subobject of DownloadThread. The difficult part was making
this compatible with QML, because somehow the pointer to the
download-table has to be passed to the DiveImportedModel. Desktop would
simply pass it to the constructor. But with objects generated in QML
this is not possible. Instead, pass the table in the repopulate()
function. This seems to make sense, but for this to work, we have to
declare pointer-to-dive-table as a Q_METATYPE. And this only works
if we use a typedef, because MOC removes the "struct" from "struct
dive_table". This leads to compilation errors, because dive_table is
the symbol-name of the global dive table! Sigh.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
abf942f303 Cleanup: make DCDeviceData a "normal" singleton
DCDeviceData was using that weird pattern where the instance
variable was set in the constructor. There is no apparent
reason to do so, therefore convert to a "normal" singleton.

Access that directly in QMLManager instead of saving it in
a member variable first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
6184f5d276 Core: remove count_dives_with_*() functions
The simplified filter-widget doesn't present lists of existing values
with counts. Thus, a whole slew of count_dives_with_*() functions
can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:33:45 -08:00
Robert C. Helling
ac8db01873 Show average max depth in yearly statistics
this was requested in #1854 and I think this suggestion makes sense

Fixes #1854

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-12-17 12:18:26 +01:00
Berthold Stoeger
c64c9c923b Cleanup: detangle unregister_dive() and delete_single_dive()
These two functions were called in different contexts:
- unregister_dive(): from the undo-commands to remove the dive
  from the global dive table, but not delete it. The dive was
  already removed from its trip.
- delete_single_dive(): from non-undo code. Most of it not in
  use and removed in a sibling-commit. Here, the dive is supposed
  to be removed from its trip and a new selection is calculated.

delete_single_dive() calls unregister_dive(), which removes the
dive from its trip. Move remove_dive_from_trip() from the former
to the latter and make both functions independent. Instead
of deleting the dive explicitly in delete_single_dive(), call
the delete_dive_from_table() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:29:31 +08:00
Berthold Stoeger
dfd7f98129 Core: don't remove dive from trip in add_dive_to_trip()
All callers of add_dive_to_trip() work on freshly generated dives,
with one exception, that was redundant anyway. Therefore it is not
necessary to remove the dive from a potential previous trip. Move the
responsibility of removing the dive from a trip to the caller,
respectively remove the redundant call. Add a warning message in the
case that trip is set.

Background: On import (either download or file-import) we might not
want to add trips to the global trip-list. For example to enable undo
of import but more generally to detangle that data flow. Thus,
add_dive_to_trip() should not mingle with the global trip-list,
which it has to do if a trip is deleted because the old dive was
removed.

Analysis of the add_dive_to_trip() callers:

1) core/dive.c

pick_trip():
    called on freshly generated merged dive.

finish_split():
    called on two freshly generated split dives.

2) core/divelist.c

create_and_hookup_trip_from_dive():
    called on freshly downloaded dive in dive_cb().
    called on freshly downloaded dive in record_uemis_dive().

autogroup_dives():
    called on dive from get_dives_to_autogroup(), which only
    finds dives that are outside of trips.

combine_trips():
    unused - removed in sibling commit.

try_to_merge_into():
    this call was actually erroneous - dive was already added
    to trip in try_to_merge(). Remove call.

3) core/libdivecomputer.c

dive_cb():
    called on freshly downloaded dive.

4) core/uemis_downloader.c

record_uemis_dive():
    called on freshly downloaded dive.

5) core/load_git.c

create_new_dive():
    called on freshly allocated dive.

6) core/parse.c

dive_end():
    called on freshly parsed dive.

7) desktop-widgets/command_divelist.cpp

DiveListBase::addDive():
    called on dive which is newly added to core.

moveDiveToTrip():
    called on dive that was removed from trip a few lines above.

8) mobile-widgets/qmlmanager.cpp

QMLManager::undoDelete():
    called on dive where divetrip was reset in the previous line.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:29:31 +08:00
Berthold Stoeger
662dd823fd Cleanup: remove split_dive_*() functions
In 302f6adb79 dive-splitting was made
undo-able. To this goal, the dive-splitting functions were split in
two types: Those that operate directly on the divelist and those that
only allocate the dives. The former are not in use anymore, therefore
remove them. Since only the latter remain, remove the "_dont_insert"
appendix of the name.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
10c20babae Cleanup: remove merge_two_dives() function
In 014c04f8bd merging dives was included
in the undo-system. This made the merge_two_dives() function caller-less.
Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
a597929c10 Cleanup: remove remove_autogen_trips() function
In f427226b3b autogrouping / removal
of autogrouping was moved into the undo-machinery. This made the
remove_autogen_trips() function caller-less. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
0a3d757aab Cleanup: remove combine_trips() function
In f427226b3b a combine_trips_create()
function was introduced that combined trips without deleting the old
trips. This was necessary for making combine-trips function undo-able.

The old combine_trips() function is not used anymore. Therefore remove
it. Rename the combine_trips_create() function to combine_trips() as
no differentiation is needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00