-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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
-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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>