Commit graph

2052 commits

Author SHA1 Message Date
Martin Měřinský
dcf2542215 Use abbreviations with dots. 2017-03-11 08:09:07 -08:00
Martin Měřinský
a9d361574e unkn > unknown 2017-03-11 08:09:07 -08:00
Martin Měřinský
9b93397ec2 SAC: %.*f%s/min versus SAC:%.*f %s 2017-03-11 08:09:07 -08:00
Robert C. Helling
eae4bd82a5 Change type of divedatepoint.depth to depth_t
... for consistency, while we are at it.

There are still some internal depth variables which are ints
somebody might take a go at those.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-11 08:03:25 -08:00
Robert C. Helling
295b1b78d8 Make depth conversion work for negative depths
This is needed in the altitude pressure conversion as there
negative altitudes are possible (for diving in the netherlands
or the Dead Sea).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-11 08:03:25 -08:00
Stefan Fuchs
8a4d3876d6 Disable minimum gas calculation for recreational mode
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 08:01:35 -08:00
Stefan Fuchs
7f8c3592ce Minimum gas calculation - Calculations and UI parameters
Add minimum gas calculation to planner output.
Add the two UI parameters prefs.sacfactor and prefs.problemsolvingtime.
Connect UI signals and slots for recalculation of diveplan.

Disable minimum gas calculation if there was already a warning before.
If minimum gas result is larger then cylinder start pressure give warning message instead of result.

Add line break before pO2 warnings but only if warnings exist.

Signed-off-by: Joachim Ritter <jritter@bitsenke.de>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 08:01:35 -08:00
Jeremie Guichard
2b06a0b223 Fix potential double/float to int rounding errors
Not using lrint(f) when converting double/float to int
creates rounding errors.
This error was detected by TestParse::testParseDM4 failure
on Windows. It was creating rounding inconsistencies
on Linux too, see change in TestDiveDM4.xml.

Enable -Wfloat-conversion for gcc version greater than 4.9.0

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-09 23:07:30 +07:00
Jeremie Guichard
406e4287eb Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-08 14:04:17 +07:00
Martin Měřinský
d6bfcd5245 In weights table 'weight' is redundant and no used for other types. 2017-03-07 16:22:27 -08:00
Martin Měřinský
186a80fffe Enable translate 'All' in yearly statistics. 2017-03-07 16:22:03 -08:00
Dirk Hohndel
e9debdf281 Add helper to parse duration text
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04 12:16:49 -08:00
Martin Měřinský
b14301a84c heartrate, heartbeat > heart rate 2017-03-04 12:08:17 -08:00
Martin Měřinský
fccfb968c1 Consistent 'salt water' versus 'fresh water'. 2017-03-04 12:08:17 -08:00
Dirk Hohndel
a3a23f63a6 Add subsurface_stat for Mac
Which is also used on iOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-24 01:14:39 -08:00
Jeremie Guichard
5ed93a9d9e Fix "Load/Save to cloudstorage" for non-ASCII user names
On Windows that would fail because stat() doesn't deal well with our
utf8 strings.

Added new subsurface_stat() portability function to replace stat().
Added Windows implementation of subsurface_stat() using wstat(),
with conversion to ut16 of the inputed path.
Other platform implementations (linux, android) make use of the normal stat().

Added non ASCII test case in TestGitStorage::testGitStorageLocal()

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-02-24 01:10:22 -08:00
Dirk Hohndel
da50bb1ae5 Dive merge: don't pick an empty dive site
When merging, we should treat an empty dive site (which will be deleted
on save) the same as not having a dive site.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-21 18:22:56 -08:00
Robert C. Helling
dbd99f706e Many filenames are const strings
So we can use string constants for those

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-21 13:14:56 -08:00
Stefan Fuchs
b39b641a05 Translate names of additional dive events and nicer format info box text
Enable translation for a few additional internal dive events.
Ensure that all event names in datatrak.c are collected for translation.
Ensure that for gaschange in profile info box the "cyl." string is also translated.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-02-21 13:11:19 -08:00
Martin Měřinský
c272c57b5e Unknow > Unknown 2017-02-21 07:03:10 -08:00
Linus Torvalds
2e77a22e2c Fix dive site string merging
If the second dive site doesn't have a particular string, but the first
one does, we did the wrong thing and created a result string like

   (first dive site string) or ((null))

which is not useful.  We should just use the first dive site string
as-is.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-19 17:38:34 -08:00
Robert C. Helling
bd89e33e76 Fix typo in saturation/desatureation rates
This patch eliminates the difference between the saturation and
desaturation rates. This was probably once meant as a conservative
measure but the desaturation rate was increased rather than the
saturation rate (which is probably a typo, as reported by Stefan).

Since there is no good basis for this anyway, this patch sets
both factors to 1.0 (and if accepted the whole factor business
should be removed).

This makes our deco times slightly longer. But in the past,
we had introduced a 1.2% fudge factor in the critical radius
calculation to add conservatism and match the benchmark better.

Removing this fudge factor brings us close to the benchmarks.
Expected test values updated.

Reported-by: Stefan <sjti@gmx.net>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-19 15:29:40 -08:00
Robert C. Helling
dc55ee4a23 Update exif.cpp from upstream
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-19 15:29:40 -08:00
Linus Torvalds
4a550e4d7d Properly handle dive sites loaded from XML
We used to always create a new dive site structure when loading dive
site data from XML.

That is completely bogus, because it can (and does) create duplicate
dive sites with the same UUID.  Which makes the whole UUID pointless.

So instead, look up the existing dive site associated with the UUID
loaded from the XML, and try to merge the data properly if we already
had dive site information for that UUID.

Reported-by: Alessandro Volpi <volpial@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-19 15:23:46 -08:00
Linus Torvalds
fc55620d2d dive merging: merge water temperature too, not just air temperature
I have no idea why we only merged air temperatures.  But it was very
explicit (even the function doing the merging was named
"merge_airtemp()"), and water temperatures were left alone.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-19 15:23:46 -08:00
Linus Torvalds
0cf4104dc6 Handle negative dates (before the epoch) better
The Qt model sorting for the dive date was using a unsigned number,
which doesn't work for dates before 1970.

Also, the dive date parsing got the year 1900 wrong.  Not that we really
care, because other parts of date handling will screw up with any date
before the year 1904.  So if you claim to be diving before 1904, you get
basically random behavior.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-17 15:08:38 -08:00
Linus Torvalds
83aff9f777 Fix crash when merging dives with a missing dive computer model
The test for the dive being a planned dive was completely bogus:

 - it should use "same_string()" which correctly checks for NULL

 - the string it checks for is obviously spelled wrong anyway.

Reported-by: Alessandro Volpi <volpial@gmail.com>
Fixes: a031dbbbd ("When merging planned dives keep all cylinders")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-15 21:46:15 -08:00
Robert C. Helling
e31714d9b2 Set up gaslist only in the beginning of diveplan
In the beginning of the diveplan, divedatapoints of zero
duration indicate available gases with the depth giving
the suggested switch depth. Zero-duration datapoints in
the middle of the dive do not have this meaning and should
thus be ignored when composing the gaslist.

The tests should have these gas defining segments in the beginning.

This fixes a problem when replanning a dive that would change
to random gases during deco.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-11 08:31:42 -08:00
Robert C. Helling
057419fa85 Always show manually added gaschanges in notes
In the manually entered part, we dont wait until the next stop.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-11 08:31:42 -08:00
Robert C. Helling
032c3258ed Reset VPM-B state between repetitive dives
This resets the maximum crushing pressures and the maximal
ambient pressure between repetitive dives to prevent anomalies
that a dive produces a shorter deco when following another one
than without.

Reported-by: sfuchs@gmx.de
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-10 06:41:24 -08:00
Linus Torvalds
0e7d8993a2 Make cylinder merging a bit more careful
This makes some further updates to the new cylinder merging code:

 - avoid re-using the cylinder if the usage type (OC/diluent/O2) is
   different between the two dives, even if the gasmix might be the
   same.

 - avoid re-using a cylinder if the user has manually added pressure
   data for it (and the pressures don't match)

 - when deciding to reuse a cylinder, make sure that we merge as much of
   the type information as makes sense.

This will potentially result in more cylinders that might need manual
cleanup, but at least we won't be throwing out user data.  And in most
cases where merging happens, none of this is an issue (because the data
comes fresh from a dive computer, and won't have been manually edited to
trigger the new rules).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-09 21:30:49 -08:00
Linus Torvalds
e2bbd0ceec Rewrite cylinder merging code from scratch
The old cylinder merging code depended on the preferred dive having all
the cylinders, and the newly merged dive was just forced to pick from
that existing set of cylinders.

That worked ok if you have a "main" dive computer that you have all the
gases programmed for, and you download that first, and then you download
any secondary data later.

But it completely messed up if the second dive computer had gases that
the first one didn't know about, and just basically ended up doing
random things.

This rewrites the whole thing to actually try to create a union of the
two sets of cylinders when merging, with sane matching so that if the
cylinders match you won't get duplicates.

Miika Turkia hit this when he only used one gas, but had several gases
defined in his OSTC that he downloaded after his Vyper (with had just
the single gas defined).

This should fix that case (at least it does for my xml merging test-case
that showed the same problem after some munging).

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-09 21:30:49 -08:00
Dirk Hohndel
f6cd21ce5a Finish removal of informational_prefs
And make export-html build again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05 12:44:11 -08:00
Joakim Bygdell
0277d5aacc Merge informational_prefs into git_prefs
There is no need to have two variables for the same purpose.

[Dirk Hohndel: changed to keep the two separate functions as otherwise
               we no longer parse existing repos successfully]

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05 12:29:51 -08:00
Joakim Bygdell
11dcae436e MOBILE: Read profile settings from git
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 11:59:47 -08:00
Joakim Bygdell
d4dbd0bee7 Save profile settings to git
In order to streamline the view between desktop and mobile we need to save
selected profile related settings to git.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 11:59:47 -08:00
Robert C. Helling
6518b0db45 Treat gaschanges at 1s as inital gas use
When the first leg in the planner is not cylinder 0, a gaschange
event at t=1s is inserted. In the profile, we should treat that
as inital gas, so no pressure information is printed for cylinder 0
that is used nominally for one second.

This fixes a problem reported by Willem.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-04 07:09:35 -08:00
Stefan Fuchs
cd38cda186 Bugfix planner output formating (linebreaks)
Changed the markup with <div> and <br> tags of the planner output in
a way that is is a good compromise for both displaying in UI and
printing.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-02-04 07:06:29 -08:00
Robert C. Helling
855995191c Don't do strcmp on NIL pointer
This is what we have same_string() for...

This prevents a crash when saving a dive in the planner.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 15:04:51 -08:00
Dirk Hohndel
db7290a915 Same typo, two more times
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 15:01:15 -08:00
Dirk Hohndel
a959e437a9 Fix typo
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 09:35:01 -08:00
Lubomir I. Ivanov
4a894e0713 Win32: add the --win32log option to log stdout and stderr to files
Adding --win32log as the first command line option on Windows
will now log all stdout and stderr output to the files
subsurface_err.log and subsurface_out.log in the working directory.

This change required a new argument 'bool logfile' to be added to:
subsurface_console_init() which is defined in all platform files
(linux.c, macos.c, etc.)

Example usage:
subsurface.exe --win32log -v -v -v

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-02-03 09:24:42 -08:00
Robert Helling
5aa9c6fa1b Do not count gas used in planned dives for statistics
This is important if in one dive we have the real dive and
a planned version of the dive as different computers using
different sets of cylinders.

[Dirk Hohndel: an early version of this was mistakenly pushed out
               by me; I reverted that and added this commit since
               fixing things up as I had done for the other two
               patches made things nearly unreadable]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:45:24 -08:00
Robert Helling
67de8f3a49 Correct: Handle more tanks than gasmixes
When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).

[Dirk Hohndel: I had mistakenly pushed out an earlier version of this
               commit, so this fixes things up to the final version]

Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:43:00 -08:00
Robert Helling
8a8315d6fe Correct "When merging planned dives keep all cylinders"
When merging a real dive with a planned dive (for comparison),
we should not try to be clever in merging similar cylinders,
rather keep the union of both cylinder sets as the two versions
of the dive might differ in exctly which gas and how much of it
was used.

Increase MAX_CYLINDERS to 20 to make room for this. We warn if we
exceed this number.

[Dirk Hohndel: I had mistakenly pushed out an earlier version of this
               commit, so this fixes things up to the final version]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:41:35 -08:00
Dirk Hohndel
08c42813e5 Revert "In statistics, ignore gas use of planned dives"
This reverts commit 1d8662006c.

Mistakenly pushed to master

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:31:03 -08:00
Dirk Hohndel
414d7f2632 Deal with some of the whitespace issues in planner.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 03:10:57 -08:00
Stefan Fuchs
fbaeeec807 Print SAC values from prefs in diveplan
Print the SAC values from preferences into the diveplan.
These are the values used for calculation of gas consumption.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 02:45:58 -08:00
Stefan Fuchs
a1c51256b2 Add ATM pressure and altitude to diveplan
Print the ATM pressure and the altitude used for calculation into the resulting diveplan.
Moved this info together with the deco model info below the runtime table.
There is one drawback in this implementation: Altitude will be recalculated from surface pressure and therefore may differ slightly from altitude entered in the UI.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 02:45:30 -08:00
Robert C. Helling
1d8662006c In statistics, ignore gas use of planned dives
When merged with real dives, those would double count otherwise.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-02 12:37:24 -08:00
Robert C. Helling
a031dbbbd8 When merging planned dives keep all cylinders
When merging a real dive with a planned dive (for comparison),
we should not try to be clever in merging similar cylinders,
rather keep the union of both cylinder sets as the two versions
of the dive might differ in exctly which gas and how much of it
was used.

Increase MAX_CYLINDERS to 20 to make room for this.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-02 12:36:08 -08:00
Robert C. Helling
99595542ec Handle more tanks than gasmixes
When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).

Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-02 12:35:58 -08:00
Robert C. Helling
bb86d13546 Initialize the surface time
Otherwise we return garbage when there is no dive in the dive list.

Closes #184

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-01 14:43:27 -08:00
Robert C. Helling
c1dc0c9ce0 Allow user to disable a cylinder in planner
In the cylinder table, the last column ("use") always showed
OC-GAS. Editing was enabled, but the user had to guess to enter
a small integer meaning dilluent or CCR oxygen cylingder. I guess,
nobody has ever done that.

This patch makes this column clickable. A click toggles if the cylinder
is used for planning or not. This wait it is much easier to investigate
the consequences of gas loss on a plan.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-23 22:11:51 -08:00
Dirk Hohndel
b15b3c195c QML UI: allow magic phrase for multiple buddies to be localized
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-22 18:20:03 -08:00
Linus Torvalds
e1ee577c4f Make event string translation when downloading from libdivecomputer more obvious
We had hardcoded the exact translation of the event numbers.  They
haven't changed (although we did have what appears to be a spurious
entry for "non stop time" at the end that libdivecomputer doesn't have
an enum for).

Instead, use an explicit array index initializer array, so that it's
obvious that the two match up (and if the sample event numbers ever
change, we should cope with it gracefully).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-17 09:15:50 -08:00
Linus Torvalds
fe5f15bdc5 Add support for libdivecomputer using DC_SAMPLE_GASMIX
New libdivecomputer versions use DC_SAMPLE_GASMIX to indicate a gas
change (which contains the cylinder index we're changing to) rather than
SAMPLE_EVENT_GASCHANGE*.

Unlike the old GASCHANGE model, and despite the name, DC_SAMPLE_GASMIX
does not actually say what the mix is, it only specifies a cylinder
index.  We had already extended SAMPLE_EVENT_GASCHANGE2 to have the
cylinder index in the otherwise unused "flags" field, so this is not all
that different from what we used to do.

And subsurface internally already had the logic that "if we know what
the cylinder index is, take the gas mix from the cylinder data", so
we've already been able to transparently use _either_ the actual gas mix
or the cylinder index to show the event.

But we do want to make it an event rather than some sample data, because
we want to show it as such in the profile.  But because we are happy
with just the cylinder index, we'll just translate the DC_SAMPLE_GASMIX
thing to the SAMPLE_EVENT_GASCHANGE2 event, and nothing really changes
for subsurface.

libdivecomputer has made other changes, like indicating the initial
cylinder index with an early DC_SAMPLE_GASMIX report, but we've seen
that before too (in the form of early SAMPLE_EVENT_GASCHANGE events), so
that doesn't really end up changing anything for us either.

HOWEVER, one thing that is worth noticing: do *not* apply this patch and
then use an old libdivecomputer library that sends both the
DC_SAMPLE_GASMIX samples _and_ the deprecated SAMPLE_EVENT_GASCHANGE
events.  It will all *work*, but since subsurface will take either,
you'll then get duplicate gas mix events.

It's not like that is in any way fatal, but it might be a bit confusing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-16 17:45:00 -08:00
Robert C. Helling
7725842383 Use real gas compressibility in planner
Modify formluas for gas use to take into account the
compressibility correction for real gases. This introduces
also the inverse formula to compute the pressure for a given
amount of gas.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-16 03:17:40 -08:00
Dirk Hohndel
1ab6e7fc8a Prevent crash on Mac when typing comma in GPS coordinates field
Our attempt to skip any white space after the comma causes an ASSERT (strangely
only on Macs).

This closes #158

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-14 09:09:58 -08:00
Linus Torvalds
638e7fb28f Add cylinder equipment tooltips with gas volume
This adds tooltips for the equipment tab for each cylinder, showing the
amount of gas used.

When you mouse over the size and working pressure fields, the tooltip will
show the amount of gas used (along with start and end gas volumes). And
when you mouse over the start and end pressures, it will show the start
and end gas volumes, and the Z factor used.

I started doing this because of the gas volume questions in the last day
or two (and a few from a few weeks ago). When even Robert Helling starts
wondering about the effects of compressibility on the SAC calculation, our
numbers are clearly too opaque.

With these tooltips, at least you can see what went into the used gas
calculations, instead of having to add debugging options to print out Z
factors.

[ This patch also adds a "rint()" to get the rounding right in the
  gas_volume() function.  Although rounding to the nearst milliliter
  really doesn't matter, it's the right thing to do after doing FP
  calculations ;^]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-12 14:17:09 -08:00
Anton Lundin
48b2b3d0b3 ostctools: Add support for profile version 0x24
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Anton Lundin
983561b353 ostctools_import: Switch to using dc_parser_new2
Instead of creating the individual parsers, and keeping track of their
arguments, this just uses the "new" dc_parser_new2 function ment for
buffer parsing.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Anton Lundin
70e2404492 Stop accessing the internals of dc_descriptor_t
This removes our own declaration of dc_descriptor_t and all our accesses
to its internals, and switches to use the libdivecomputer functions to
access those instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Anton Lundin
d11dfd2f45 ostctools: Correct argument order to get_descriptor
This corrects the argument order, which was changed back in
00629c861c, but not on this place. Whups.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Miika Turkia
aaa46c2465 Add some additional parameters to help text
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-06 20:44:02 -08:00
Robert C. Helling
935734100f Rename prefs.deco_mode to prefs.planner_deco_mode
This is to avoid confusion with planner.display_deco_mode.
When accessing the "current deco mode" use the decoMode()
helper function.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
bb4bf639c3 Fix deco_mode confusion
We have two prefernces determining the deco_mode (BUEHLMANN vs VPMB
vs RECREATIONAL): One for the planner (deco_mode) and one for
displaying dives (display_deco_mode). The former is set in the planner
settings while the latter is set in the preferences.

This patch clears up a confusion which of the two to use by introducing
a helper function that selects the correct variable.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
43599742a3 Display surface interval in diveplan
...instead of just stating "repetitive dive". As requested by
a user.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-03 22:28:18 -08:00
Miika Turkia
8766054581 Hooking up av1.xslt for log import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2016-12-31 09:56:08 +02:00
Robert C. Helling
10b8bda662 Fix picture hashing logic for pictures on the web.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2016-12-30 19:43:00 +01:00
Anton Lundin
38474f2d47 android: Add a subsurface_user_is_root for android
This is to compile the desktop ui for android

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-28 22:40:18 -08:00
Anton Lundin
3b884c2e7c Use get_descriptor instead of hard-coded switch's
This starts using the newly lifted out get_descriptor in configure dive
computer, instead of previously hard-coded out of date
switch-statements.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-28 22:40:18 -08:00
Anton Lundin
00629c861c Rename ostc_get_data_descriptor to get_descriptor
This renames and cleans up ostc_get_data_descriptor into get_descriptor,
for more generic use.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-28 22:40:18 -08:00
Anton Lundin
db8e786f85 Lift ostc_get_data_descriptor out from ostctools.c
This is for later reuse of that function in other source files.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-28 22:40:18 -08:00
Tomaz Canabrava
27b4ef321a Correctly open the resource file
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-27 08:27:21 -08:00
Robert C. Helling
3e4ea9e084 Get rid of debug messages
...that managed to sneak in in a previous commit.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-26 13:09:05 -08:00
Robert C. Helling
c1ef59c540 Indicate a repetitive dive in the diveplan
Fixes #1095

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-26 12:47:57 -08:00
Robert C. Helling
1ab5db3726 Empty image hashes are not valid
I don't know how those arose in the first place, but an
empty QByteArray is never a valid hash value for an image. So
we should not store those in our translation tables and also
get rid of them when loading the tables from disk.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-04 05:37:16 +09:00
Robert C. Helling
f03acb9e9a Fix effective GFs in notes
This patch fixes two bugs:

1) It first computes the effective gradient factors and then
composes the notes with the diveplan rather than the other way
around.

2) It does not try to fit a line through a single point.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-04 05:32:08 +09:00
Robert C. Helling
4d0d37b690 Show effective gradient factors for VPMB-plans
For each stop, this computes an effective gradient factor
that gives the same ceiling. Then, it does linear regression
to find values for GFlow and GFhigh that give a similar deco
profile.

Note that this optimises the average gradient factor. The
runtime however depends strongly at the gradient factor at
the last depth. So we don't necessarily to get the runtime
right.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-24 09:59:42 +09:00
Robert C. Helling
d1a0655613 Show runtime on top of diveplan
This is central information when planning a dive but often
scrolled out of the window for longer plans. So print it on
the top.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-24 09:59:32 +09:00
Robert C. Helling
20e211d337 Only consider non-zero average depth for statistics
Upon importing dives, the average depth can be undefined which we store as 0.
This zero should not contribute when computing the average depth for
the (yearly) statistics, only dives with average depth set now contribute.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-15 03:25:46 -08:00
Dirk Hohndel
9006802f72 Clean up some warnings in file.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-09 06:33:45 -08:00
Miika Turkia
66d9cc788c Parse multiple dives from single DL7 log file
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-09 06:29:24 -08:00
Anton Lundin
2497ecf16d configure ostc3: Correct typos
This fixes a copy-paste error made by me that caused
tempSensorOffset to first be set the wrong way and then overridden by
pressureSensorOffset.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-07 21:08:28 -08:00
Tomaz Canabrava
37e3e7e69a Deco mode for plannining is not deco mode for showing
We had (in the wrong place, imo) a new feature that
should differentiate the different deco_modes, you could
plan your dive in buelhman and see it in vpm-b, for instance
but both of them accessed the same pref.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:41:17 -07:00
Tomaz Canabrava
c110b4a238 More preference handling fixes
Remove a few uneeded lines and add more loading code for
the preferences.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:40:43 -07:00
Tomaz Canabrava
ce8f621623 on first run, use system language.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:39:45 -07:00
Tomaz Canabrava
5da23065d6 Use default prefs for the prefs that where missing
This patch fixes all the cases that I didn't checked for
the default prefs.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:39:17 -07:00
Tomaz Canabrava
1dddf731ee use GET_* macros for getting settings
Those macros are nice because they take into consideration
the default preferences.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:39:08 -07:00
Tomaz Canabrava
da2c6b208f Load use_system_language
Forgot to load use_system_language, wich borked the preferences.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:38:49 -07:00
Tomaz Canabrava
fdb48f9efb Remember to load the language
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:38:21 -07:00
Tomaz Canabrava
df2dfa4706 Fix bug where the Font setting was ignored
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:37:52 -07:00
Tomaz Canabrava
92272311bf Preferences tests: fix Update Manager date loading
Date loading was incorrect, this unittest + fix deals with that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:34:47 -07:00
Tomaz Canabrava
3966f3e7dd Preferences tests: location updates & bug fix
Fixed loading the location preferences.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:34:47 -07:00
Tomaz Canabrava
540075962c Correctly load the language based prefs
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-28 07:31:50 -07:00
Tomaz Canabrava
d7f339ade7 Load system Language
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-28 07:31:34 -07:00
Tomaz Canabrava
324b1d2dfc Fix default file behavior tests
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-28 07:31:17 -07:00
Tomaz Canabrava
eb6f9e263c Remember to look for the Group
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-28 07:30:39 -07:00
Rick Walsh
ebddf95252 ToolTipItem: show gf line based on correct gradient factor preferences
Calculate gfline using the gradient factor that is set by the planner
preferences when in the planner, and by the general prefs when not in the
planner. This is achieved by doing the gradient factor calculation in dive.c,
where buehlmann_config is defined.

Previously, the gfline was calculated using the general preferences gfhigh and
gflow, even when in the planner.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-27 20:36:14 -07:00
Tomaz Canabrava
713dd26d6c Added language testcase
Also, added a missing method / property

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-18 11:13:37 -07:00
Tomaz Canabrava
a42b05578f Tests for Units Preferences
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-18 11:12:33 -07:00
Tomaz Canabrava
9c4b0170bf Make all current written tests pass
Fixes a couple of issues with the tests.
Also, a type in prefs.h is "short" while it's actually
a boolean, this made me write the wrong testcase for this.

Fixed this by setting the Qt wrapper to bool, but I didn't
changed the c implementation because I tought I could break
something.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-15 12:24:05 -07:00
Tomaz Canabrava
c1fbc70d83 Update a few tests, implement Planner
Also, fixed a typo that caused a bug.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-15 12:22:52 -07:00
Tomaz Canabrava
8cd4255a28 Test planner settings
Plus: fix a typo.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-15 12:22:28 -07:00
Tomaz Canabrava
256d16a540 Test geologation
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-15 12:21:32 -07:00
Robert C. Helling
0d20344c90 Add preference to change deco model
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-11 21:58:41 -07:00
Miika Turkia
b5de08b709 No gas change event on merging dives with same gas
When merging dives, this will skip the gas change event if both dives
use same gas.

Fixes #1099

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-11 21:56:52 -07:00
Robert C. Helling
aa3067c0f8 Compute weighted Buehlmann coefficients for all deco models
... as those are needed for the heatmap and not only
for Buehlmann ceilings.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-03 12:44:16 -07:00
Dirk Hohndel
fa2fcc4024 Clean up group handling in SettingsObjectWrapper
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-25 11:01:03 -07:00
Dirk Hohndel
9b4abca9f4 Make sure we remember the dive computer vendor and model
Preferences work best if you not only write them, but read them again as
well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-25 10:34:30 -07:00
Rick Walsh
7e09a6c7bc Separate VPM-B conservatism preference for planner and profile
Separate the VPM-B conservatism preference into diveplan.vpmb_conservatism for
planning dives and prefs.vpmb_conservatism for profile ceiling display of
saved dives.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:30:11 -07:00
Rick Walsh
7b891904e7 Rename conservatism_level to vpmb_conservatism
Make the variable purpose less ambiguous

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:29:56 -07:00
Dirk Hohndel
f4ca863a91 Correctly pick up the UI language from settings
While Linux can set the locale from the language text, Windows needs the
correct locale value (which makes more sense to use, anyway - that's why
we save it).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-22 22:07:42 -07:00
Dirk Hohndel
78dc3a3efe Revert "Add a simple cp2130 libusb driver"
This reverts commit 93ef223a31.
2016-09-22 14:56:31 -07:00
Dirk Hohndel
5fdbc1ffc3 Language preference: once we figure out the locale, remember it
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 12:40:30 -07:00
Dirk Hohndel
743f73e4a3 Don't look up the setting again
This caused us to do the wrong thing if the setting wasn't set at all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 12:38:23 -07:00
Dirk Hohndel
a31dd6c1c0 Preferences: remember both the locale name and the user friendly text
Currently we are confused which it is we are looking at and so setting the
language is broken.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 12:35:49 -07:00
Dirk Hohndel
c809a8873c Second attempt to fix crash
Linus pointed out that it might be another call site (and looking at his
proposed patch I noticed a logic error in my earlier attempt)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 09:26:35 -07:00
Dirk Hohndel
076d8966f0 Prevent possible NULL pointer dereference
Not sure if this will fix the crash for Henrik, but it's worth
a try.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 08:47:08 -07:00
Dirk Hohndel
3ea15febfa Fix compile error on Windows
We need to return a DC_STATUS here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:41:55 -07:00
Anton Lundin
93ef223a31 Add a simple cp2130 libusb driver
This adds a simple cp2130 userspace driver. Its probably unusable in the
real world but its a great base to build upon.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:12:16 -07:00
Anton Lundin
e0fe8762c2 Fix warning about incompatible pointer
The set_halfduplex function takes a unsigned int, not a int.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:11:45 -07:00
Anton Lundin
ffa3c48593 Rewrite libdivecomputer custom serial code
This rewrites the custom serial code to use the new api which I
implemented in the Subsurface-branch of libdivecomputer.

This is a bit to big patch but I haven't had the time to break it down
into more sensible patches.

This rewrite enables us to support more ftdi based divecomputer
communication and is tested with both a OSTC3, OSTC2N and a Suunto
Vyper, all over the libftdi driver.

The bluetooth code paths are tested to, and should work as before.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17 15:47:37 -07:00
Joakim Bygdell
1219dc6931 QML UI: deal with multiple buddies correctly
When editing adive in Subsurface-mobile we can only handle one buddy
due to the limitations of the combobox. To prevent loss of data when editing
a dive with more than one buddy we display "Multiple Buddies" in the buddy
field. This creates a special case where no changes are written to the buddy field
unless the user changes buddy for that dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17 13:46:15 -07:00
Robert C. Helling
ed11dab7fb Compute total tissue saturation for all deco models
... and not just for Buehlmann. This makes the saturation
graphs meaningful for VPM-B.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17 13:43:28 -07:00
Robert C. Helling
cd99bbe727 Cosmetic changes to Buehlmann code
Change runtime table string from ZHL-16B to ZHL-16C to reflect he fact
that we use 5min as half-time for the fastest compartment rather than
4min.

Further more trade pow(2.0, ...) for exp().

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17 13:41:12 -07:00
Dirk Hohndel
80eafb8db7 Fix some warnings
At least the warnings about size potentially being uninitialized seem correct
and valid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 10:27:56 -07:00
Dirk Hohndel
830d9163dc iOS build: Fix compile failure
Without this moc_SubsurfaceObjectWrapper doesn't compile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 07:52:18 -07:00
Linus Torvalds
833683521a Stop trying to fix up pressure sensor indexes
This removes 'fixup_dc_cylinder_index()', which was added to fix up the
pressure sensor indexes from the Atomic Cobalt dive computer.

Even for the Cobalt it really shouldn't matter, because the
libdivecomputer backend for the Cobalt actually tries to do the right
thing.  See for example commit 8853a1ccd422 ("Associate the pressure
samples with the primary tank.") in libdivecomputer.

Some historical digging shows that the subsurface sample pressure index
code came in from commit e32ba4d6d8 ("Improve tank handling for
Cobalt"), dated Tue Oct 28 13:48:15 2014.

And the libdivecomputer "use the right cylinder" code was around the
same time (Fri Oct 10 20:29:17 2014 +0200).

So I suspect that subsurface needed the fixup based on an older version
of libdivecomputer.  Jef's patch is a couple of weeks before, but we may
not have tracked libdivecomputer religiously.

The reason to remove this code is because it can (and does) mess up the
sensor index when it is actually reliable, like in the multi-sensor case
of the Suunto EON Steel.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 07:37:28 -07:00
Joakim Bygdell
4e0200863b Remove hacks regarding multiple gasmixes and cylinders
Enabling cylinder edit in Subsurface-mobile our previous hacks
regarding multiple cylinders and gasmixes must be removed.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 07:36:43 -07:00
Joakim Bygdell
674d8331f5 QML UI: Enable cylinder edit
This adds the option to select a cylinder when adding or editing a dive.
Due to limited screen size we restrict the editing to the first cylinder only.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 07:36:13 -07:00
Rick Walsh
7b3665827a Settings fixup: gflow and gfhigh are int
With the recent setting cleanup, gradient factors were set to bool, so were
saved as 1/1, rather than say 50/80. This commit fixes that.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 07:29:42 -07:00
Linus Torvalds
d8a6b917a5 Teach 'interpolate()' about zero-sized ranges
No, they don't make sense.  We should normally not have multiple samples
that are on the same second.  But they seem to happen on the EON Steel
under some circumstances, and instead of dividing by zero when trying to
interpolate across such a sample, do something sane.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-29 21:43:19 -07:00
Linus Torvalds
5a66ac7698 Make sure DC_FIELD_TANK starts from a clean slate for each cylinder
We used to clear the 'dc_tank_t' for each dive, but then only clear the
volume field in between each cylinder.  That means that if the
libdivecomputer back-end does not touch a field, it might contain the
stale value from the previous tank information.

I'm not sure this is actually much of an issue, since I'd expect
back-ends do seem to initialize the fields fully (at least the EON Steel
back-end does).  But it's inconsistent.

Also, the code was actually buggy because of the odd indentation: it
would only ask for new tank information up to 'ntanks' tanks, but
because of the final fixup that was done outside of the conditional, it
would actually update the cylinder begin/end pressure data *beyond*
'ntanks', and just re-use the last libdivecomputer data for the rest of
the cylinders.

Again, in practice, that probably never really happened, but it is a
real bug.

The fixed-up code actually looks better too, imho, and is one line
shorter because of the initialization now being done in one place rather
than two.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-29 21:43:17 -07:00
Linus Torvalds
99d1cecf06 Hacky workaround for multiple gas pressures per sample
In subsurface, we only have one cylinder pressure per sample (well,
technically two: we have a separate o2 pressure for rebreather diving).

Which makes things "interesting" if the dive computer can actually have
multiple pressure sensors, and can report them all concurrently.  Like
the Suunto EON Steel.

We used to just take the last one (each sensor reading would just
overwrite any previous ones), and this quick hack just changes the logic
to prefer the "current" cylinder instead.

It's wrong, and it's stupid, but it's the best we can do without major
surgery.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-29 21:43:14 -07:00
Tomaz Canabrava
1b07483830 Settings update: Fix git_local_only loading
Thanks to the unittesting.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-28 20:01:41 -07:00
Tomaz Canabrava
e54f81855d Settings update: Fix cloud_git_url
I was freeing data segment, sigh.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-28 20:01:00 -07:00
Tomaz Canabrava
28744e232c Settings update: Fix loading "show pictures" in profile tests
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-28 19:59:58 -07:00
Tomaz Canabrava
0a6f6b4382 Settings update: Fix missing groups and Language initialization
There's one function named uiLanguage() that should return
the current uiLanguage() that subsurface is running, but
it actually sets a whole lot of preferences, I think
that the general idea of that function is okay, but it seems
broken for me.

still, I used it to load the correct language from the preferences
since it's what this function is currently doing right now.

Also, a lot of missing groups where added.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 22:37:15 -07:00
Tomaz Canabrava
270864d073 Settings update: Only set if value changed + bugfixes.
Only set the settings if it actually changes, when the user
clicked on the save button on the preferences, the code would
run in every dialog saving each preferences on disk, but this
is uneeded if the value didn't changed.

Also, while doing that, I found a couple of places where I
used the wrong field, which are now fixed.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 22:32:01 -07:00
Dirk Hohndel
1bf76dd3db Settings update: Fix broken UpdateManger logic
In commit b76c1846bb ("Settings update: Simplify Update Manager")
the logic for when to show the UpdateManger question to the user got
broken. Unintuitively, a boolean setting actually has three possible
values. True, False, and Unset. This patch fixes things to work as
designed again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 12:29:08 -07:00
Tomaz Canabrava
f745a25cb7 Settings update: Remember to load the "UpdateManager" settings
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Tomaz Canabrava
9b2404fcb4 Settings update: Move loadPreferences out of qt-helper.cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Tomaz Canabrava
f8f87b7294 Settings update: Move preferences sync / initialization
Move Preferences sync / initialization out of the planner
widget prerferences to the ObjectWrapper.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Tomaz Canabrava
a1b22797ca Settings update: Remove uneeded includes
and comment out questionable code.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Tomaz Canabrava
9299e3c42b Settings update: Correct comment
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:44 -07:00
Tomaz Canabrava
ee91002fdb Settings update: Remove unused include and add FIXME comment
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:44 -07:00
Tomaz Canabrava
db8e8957ab Settings update: Add "Dive Computer" settings to SettingsObjectWrapper
For some reason, the dive computer settings weren't in the
settings prefs. This moves it, makes the boilerplate on Settings
ObjectWrapper and make things compile.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:44 -07:00
Tomaz Canabrava
5c8b87b5fd Settings update: Add UpdateManagerSettings to SettingsObjectWrapper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 10:58:13 -07:00
Tomaz Canabrava
81d5d82b7b Settings update: Clean up save user id local
So, prefs.save_userid_local is being set outside of
a preferences set (it's set to true and false while
loading the files via xml or git) and because of that
I had to bypass a few method calls.

When something triggers a preferences change, the
application will be notified that the preferences
changed, thing that I couldn't do while reading the
xml or git because that should be local-only.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 10:55:40 -07:00
Dirk Hohndel
59e53ae4cc Hide compile time warning
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-16 11:31:31 -07:00
Linus Torvalds
c840ab4332 Fill in divecomputer serial number and firmware version on loading
We have the serial number and firmware version fields in "struct
divecomputer", but we don't actually fill them in when loading the data
from git or xml, because we save all that information in the separate
device table instead.

But in order to always have the serial number associated with a device,
let's make sure to fill those fields in.  It won't hurt, and this way we
have the information available whether we just loaded the dive from a
file, or imported it from the dive computer.  One less semantic
difference to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-14 10:22:41 -07:00
Linus Torvalds
777cbd9cfe Fix cloud storage authentication attempt counting
The authentication count was a static counter in the authentication
callback, which gets incremented until we consider the authentication to
have failed.

The problem with that is that it doesn't get incremented for just _one_
authentication operation, it gets incremented each time you try to load
or save, so eventually the code considers authentication to have failed
even if nothing ever went wrong.

This fixes it by making it static to the whole git-access file, and have
each operation clear it before starting a new remote access.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-14 10:22:35 -07:00
Brian Weber
cccd4cd17b Add HP117 to the cylinder list
Reported-by: Brian Weber
Signed-off-by: weber311@gmail.com
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:08:51 -07:00
Miika Turkia
38a2db05c0 Include full year for trip on divelist
Having only the last 2 digits of the year is somewhat confusing as one
can easily think that to be the day. Thus it is more clear to use full
year for the trip header.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:08:04 -07:00
Robert C. Helling
b5aa6b496f Replace the "stop" symbol in deco plan
Windows Server 2008 seems to be missing the heavy dash in Courier New.
This replaces the symbol by an ordinary dash.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:07:04 -07:00
Robert C. Helling
c23e3adc29 Copy salinity and ambient pressure from diveplan to dive
... otherwise it does not get saved.

Fixes #967

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:06:48 -07:00
Robert C. Helling
2c715542fd Unify handling of QDateTime time zone information
Subsurface uses "local time" which in particular means we never
display time zone information to the user. The user (and our file
format) only sees times like 5pm or 17:00. A better name than
local time (which could mean "local at the dive spot) would
be "watch time", the time displayed by the diver's watch when
she entered the water.

Internally, we store times as time_t, seconds since Jan 1 1970 0:00
UTC. Our convention for conversion between 5pm and time_t as always
been to treat 5pm as if it were UTC.

Then confusion arose since Qt's QDateTime (which is tied to UI elements
like QTimeEdit and similar) is time zone aware and by default assumes
the system time zone. So when we set a QDateTime to 5pm and then later
convert it to time_t we have to take care about the difference between
UTC and the system time zone.

This patch unifies our solution to this problem: With it, we set all
QDateTime's time zone to UTC. This means we don't have to correct for
a time zone anymore when converting to time_t (note, however, the
signedness issue: Qt's idea of time_t is broken since it assumes it
to be unsigned thus not allowing for dates before 1970. Better use the
millisecont variants).

We only need to be careful about time zones when using the current time.
With this convention, when assigning the current time to a QDateTime, we
need to shift for the time zone since its value in UTC should actually be
the watch time of the user who is most likely used to the system time zone.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:04:39 -07:00
Tim Wootton
bd40ef7f42 Adds Cylinder helper class for cylinder info access in grantlee templates
to allow grantlee to access individual fields of the cylinder_t struct
rather than a string representation of the whole cylinder info using a
grantlee structure like this one:
	<table class="table_class">
		<tr>
			<td>Cylinder</td>
			<td>Start press.</td>
			<td>End press.</td>
			<td>Gas mix</td>
		</tr>
		{% for cylinderObject in dive.cylinderObjects %}
		<tr>
			<td>{{ cylinderObject.description }}</td>
			<td>{{ cylinderObject.startPressure }}</td>
			<td>{{ cylinderObject.endPressure }}</td>
			<td>{{ cylinderObject.gasMix }}</td>
		</tr>
		{% endfor %}
	</table>

Signed-off-by: Tim Wootton <tim@tee-jay.org.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:00:33 -07:00
Dirk Hohndel
677bbb77d9 Send the appropriate signal when gitLocalOnly changes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-30 13:06:36 -07:00
Dirk Hohndel
dcf94bef56 Add new helper for case insensitive string comparison
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-24 09:53:24 +09:00
Dirk Hohndel
177e21076b Allow the user to give longer cloud timeout on the command line
When stuck in areas with really bad internet 5 seconds may not be enough,
but making the timeout longer in general seems the wrong way to go. So
keep the default 5 seconds but allow the user to override that with
subsurface --cloud-timeout=NN

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 12:54:30 +09:00
Dirk Hohndel
9815eaf1ed Use preferences object to correctly store cloud status
There are a lot more places all over Subsurface where this needs to be
cleaned up. The converstion of the preferences system has been a complete
mess.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 12:53:37 +09:00
Tim Wootton
0b5a1719a1 Only add non-blank cylinder strings to the cylinder list
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 10:55:17 +09:00
Rick Walsh
b78e6525eb Remove unnecessary DivePlannerPointsModel functions and variables
Commit b1ed04a means that DivePlannerPointsModel::rememberTanks() and related
functions and variables are no longer required

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 10:54:51 +09:00
Tim Wootton
e34bf95718 Only add non-blank weights to the weight list
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 10:52:55 +09:00
Tim Wootton
d0e2ff578a Let cns and otu return ints rather than QStrings
This way they display correctly when accessed from grantlee template

Fixes #1085

Signed-off-by: Tim Wootton <tim@tee-jay.org.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 10:50:15 +09:00
Tim Wootton
2cffb77d19 Adds missing visibility to DiveObjectHelper, so it too can be used in print templates.
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 10:49:19 +09:00
Linus Torvalds
a0aaadd50b Add support for SAMPLE_EVENT_STRING event type
Instead of having fixed numbers and trying to translate them into
strings, a dive computer could just give us the string directly.  Like
the new EON Steel backend does.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 20:00:04 +09:00
Linus Torvalds
c27ad52be4 Properly pick cylinder use when merging dives
The cylinder use field was not merged when dives were merged.  This is
normally not noticeable, since hopefully the cylinder use should be the
same anyway, but when re-downloading the dives from the EON Steel after
updating it to also get cylinder use data, the dive merging threw the
data away again since the original dive lacked it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 20:00:04 +09:00
Linus Torvalds
b2f2a865eb Get the cylinder use data from libdivecomputer if provided
This uses the extended tank type information to fill in the cylinder use
(OC gas, CC Diluent or CC O2) from libdivecomputer when available.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 20:00:04 +09:00
Linus Torvalds
7c8073e7ea Add proper line ending for unit line in git save format
The imperial and metric unit formats already had this, but the
personalized one missed the newline at the end.

It shouldn't really matter, since it's the last line of the file, but it
is not right.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 20:00:04 +09:00
Dirk Hohndel
b25d1c04c4 Show SAC rate when using the ruler
This way it's really easy to see the SAC rate during a segment of a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-18 16:27:38 +09:00
Dirk Hohndel
0a58e6d117 Stay offline if the cloud server is unreachable
It makes no sense to keep trying. Maybe we need a UI to force it online
again, but for now this works much better when using cloud storage while
actually offline.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-17 09:15:10 +09:00
Rick Walsh
ffca5674bf Fixup: don't capitalise best_He
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:08:41 -07:00
Rick Walsh
f08b0e0e3e Planner: automate calculation of best mix for max depth
Add option to calculate the best mix portion of O2 and He for the dive's max
depth if the user enters * in the MOD and MND cylinder fields. Gas portions
are automatically recalculated if the max depth of the dive changes.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:08:25 -07:00
Rick Walsh
ae9e147314 Validate O2 in best mix
We can't have >100% O2

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:08:20 -07:00
Rick Walsh
9fbd11744f Add function to calculate gas maximum narcotic depth
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:08:06 -07:00
Rick Walsh
b1ed04a7f4 Have divedatapoint store cylinder id instead of gasmix
Determining the correct cylinder index from a known gas mix can be
complicated, but it is trivial to look up the gasmix from the cylinder_t
structure.

It makes sense to remember which cylinder is being used. This simplifies
handling changing a cylinder's gas mix, either directly by the user, or
indirectly in the planner. It also permits tracking of multiple cylinders of
the same mix, e.g. independent twins / sidemount.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:07:25 -07:00
Anton Lundin
7c7588a986 Support libgit2 api 0.24
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-23 16:35:39 -07:00
Dirk Hohndel
cb20da7de3 Avoid unused argument warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-20 18:44:16 -07:00
Linus Torvalds
d918289a04 Preferentially use existing device ID when setting serial number
We have two different models for setting the deviceid associated with a
dive computer: either take the value from the libdivecomputer 'devinfo'
field (from the DC_EVENT_DEVINFO event), or generate the device ID by
just hashing the serial number string.

The one thing we do *not* want to have, is to use both methods, so that
the same device generates different device IDs.  Because then we'll
think we have two different dive computers even though they are one and
the same.

Usually, this is not an issue, because libdivecomputer either sends the
DEVINFO event or gives us the serial number string, and we'll always
just pick one or the other.

However, in the case of at least the Suunto EON Steel, I intentionally
did *not* send the DC_EVENT_DEVINFO event, because it gives no useful
information.  We used the serial number string to generate a device ID,
and everything was fine.

However, in commit d40cdb4755ee ("Add the devinfo event") in the
libdivecomputer tree, Jeff started generating those DC_EVENT_DEVINFO
events for the EON Steel too, and suddenly subsurface would start using
a device ID based on that instead.

The situation is inherently ambiguous - for the EON Steel, we want to
use the hash of the serial number (because that is what we've
historically done), but other dive computers might want to use the
DEVINFO data (because that is what _those_ backends have historically
done, even if they might also implement the new serial string model).

This commit makes subsurface resolve this ambiguity by simply preferring
whatever previous device ID it has associated with that particular
serial number string.  If you have no previous device IDs, it doesn't
matter which one you pick.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-20 18:39:21 -07:00
Dirk Hohndel
da052967c2 Grr. Fix. Typo.
I never push things without compile testing. Never.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-14 12:15:03 -07:00
Robert C. Helling
fc213066f8 Only setpoint changes with non-zero SP indicate a CCR dive
There might be some spurious setpoint changes at t=0 without
an actual value (I have no idea where those come from). In
any case, those do not indicate that the dive is a CCR dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-14 12:04:36 -07:00
Dirk Hohndel
c580122727 Remove unused variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-11 10:32:00 -07:00
Robert C. Helling
3870916ae2 Fix logic for presaturation
There were two problems in the calculation of tissue pre-
saturation from previous dives: We added the surface interval after
the dive rather than before and when also took dives into accout
that were in the future of the dive considerd.

Reported-by: Timothy Massey
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-11 10:28:04 -07:00
Linus Torvalds
7a77569019 Make sure all dive computer events are represented in the plot_info data
We could create a plot_info data that didn't contain all the time slots
for the events fromt he dive computer, which would terminally confuse
the plotting of the event profile widgets because it couldn't match up
the event with the dive plot data model.

So for example, in DiveEventItem::recalculatePos(), when the code tries
to figure out the spot in the data model, it could fail, and then try to
hide the event (because without the data model information it doesn't
know where it should go).  But that hiding would then not match the
logic in DiveEventItem::shouldBeHidden(), and the event would end up
being shown in the upper left-hand corner of the profile after all.

The reason the plot_info data wouldn't contain the time slots is that
the slots are allocated primarily for the sample data, and then the
events would be added in between sample data in populate_plot_entries().

But since we'd only add the event pointer *between* samples, that would
mean that events after the last samples would not get plot-info points
allocated to them.

That issue was exacerbated by how we also truncate uninteresting samples
at the end when some dive computers end up giving a long stream
(possibly several minutes) of "at the surface" events before they
finally turn off logging.

This makes sure that we take the event timestamps into account for the
"maxtime" calculation, and also that we finish populating the plot_info
data with any final event timestamps.

Now all the events will have a matching plot_info entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-01 13:09:26 -07:00
Linus Torvalds
5ea16c0bab Don't ignore surface events in xml parsing
I missed the fact that not only did we skip importing surface events
from the dive computer, we had also made our xml parser ignore them when
loading an xml file.  All part of our historical "let's ignore surface
events because dive computers are being very annoying about it".

Signed-off-by: Linus Torvalds <torvalds@linux-foundtion.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-01 13:08:22 -07:00
Linus Torvalds
7bbd8cc974 Don't ignore surface events from libdivecomputer
There are cases where we actually want to keep them, as exemplified by
this situation from Richard Yorke:

  "I have just come across a situation when ignoring the surface marker
   is a disadvantage.  I have just had a problem with my BC feed
   seeping, slowly filling my BC and as I control my buoyancy on the
   bottom using the air in my drysuit, I did not notice, so that when I
   came to ascend the expanding air in my BC caused a loss of control.

   Fortunately not from a great depth and no untoward consequences.
   However, the Subsurface profile only shows me rising to 4m and
   descending to 5.5m for my safety stop.  However I actually broke the
   surface and descented to 5.5 but the frequency of recording depth was
   not fast enough to show this as it was so brief"

so remove the code that ignores the surface events entirely.

I think we'll have to come up with some smarter filtering model for
showing them, but that is predicated on getting these events to come
through in the first place.

Reported-by: Richard Yorke <yorke.richard@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-31 10:16:20 -07:00
Linus Torvalds
2582972121 Make 'clear_dive()' free the primary dive computer data properly
Our primary dive computer really is special, not just because it's the
first one: it's directly embedded in the "struct dive", and so if you
just walk the divecomputer list, you'll miss it, because it's not _on_
the list, it is the very head _of_ the list.

We had that bug in copy_dive(), and it turns out we have it in
clear_dive() too: clear_dive() would free all the dive computers on the
list, but not the actual primary one.

This is a minor memory leak, no more, so it's not exactly critial, but
let's just do it right.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-31 10:16:13 -07:00
Rick Walsh
8acbeed555 Add some gas mix validation to the planner
A few basic rules for gas validation:
	We can't have <0%, or >100% of either O2 or He
	O2 + He must not be >100%
	Switch depth can't be <0%

This places limits on user-input values

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28 14:24:10 -07:00
Miika Turkia
47a2e8b1d9 Shearwater import model name for Petrel and Predator
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28 14:23:10 -07:00
Miika Turkia
1aa6bd9904 Set model on Shearwater import
For starters, let's just state that this dive was downloaded from
Shearwater. However, once we have information how model numbers map to
names, we can use that info for the models we know about.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28 14:22:58 -07:00
Miika Turkia
1e5fe4f3fe Use serial as device ID on Shearwater import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28 14:22:51 -07:00
Rick Walsh
1e607ae98d fixup: Don't confuse EAD and END
The previous patch (Planner: add best mix EAD preference) used the term EAD
(equivalent air depth) in variable names and strings, when it should have been
END (equivalent narcotic depth).
They're not the same thing and shouldn't be confused.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21 07:03:55 -07:00
Rick Walsh
9b29173363 Planner: add best mix EAD preference
Add best mix EAD preference and UI, along with a tooltip describing what it
does

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21 07:03:38 -07:00
Rick Walsh
b61b3a8d28 Add functions to calculate best mix
Best mix O2 calculated based on planner Bottom O2 preference
Best mix He calculated based on EAD of 30m (should be made user-configurable)

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21 07:03:23 -07:00
Joakim Bygdell
0e4e8edf78 QML UI: add comboboxes to DiveDetailsEdit
This adds autocompleting text input fields for suit, buddy and
divemaster.

[Dirk Hohndel: some whitespace cleanup]

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-16 11:05:20 -07:00
Joakim Bygdell
fcc370b2fe Add functions to DiveObjectsHelper
This generated the QStringLists needed to populate the combobxes
in DiveDetailsEdit.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-16 11:02:27 -07:00
Miika Turkia
b468390155 NULL terminate the parameters array
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-05 07:28:28 -07:00
Miika Turkia
74065ad8aa Allow parsing of .txt files on import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-05 07:27:31 -07:00
Dirk Hohndel
d668a89df7 Find bundled translations on iOS
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-04 13:51:55 -07:00
Dirk Hohndel
e47327c87a Android build: prepare and copy translations into the APK
And then load them at runtime.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-03 17:20:53 -07:00
Miika Turkia
1902d527d5 Parse date and time from on APD import
This will parse the date and time information on CSV import if the file
name matches the one used by APD log viewer (date and time are available
in the file name). Hard coding the year to 20?? is a bit unfortunate,
but as there is only 2 digits in the year, we have to invent something.
And it would be quite optimistic to assume this will bite us back any
time soon :D

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-03 09:50:32 -07:00
Miika Turkia
43f9112420 Print xsltproc command line on verbose mode
Printed command line can be used to manually test the import function,
allowing faster testing of XSLT changes, and showing debug prints that
are discarded by Subsurface.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-02 10:24:58 -07:00
Thiago Macieira
8f35b7324e Move the qtTranslator and ssrfTranslator pointers to qt-init.cpp
No point in having it defined in each main program's .cpp. Especially
since the unit tests don't define them.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-02 07:07:21 -07:00
Robert C. Helling
c2c0cb48d2 Only attempt to download each picture once
Otherwise we keep downloading the same image multiple times instead
of new images.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 16:18:44 -07:00
Dirk Hohndel
82d4ffbdcd Fix typo
Otherwise this code makes no sense (and has no effect).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 16:15:51 -07:00
Dirk Hohndel
241dd7cb81 Merge branch 'offlineDefault' 2016-04-30 12:40:52 -07:00
Dirk Hohndel
d943050a93 QML UI: make offline the default
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 11:07:14 -07:00
Dirk Hohndel
9bec79a71b Don't pretend that opening git repo succeeded
Not sure why we claimed that this was successful when clearly it wasn't.
There's a risk that this could break something on the desktop, but it
makes no sense to me why that would be the right thing to do.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 11:06:02 -07:00
Dirk Hohndel
05a51f7984 Only create the path to no cloud local storage once
This required a small change to the helper function, but this seemed
totally worth it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 09:46:29 -07:00
Dirk Hohndel
3f63660267 Allow switching the user from the command line
This is a feature that many people have asked for. This implementation is
somewhat simplistic because we simply use a different name for the
program settings - but interestingly enough this appears to be enough to
capture a lot of the core functionality that people are looking for in
multi-user support.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 12:14:59 -07:00
Robert C. Helling
2e6588dc0e Protect access to image hash dictionaries with lock
Otherwise we step on our own feet when downloading several images,
like after import from divelogs.de with many linked images.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:08:20 -07:00
Linus Torvalds
56ed3f1c61 Fix Qt date interfaces for times before 1970
This seems to work around the crazy QDateTime::fromTime_t() problem in Qt.

It is *very* lightly tested. In fact, the only test is that "test0.xml"
change that is part of this patch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:07:41 -07:00
Linus Torvalds
84166a4ee7 Extend time parsing to before 1970
It turns out that we are starting to have users that have logs that go
back that far. It won't be common, but let's get it right anyway.

NOTE! With us now supporting dates earlier in 1900, this also makes
"utc_mktime()" always add the "1900" to the year field.  That way we
avoid ever using the fairly ambiguous two-digit shorthand.

It didn't use to be all that ambiguous when we knew that any two-digit
number less than 70 had to be 2000+.  Now that we support going back to
earlier in the last centiry, that certainty is eroding.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:07:17 -07:00
Dirk Hohndel
9ba090c31f git storage: init local repository
So far we didn't do that at all, we either relied on the user manually
creating a local repo, or we cloned a remote repo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Miika Turkia
61c9b2891c Fix time parsing for Divesoft Freedom
Divesoft uses 17 bits for time so parse accordingly.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-25 11:25:34 -07:00
Miika Turkia
90db7d3a50 Abort git authentication attempt
If we have incorrect cloud credentials, we need to return an error on
git authentication call back in order to avoid endless authentication
loop. This might well happen e.g. when changing the password on desktop
and then on laptop Subsurface still thinks the credentials are validated
and ends up in the authentication loop.

The authentication call back on libgit is intended to be used to ask for
user credentials, and as we handle credentials elsewhere, we just need
to fail the authentication attempts. (The threshold for bail out could
have been 1 attempt...)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-25 09:58:57 -07:00
Miika Turkia
24edaf4be1 Parse date and time in DL7 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-25 09:16:32 -07:00
Miika Turkia
f4ddc07883 Grab the payload of DL7 file
This allows us to parse the DL7 profile data (skipping the header and
footer)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-25 09:08:57 -07:00
Dirk Hohndel
d6b36c47cb Fix SettingsObjectWrapper to actually use the group set
At least for the GeneralSettings group.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-22 12:04:24 -07:00
Dirk Hohndel
31b34a24cc Don't calculate the 9 minute average
We don't do the "smoothed" profile anymore (and haven't for years),
so no need to calculate the data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-20 16:00:28 -07:00
Dirk Hohndel
eb07faef00 Only do 9 minute interval for min/max/avg
We don't use 3 and 6 minute values anywhere, so why calculate them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-20 15:55:51 -07:00
Linus Torvalds
e0ac1c9a26 Fix 3-, 6- and 9-minute min/max calculations
Make them use indices into the plot-info, fix calculation of average
depth, and fix and add comments.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-20 15:36:25 -07:00
Rick Walsh
62b989979e Fix broken Bluetooth support
This partially reverts Commit 39313c5

Reported-and-analyzed-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-18 06:01:01 -07:00
Dirk Hohndel
4ac6f34b16 With patched Qt 5.6 for iOS correctly handle disabled GPS source
Qt 5.6.0 is broken when it comes to using CoreLocationService on iOS.
It doesn't even check if the location service is enabled. My patches fix
that and make Qt set an error code right after service creation. Having
the service creation fail is actually the wrong thing to do because then
Qt switches over to GeoClue and that really isn't helpful for our needs
here.

Additionally, Qt 5.6.0 without my patches doesn't follow the REQUIRED
flow of using the location service as it does not check the access
permissions before accessing the GPS service - without doing so the
GPS service will not run in the background.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-17 22:59:19 -07:00
Dirk Hohndel
c0b44e25b7 GPS provider: change haveGPS status if GPS source returns error
If the GPS source returns an error that could be an indication that the
user hasn't given us permission to use it, so switch our status to NOGPS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-17 22:59:12 -07:00
Dirk Hohndel
b00306f50e GPS provider: track tristate information for GPS source
Initially we don't know if we have a source. After that we may think
that we have one, or not have one (but that can actually change while
the program is running if the user, for example, turns the source off
or switches to airplane mode).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-17 22:59:02 -07:00
Dirk Hohndel
71d74f9e3c QML UI: rewrite the commitChanges function
I couldn't figure out how to break this down into small, useful commits.
Part of the problem is that I kept going while working on this and as you
can see from looking at the commit, diff tries so hard to find small code
fragments that moved around, that the diff overall becomes quite
unreadable and it seemed impossible to recreate the sequence of steps
after the fact.

It all started with adding the parsing for the GPS coordinates. But while
testing that code I found several issues with the rest of the function.
Most importantly it seemed ridiculous that we carefully tried to match the
texts that the DiveObjectHelper would create for the various fields,
instead of just using the DiveObjectHelper to do just that. And once I had
converted that I once again realized just how long and hard to understand
that function was getting and decided to break out some of the more
complex parts into their own helper functions.

But of course all this didn't happen in this logical, structured, ordered
way. Instead I did all of these things at the same time, testing,
rearranging, etc.

So in the end I went with one BIG commit that does all of this in one fell
swoop.

This adds four helper functions to deal with start time/date, duration,
location and gps coordinates, and depth of the dive.

To avoid mistakes when dealing with the GPS coordinates, there's another
helper to encapsulate the creation of the dive site and we switched to a
current GPS location.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:16 -07:00
Dirk Hohndel
6985c123d4 QML UI: stop using "--" for empty strings
I can't remember why we started doing this, but at this point I find it
just weird.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:08 -07:00
Dirk Hohndel
c84f16e7f6 Make the raw timestamp available in QML
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:43:33 -07:00
Dirk Hohndel
590af9ae7d Add helper to find the dive closest to a given time
If we want to keep the selected dive "close" to where it was before an
operation (whether a delete, or a reload, or something like that), then
the most intuitive thing to do appears to be to select either the same
dive again (if it still exists), or one very close to it in time. This
helper allows us to identify the dive in the current dive list that is
closest to the given time.

We do this in the C code to ensure that we look at all dives in the
dive_table - based on the id that is returned the UI can then figure out
where this dive is currently shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:42:10 -07:00
Rick Walsh
22afd4a1ce VPM-B profile: declare CVA iteration variables within each loop
The variables that control each CVA iteration should be declared at the start
of each loop so that the values are carried over from one iteration to the
next.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2016-04-11 21:24:00 +02:00
Robert C. Helling
a260dc2f8a Fix time of first ceiling calculation
In our verision of VPM-B for real dives, we take as the deco time the
difference between the time of the deepest ceiling and the time when the
ceiling clears.

When the display of ceilings was set to multiples of 3m this was confused, as
the maximum finder had issues: First of all, it updated the time when the ceiling
was the same (which was almost always the case for stepped ceilings) but changing
>= to > was not enough, since then the first time a deepest stepped ceiling was
reached was used.

This patch uses the actual ceiling (not rounded to the next integer multiple of 3m)
for this calculation to get rid of this problem.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2016-04-11 21:23:35 +02:00
Dirk Hohndel
a1ec0d6724 git storage: only sync with remote if git_local_only isn't set
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:29:17 -07:00
Dirk Hohndel
922c945f5a QML UI: more hacking around with git progress reporting
I gave up on the magic numbers and instead report simply linear progress.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 23:39:54 -07:00
Dirk Hohndel
3555cadb77 QML UI: don't fetch the remote twice when loading
We first check the sha to see if we want to load at all. But at that
point we already have the repository and the branch and we have synced
with the remote. So when we decide that we need to reload from storage,
we don't need to repeat those steps, instead we can go directly to the
git load.

For that to work we need to pass the repository pointer and the branch
name back to the caller so that we can directly call git_load_dives().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 22:57:16 -07:00
Dirk Hohndel
a1332ce361 Simplify git tracking of git tree creation
With Linus' changes to the tree creation saving the dives is no longer
the dominant part of that process, so simplify the output (which also
removes the hacky buggy code to show the percentages that is of course
totally bogus).

(apparently a couple of white space cleanups snuck into this patch)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:23:48 -07:00
Dirk Hohndel
f869ce51b4 git storage: add explanation for fast forward to remote
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:13:27 -07:00
Dirk Hohndel
092d0478c3 git storage: compare with correct SHA when checking if cache is current
Otherwise by the time we make the comparison the saved_git_id has already
been updated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:10:41 -07:00
Linus Torvalds
485c5a4ebd Fix per-cylinder SAC rate calculations when cylinder use isn't known
John Van Ostrand reports that when he dives using two cylinders using
sidemounts, the per-cylinder SAC rate display is very misleading.

What happens is that since the two cylinders are used together (but
without a manifold), John is alternating between the two but not
actually adding gas switches in the profile.  As a result, the profile
looks like only one cylinder is used, even though clearly the other
cylinder gets breathed down too.

The per-cylinder SAC rate calculations would entirely ignore the
cylinder that didn't have gas switch events to it, and looking at the
info window it would look like John had a truly exceptional SAC rate.

But then in the general statistics panel that actually takes the whole
gas use into account, the very different real SAC rate would show up.

The basic issue is that if we don't have full use information for the
different cylinders, we would account the whole dive to just a partial
set.  We did have a special case for this, but that special case only
really worked if the first cylinder truly was the only cylinder used.

This patch makes us see the difference between "only one cylinder was
used, and I can use the overall mean depth for it" and "more than one
cylinder was used, but I don't know what the mean depths might be".

Reported-by: John Van Ostrand <john@vanostrand.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 16:53:02 -07:00
Linus Torvalds
ff8392da54 Remove unused and buggy get_cylinder_used_gas_string() function
It's good that this is unused, because it does the calculations wrong.

Due to the gas compressibility the gas use calculations should subtract
the gas_volume() values at the differing pressures, not the pressures
themselves.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 16:52:58 -07:00
Dirk Hohndel
6d6ba8b54a QML UI: better trip header
This tries to give the best information about the trip that we have.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 12:27:51 -07:00
Dirk Hohndel
0a4b246421 Small cleanup of helper functions to remove unused arguments
Also removes an unused variable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 07:40:52 -07:00
Linus Torvalds
eff4059802 Start using the actual cylinder data for gas switch events
Now that gas switch events always have indices into the cylinder table,
start using that to look up the gas mix from the cylinders rather than
from the gas switch event itself.  In other words, the cylinder index is
now the primary data for gas switch events.

This means that now as you change the cylinder information, the gas
switch events will automatically update to reflect those changes.

Note that on loading data from the outside (either from a xml file, from
a git/cloud account, or from a dive computer), we may or may not
initially have an index for the gas change event.  The external data may
be from an older version of subsurface, or it may be from a
libdivecomputer download that just doesn't give index data at all.

In that case, we will do:

 - if there is no index, but there is explicit gas mix information, we
   will look up the index based on that gas mix, picking the cylinder
   that has the closest mix.

 - if there isn't even explicit gas mix data, so we only have the event
   value from libdivecomputer, we will turn that value into a gasmix,
   and use that to look up the cylinder index as above.

 - if no valid cylinder information is available at all, gas switch
   events will just be dropped.

When saving the data, we now always save the cylinder index, and the gas
mix associated with that cylinder (that gas mix will be ignored on load,
since the index is the primary, but it makes the event much easier to
read).

It is worth noting we do not modify the libdivecomputer value, even if
the gasmix has changed, so that remains as a record of the original
download.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:37:18 -07:00
Linus Torvalds
e0824ef9f3 Make gas change events always have a cylinder index
In commit df4e26c875 ("Start sanitizing gaschange event information")
back about a year and a half ago, I started sanitizing the gas switch
event data, allowing gas switches to be associated with a particular
cylinder index rather than just the gas mix that is switched to.

But that initial step only _allowed_ a gas switch event to be associated
with a particular cylinder, the primary model was still to just specify
the mix.

This finally takes the next step, and *always* associates a gas switch
event with a particular cylinder.  Instead of then looking up the
cylinder by trying to match gas mixes at runtime, subsurface now looks
it up when loading the dive initially as part of the dive fixup code.

The switch event still has an a separate gas mix associated with it, but
this patch also starts preparing for entirely relying on the gas mix in
the cylinder itself, by starting to pass in not just the event but also
the dive pointer to the routines that look up gas mix details.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:37:18 -07:00
Linus Torvalds
7a444c0210 Make cylinder_nodata() take a const cylinder pointer
Some of the gas mix cleanups I'm doing are in code that uses const
pointers, and wants to use this.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:37:18 -07:00
Linus Torvalds
9005274986 Make "is_gasmix_redundant()" more robust
The gas switch event handling is somewhat fragile, mostly because the
legacy event encoding for gas switches is odd.  It's also limited to
whole percentages, unlike our internal gas mix model.

In addition, it also ends up comparing the values to the raw permille
values, which is wrong for air, and wouldn't match our O2_IN_AIR which
is 209 permille (closest approximation to 20.946%).

So handle air separately, since "21" really is a valid oxygen value for
air, and should match 20.9%.  And use the proper accessor functions to
get the gasmix values.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:37:18 -07:00
Linus Torvalds
eb5907ab3b Remove linear pressure interpolation detection code
Dirk says that divinglog hasn't been doing the linear pressure
interpolation for a long while, so we're doing extra dive fixups that
really aren't needed any more.

Also, the code is actually buggy: it only ever worked on the first
cylinder anyway (because only the first cylinder pressure_delta[] would
be initialized).  That was probably perfectly fine in practice, since
it's unlikely that many tech divers used old versions of divinglog
anyway, so the bug per se isn't a reason to remove it - but it is a sign
that the code was a bit hard to read, so let's get rid of it if there is
no reason to maintain it or fix it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:37:18 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.

And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.

This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:33:58 -07:00