Commit graph

1601 commits

Author SHA1 Message Date
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