This functionality never came to be and there are fundamentally
different plans floating around. Therefore, remove these empty
files.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In commit 62d87e9d25 ("Planner: handle zero
length segments when replanning") a change to libdivecomputer snuck in that
undid the addition of Shearwater Peregrine detection.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
User request: when entering a cylinder type, do a substring
search. For example, when entering "100" also find "AL100".
Currently, a starts-with search was used.
This is simply done by setting the "filterMode" of the
ComboBoxDelegate to "Qt::MatchContains".
Suggested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The function was called on a freshly copied dive, which has its git cache
invalidated automatically in copy_dive().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
delete_divecomputer had legacy code, which
1) invalidated the git dive cache
2) made sure that the dive computer was not displayed anymore
However, both callers called on a freshly copied dive, which
has its dive cache invalidated in copy_dive() and can't be
the currently displayed dive. Therefore, this code is dead
code and can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is a number_of_computers() function which does
the same thing with two exceptions:
1) checks for null-dive
2) returns an unsigned int
Replace calls to count_divecomputers() by calls to number_of_computers().
In one case, the return type makes a different - add a cast to int there.
Ultimately, we should probably change the dc_number to signed int
throughout the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When planning a dive, dc_number was set to 1, which actually is
the second dc! The code seems to handle this gracefully, however
it appears weird. Let's set dc_number to 0 instead.
Originally, the assignment was introduced in a422957cd6
and moved later in 4f5621c4c6.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This helper function is not used outside taxonomy.c anymore.
Let's hide this implementation detail.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of getting the index and using that to access values, use
the taxonomy_get_value() helper function. Two places are affected:
1) reverse geo-lookup
2) location filter delegate
The behavior of reverse geo-lookup is changed slightly: now an
empty string is likewise recognized as missing "TC_ADMIN_L3".
Before, only a missing category was interpreted as such.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is the counter-part to taxonomy_set_value(). Let taxonomy_get_country() be the
first user of the function. If a category doesn't exist, return NULL.
Small addition: make taxonomy_get_countr() take a const argument.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
get_dive_country() was essentially a reimplementation of taxonomy_get_country().
Let's just use the already existing function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of recoding the "search for category" loop, reuse the already
existing functionality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The alloc_taxonomy()/free_taxonomy() interface was exceedingly strange.
The former gave a "struct taxonomy", the latter took a "struct taxonomy_data".
To make things worse, is appears as if the names "taxonomy" and "taxonoma_data"
are reversed: the latter contains the former.
In any case, the alloc_taxonomy() call is not needed anymore from outside
taxonomy.c, as these memory-management details are now hidden in accessor
functions. Therefore, make the function local to taxonomy.c. Moreover,
rename it to "alloc_taxonomy_table()" and let it take a "taxonomy_data"
structure for symmetry with "free_taxonomy()".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of manipulating the taxonomy structures directly, use the
taxonomy_set_category() function. This improves encapsulation and
gives us the possibility to improve the taxonomy data structures.
This concerns three places:
1) git parser
2) XML parser
3) reverse geo-lookup
This improves the XML parser code slightly: The parser assumes that
the value-attribute comes last (after origin and category). While
it still does that, it now at least generates a warning if it encounters
a value-attribute without origin- or category-attribute.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions were taking a const char *, yet taking ownership
of the value. Moreover, taking ownership of strings is rather
unusual in C-style APIs. Let's copy the string instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Setting a taxonomy category was cumbersome: the caller had to
make sure that the category-table was allocated. Introduce
a helper function to make that simpler.
Make taxonomy_set_country() the first caller of the new function,
since it is just a special case with category = TC_COUNTRY.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When overwriting a country, the old string was not freed. Fix this.
Contains an unrelated coding-style fix: use braces if code block
contains more than one line.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This adds a common macro to convert salinity (which is
given as a density in terms of g per 10l) to a specific
weight with units of mbar / mm = bar / m that is used
to translate between pressures and depths.
The weired factor of 10 (from the unusual unit of salinity)
is included in the macro. It is there for historical reasons,
as it goes back to 05b55542c8 from 2012 where it was introduced
in code for downloading from Uemis dive computers.
Now, salinity appears in too many places to easily remove
this unconventional factor of 10 everywhere without breaking
to many things (including various dive computer downloads).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Some remote dive sites have no populated places (towns, cities)
nearby. For such sites, we now fall back to looking up
unpopulated place names, such as the reef or island name.
Also some code refactorisation:
the actual network access is now encapsulated in its own
function removing some duplicated code handling in the
reverseGeoLookup function and making it more readable.
Furthermore, reverseGeoLookup() was completely refactored as
most of its functionality was due to legacy requirements; the
current code-base only calls this function from a single
location and only with an empty taxonomy_data object. This
makes the function more focussed and much simpler and more
readable.
Finally, a resource leak in reverseGeocde introduced in
4f3b26f9b6 was fixed.
Signed-off-by: Michael Werle <micha@michaelwerle.com>
Dives for the seac action computer are imported by the seacsync
program into two tables in an sqlite3 database.
The dive information is read from the headers_dive table.
The dive_data table is then queried for each dive to get samples.
The seac action computer is the only current supported computer
by the seacsync program. It only supports two gas mixes, so the
parser will toggle between two cylinders whenever it detects a
change in the active O2 mix.
Dive start time is stored in UTC with a timezone offset.
A helper function to read this was added to qthelper.
Default cases have been added to some switch statements
to assist in future development for other dive types and
salinity.
Example database has been added to ./dives/TestDiveSeacSync.db
Signed-off-by: James Wobser <james.wobser@gmail.com>
When plotting the profile in higher resolution for export,
increase the icon size in the same way.
This is commented out for the mobile version as that
uses printMode for profile display.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The way we export the profile image (as direct export but
also used for printing) is that we render the profile
from the screen to a Pixmap and save that to a file. Unfortunately
this results in very bad resultion and a blurred image.
This is an attempt to improve that situation but it's still far
from perfect: Rather than a QPixmap and grab, I now use a QImage
(where I can set the size) and render, and indeed the picture resolution
(when vied at fixed size) get's better this way. The disadvantage
is that icons get smaller at the same rate und so
there is a natural limit on how big we can get. Maybe somebody
with better Qt knowledge can take off from here. In my opinion
this is already a step in the right direction.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
You need a better resolution to plot a picture with high resolution...
Connection done with a lambda expression thanks to @dirkhh.
Signed-off-by: Robert C. Helling <helling@atdotde.de> (+1 squashed commit)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't really expect to get Nº of dives greater than the biggest
integer value.
Signed-off-by: Salvador Cuñat <salvador,cunat@gmail.com>
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
WLog is a Win32 based ancient shareware program whose target was:
1) fully support divelogs coming from DataTrak (DOS or Win)
2) fill some meaningful data which wasn't supported by Uwatec software
3) have a more user-friendly GUI than Datatrak had
The problem achieving goals 1) and 2) at the same time was solved by
adding a complementary file with .add extension and - mandatory - same
base name than .log file (including directory tree).
This .add file has a fixed structure composed of a 12 bytes header,
including file type check and Nº of dives following; then a fixed 850
bytes size for each dive in the log file. Data fields size and position
are fixed inside these blocks and heavily zero padded, so they are easy
to parse.
A serious restriction imposed to the WLog user was *Do not edit the logs
with other software than Wlog*; this was due the order of dives in .log
file being the same than the order of dives in .add file. Thought you
could show a WLog divelog in Datatrak, editing it resulted in mixing all
extended data for dives following the edited one.
Thus, we have to trust files are correct and is to the user ensure this
is so. If extended data are mangled, they are mangled in WLog too and we
are not trying to fix the mess, just importing.
On the technical side, we try to be smart about tank names as neither
DataTrak nor WLog record them. So we just take the first tank in users
list matching the volume recorded in WLog.
For weights we add a translatable "unknown" string as an empty string
results in weight not being shown in subsurface-mobile (which could be a
reportable issue, BTW).
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
If a user exits the LocationInformationWidget (Edit Dive Site)
while a reverseGeocode lookup is in progress, the object's
diveSite variable is set to null.
When the reverseGeocode lookup completes, this variable is
dereferenced causing an application crash.
Signed-off-by: Michael Werle <micha@michaelwerle.com>
When the dive has no explicity salinity, our conversion
between pressure and depth assumed salt water. Make this
explicity by using the corresponding macro.
When the planner starts and no salinity is set explicity,
set the water type chooser to salt water to reflect
our default assumption.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This new option allows a user to select a new destination tank for an
existing "Gas Change" event. This is useful when Subsurface's heuristics
get tanks wrong after an import from a divecomputer. The use-case arose
from sidemount divers with air-integrated transmitters as well as carrying
a deco tank.
Signed-off-by: Michael Werle <micha@michaelwerle.com>
You cannot be at two depths at the same time (and it confuses
the planner). So give yourself at least 10 seconds.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When setting up a dive for replanning, we ignored zero length segments as those
tend to be generated by gas changes. But it is possible to enter those in the
planner and the replanning should not ignore those. So be
more clever about gas changes. Let's add 10 seconds so we are not at two depths
at the same time and help since add_stop also does not like zero length
segments (it thinks we are trying to replace a waypoint).
Fixes#2901
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Most (all?) BLE dive computers actually don't need to be paired, and some
apparently can't be paired. So let's not enforce that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While this code was added as I was trying to work through issues with a BLE
stack that turned out to be broken, the failure behavior of that device showed
that Qt doesn't like it when we start discovering the details of
characteristics while it is still busy discovering services.
So instead of handling the services as we find them, let's instead wait until
we are done discovering services and then discover the details for all those
services.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There is no need to continue to look, and at least with the Shearwater
Peregrine having the scan run while we are trying to discover characteristics
appeared to cause issues.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I can no longer reproduce the case where this rescan was necessary.
So let's remove it as it causes additional wait time for BT/BLE users on macOS.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
get_cylinder(d, i) is more readable than d->cylinders.cylinders[i].
Moreover, it does bound checking and is more flexible with respect to
changing the core data structures. Most places already used this accessor,
but some still accessed the cylinders directly.
This patch unifies the accesses by consistently switching to get_cylinder().
The affected code is in C++ and accesses the cylinder as reference or
object, whereas the get_cylinder() function is C and returns a pointer.
This results in funky looking "*get_cylinder(d, i)" expressions.
Arguably still better than the original.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The libdivecomputer internals changed for USB devices, and now we need
to scan the USB devices before calling libdivecomputer. That's the same
pattern as for USBHID and IRDA, so let's just regularize this all.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
getFormattedCylinder() is a helper function to format a list
of cylinders. It had that weird logic that it would skip
cylinders without description unless it is the first, which
would instead be written as "unkown".
The reason was the old statically sized cylinder array,
where it wasn't clear if a cylinder was actually in use.
This became obsolete when switching to a variable size
cylinder array. Firstly, all cylinders in the array were added
by the user. Secondly, we now also support dives without
cylinders, i.e. the first cylinder is not any different from
the rest.
Thus, remove the logic and format any cylinder without
description as being of type "unknown".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Quite a few little changes lately that all deserve a new nobile app
release, and each release requires an updated version number.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>