Commit graph

606 commits

Author SHA1 Message Date
Dirk Hohndel
bebee64ca9 Don't show localization warning unless verbose
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20 06:51:51 -04:00
Lubomir I. Ivanov
e4a9787c5e dive.h: add handling of NULL in get_dive_dc()
This line:
    dc = &dive->dc
can SIGSEGV for a NULL 'dive' pointer.
return NULL if 'dive' is NULL.

Also handle NULL 'dc' in get_gasmix() and set 'ev' to NULL.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-19 22:03:51 -04:00
Robert C. Helling
a422957cd6 Use displayed_dc instead of current_dc
current_dc is a macro that determines the dive computer
based on the current dive number. When the planner is started
from an emtpy dive list, the dive number ends up being -1 and
that doesn't produce a valid dive computer. Use the divecomputer
of the displayed_dive instead. This is done via a macro that
can also be used in two other places. Without this patch, the
planner crashed when called on an empty dive list.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-19 14:57:02 -04:00
Stefan Fuchs
7a82103c99 CNS calculation fix
Identify previous dives for CNS calculation in a similar way as it
is done for previous dives for deco calculation.
This is done to identify the previous dives dynamically when moving
around date/time of a dive in the planner.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 23:19:13 +02:00
Stefan Fuchs
4158a4c7de init_deco correctly identify previous dives and report overlapping dives
When changing the date/time of a dive in the planner the dive may end
up in a totaly new position in respect to date/time of other dives in
dive list table. It can be moved to the past or the future before or after
other existing dives. It also could overlap with an existing dive.

This change enables identification of a new "virtual" dive list position
and based on this starts looking for previous dives.
Then it (as before the change) does init the deco calculation with any
applicable previous dive and surface interval.
If some of these applicable dives overlap it returns a neg. surface time
which is then used in the planner notes to prohibit display of results.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 23:19:13 +02:00
Stefan Fuchs
ba7be8f335 plannernotes.c coding style fixes
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 17:41:42 +02:00
Stefan Fuchs
94e563a94e Minimum gas calculation: Change text colors for delta value output...
and adapt the strings for translation to s.th. which can be handled more
easily.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 17:41:42 +02:00
Stefan Fuchs
90fcfca02c Taxonomy: Don't access empty entries when printing the tags
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-17 06:12:07 -04:00
Stefan Fuchs
884e690049 Tags for geo references: Nicer look, translations and warning message
For the geo references tags update the following:
- Nicer look w/o "Tags:" text and brackets when inside location UI
- Translation for "Tags:"
- Warning message when no dive site layout categories are set

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-17 06:12:07 -04:00
Jan Mulder
4406a6ccf9 Fix Android compile error
Trivial typo only visible on Android build.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-17 10:42:42 +02:00
Stefan Fuchs
180e51a906 Tidy up code in planner.c - create_dive_from_plan()
Tidy up the code which creates the first sample for time = 0 to make
clear that the info for this does NOT come from the first planner point (dp).
No functional change.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 18:23:27 +02:00
Stefan Fuchs
f812dc5d9b Fix dump_plan debug code
This fixes some debug code to dump the diveplan which is usually
not compiled and used.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 18:23:27 +02:00
Stefan Fuchs
4fa576526f Planner creating dive from plan: No pressure for 1st sample with new gas
In the planner when a dive is created from the diveplan every first
sample with a new gas shouldn't have a pressure value added.
Otherwise the interpolation code for the pressure graph in the profile
will draw the pressure graph incorrectly.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 18:23:27 +02:00
Stefan Fuchs
3e67bfaea6 In planner prefer best_first_ascend_cylinder for gas breaks
Up to now the cylinder for gas breaks was hardcoded to first cylinder.
With this change the best_first_ascend_cylinder is used if its
O2 is <=32%.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
80a2cd7b1b Don't confuse cyl with same gasmix with best_first_ascend_gas
When calculating the dive plan in the planner don't accidently use
another gas with same gasmix instead of the gas stored as
"best_first_ascend_gas".
This is important if you have e.g. a bottom stage and back gas with
same gas mix because then you always want to start your ascent with
the gas you used in last entered dive planner point.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
df6933326d In dive.c make cylinder_renumber an external function...
instead of dc_cylinder_renumber() because it is the one which is really
useful elsewhere.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
c29456f0bb Used gas in dive planner points: Support for multiple cyl with same gas
In the planner if one adds two or more cylinders with the same gasmix
(e.g. back gas and bottom stage 18/45) the drop down and data in the
used gas column of the planner points table will be filled with a more
verbose string mentioning also the cyl number and the cyl type
description.
Makes it easier in such a case to select the right cylinder.

Introduces also a helper function which tells you if there is another
cylinder with the same gasmix as the provided cylinder.
This also has an option if it should consider unused cylinders or not.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
5b415ad8db Reverse geo lookup string for http://api.geonames.org corrected
Language selection should now work again with string "lang=xx".

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 03:43:02 -08:00
Dirk Hohndel
4d283bdd5f Android should support the Cobalt dive compouters
With an OTA adapter - sadly I can't test that. This driver opens a
specific USB device and will ignore the connection settings. It would be
better to get some visual feedback for that (in the QML UI), but I'll
leave that until this has been verified to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-15 21:31:28 -04:00
Dirk Hohndel
dd14e27820 BLE: try to enable on iOS
We can't use the localBtDevice on iOS, so hack around that and go straight to
discovery.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-14 04:32:50 -07:00
Jan Mulder
ba4058667a mobile: enable switching BT on/off during session.
This commit implements possible switching BT on and off during a session,
so not needing a restart of the app when the user forgot to switch
it on when starting the app.

For this, the following needed to be done: 1) create a handler that
reacts on local BT device status changes. 2) repopulate the connection
list in the download screen when a BT status change is detected.

Notice the subtile change of the Q_INVOKABLE btEnabled() function
to a Q_PROPERTY. This gives a nice dynamic behaviour when
switching BT on/off with the app open.

Fixes: #556

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-12 09:43:40 +02:00
Jan Mulder
fa5e685279 Add function for non-BT connection addresses
Simple rewrite of a piece of code separated to its own function
so that is can be used in other places as well. To avoid code
duplication for dynamic BT on/off switching on mobile.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-12 09:32:12 +02:00
Jan Mulder
8b8863b640 Add function to clear connectionModel data
Preparation primarily for mobile. When we want to switch in
one session from BT to cable connection and vise versa, we
need a way to clear the model data containing the possible
connections in use.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-12 09:32:12 +02:00
Lubomir I. Ivanov
56e755b711 Use lrint() for all degrees_t related rounding
In certain places the '(int)' cast is used, while in other the
llrint() or lrint() functions. Make the conversation from degrees
in the 'double' form to the 'int' degrees_t consistent using lrint().

lrint() is the function which should give the best results,
because it accepts a 'double' and results in a 'long'
even if degrees_t is 'int'. If the truncation from 'long' to 'int'
is discarding some of the precision then the next step
would be to turn degrees_t into a 64bit signed integer type.

Possible fix for #625.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-09 13:38:58 +03:00
Stefan Fuchs
78cda85444 Display units in dive list table based on prefs option
Add a preferences option which enables or disables display of units in the
main dive liste table.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-09 11:49:29 +03:00
Rick Walsh
f9d05a8038 VPM-B profile: calculate parameters when in planner mode
Calculating parameters when in the planner mode is necessary to display the correct ceiling.

Fixes #601

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-10-08 23:16:40 +02:00
Miika Turkia
04785f3c8b Fix crash when text empty
Exporting to divelogs.de triggered this bug when divesite name is empty.

Fixes #656

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-10-08 19:41:54 +03:00
Miika Turkia
6573132307 Store RBT value on DivingLog import
Fixed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-10-07 22:38:49 -07:00
Linus Torvalds
d5a0184f71 Fix divinglog import temperature truncation
The code incorrectly divided the temperature by 10 as an integer,
causing unnecessary precision loss due to truncation.

Fix it, and update the test results for the now improved temperature
import.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 14:52:57 -07:00
Linus Torvalds
03b10383c9 Fix divinglog import limit checking
The divinglog import did horrible things with the strings returned from
the sqlite queries, and ended up using uninitialized values at the end
of the secondary profile data strings.

This rewrites the import logic to track the length of the strings
properly when importing the divinglog data.

We should run 'valgrind' a whole lot more than we do, I suspect.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 14:52:48 -07:00
Dirk Hohndel
56c82081a5 Make compile succeed without BT_SUPPORT
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 10:06:47 -07:00
Dirk Hohndel
7aacaf60da Move ConnectionListModel into its own source file
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 10:06:47 -07:00
Miika Turkia
e78f89b0d8 Safeguards for Liquivision import
I have received one sample log where after parsing a bunch of dives
properly, the sample count hits zero, and after that it is astronomical.
In case of zero, the only data we have is dive date and time of a
duplicate dive that we already parsed with proper dive profile. So
preventing a crash with this hack without properly understanding the
weird file format.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-10-07 08:36:10 -07:00
Dirk Hohndel
3278953f86 Fix two bugs in taxonomy_set_country
The random coincidence that this code actually ended up working
in my tests is weird.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 08:16:53 -07:00
Subsurface
30be43c311 Merge pull request #641 from Subsurface-divelog/taxonomyCrashFix
Taxonomy crash fix
2017-10-05 22:27:02 -07:00
Dirk Hohndel
80e6032f6f Prevent crash when adding country to dive site
We need to make sure that the taxonomy information has been allocated
before assigning values to it...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-05 15:42:46 -07:00
Lubomir I. Ivanov
90674cf7f8 divesite.c: use NULL instead of 0 for char* buffers
Makes it clearer that these are buffers and not integers
like `ds->uuid`.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-05 12:06:13 -07:00
Lubomir I. Ivanov
d96c47a1b9 divesite.c: prevent double free()
Reported-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-05 12:06:13 -07:00
Stefan Fuchs
c127a92e8e Explicitly copy a cylinder which was marked as "unused" in the planner
When planning a new dive (not replan!!!) based on an existing (planned)
dive, the cylinders from the existing selected dive are copied.
This patch guarantees that cylinders which had been marked as "unused"
are indeed copied as well. Sounds strange at the first moment but makes
sense because if one marks a cylinder explicitly as "unused" in the
planner instead of deleting it that does mean that one wants to keep
this cylinder to have it available and be able to reenable it later-on.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-05 20:32:35 +02:00
Dirk Hohndel
b19db6afb5 White space and clarifying braces
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
9162dee8a1 Whitespace change
This is just the indentation change for the code that was inside the
loop before.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
09b02aae4e Simplify the geo reverse lookup function
We never actually create a list of dive sites for which we
call the reverse lookup service, it's always just displayed_dive_site.
So make this all much simpler and just go straight for that.

This commit removes a loop, but doesn't change the indentation of the
code inside the loop to make it easier to see what was changed. That
whitespace change will be in my next commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
ed78aeade0 Change the signature of constructLocationTags
We actually want to be able to pass a specific divesite structure
and not have it look that up by uuid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
b96633d3e9 fixup taxonomy type
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
21d78121ad Don't add separate country field, use taxonomy
The more I looked at the code that added the country to the dive site,
the more it seemed redundant given what we have with the taxonomy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
de10fd4021 Add taxonomy copy helper function
We don't want to just be able to copy all of a dive site.
Sometimes we might want to be able to copy just the taxonomy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
9fd6b3eefb Add taxonomy helper functions
Right now we just want direct access to the country, I assume
we'll add more like this in the future.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Robert C. Helling
a163bbc442 When finding deepest ceiling, do not round to multiples of 3m
Fixes #630

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-04 12:34:16 +03:00
Stefan Fuchs
8786003c11 Planner minimum gas calculation: Print delta pressure in results
Print the delta between the required minimum gas result and the cylinder
pressure at last bottom datapoint in results.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-04 08:46:14 +02:00
Tomaz Canabrava
e1bd006cd6 [Divesite] request dive country
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 09:52:50 -07:00