Commit graph

11023 commits

Author SHA1 Message Date
Linus Torvalds
f92e2e752f Split up fixup_dive_dc() into multiple smaller independent functions
fixup_dive_dc() is called for each dive computer when we add a new dive.
It does various housekeeping functions, cleaning up the sample data, and
fixing up dive details as a result of the sample data.

The function has grown to be a monster over time, and particularly the
central "walk every sample" loop has become an unreadable mess.

And the thing is, this isn't even all that performance-critical: it's
only done once per dive and dc, and there is no reason to have a single
illegible and complex loop.

So split up that loop into several smaller pieces that each will loop
individually over the sample data, and do just one thing.  So now we
have separate functions for

 - fixing up the depth samples with interpolation
 - fixing up dive temperature data
 - correcting the cylinder pressure sensor index
 - cleaning up the actual sample pressures

Yes, this way we walk the samples multiple times, but the end result is
that the code is much easier to understand.  There should be no actual
behavioral differences from this cleanup, except for the fact that since
the code is much more understandable, this cleanup also fixed a bug:

In the temperature fixup, we would fix up the overall dive temperatures
based on the dive computer temperatures.  But we would then fix up the
overall dive computer temperature based on the sample temperature
*afterwards*, which wouldn't then be reflected in the overall dive
temperatures.

There was another non-symptomatic bug that became obvious when doing
this cleanup: the code used to calculate a 'depthtime' over the dive
that was never actually used.  That's a historical artifact of old code
that had become dead when the average depth calculations were moved to a
function of their own earlier.

This is preparatory for fixing the overall cylinder pressure stats,
which are currently wrong for dives with multiple dive computers: we
currently take the starting cylinder pressure from the *first* dive
computer that has cylinder pressure information, but we take the ending
cylinder pressure from the *last* dive computer with cylinder pressure
information.

This does not fix that bug, but without this cleanup fixing that would
be a nightmare due to the previous complicated "do everything in one
single loop" model.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 20:17:40 -05:00
Dirk Hohndel
cace666741 QML UI: avoid having the virtual keyboard show briefly at startup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 20:15:44 -05:00
Dirk Hohndel
f19ffb28c6 Minor tweak to script to pull Kirigami
This just allows the script to be used when you are working locally on
Kirigami to test changes - no point in waiting for a pull from upstream
then. The only goal is to copy the files over.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 20:13:33 -05:00
Dirk Hohndel
80bfccdf33 QML UI: better visual arrangement of the dive list
Make the lines that together form one dive move closer together so the dives
visually stand out more.

(this also includes small white space change, oops)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 16:56:16 -05:00
Dirk Hohndel
c117a7be6e QML UI: make the dive list font even darker
Still not black, though - there's an opacity setting somewhere that I must be
missing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 16:55:24 -05:00
Dirk Hohndel
74f8d50264 QML UI: use the new Kirigami option to control the title bar sizes
I liked the default and the fact that it disappeared completely, but the big
size was a bit too much...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 16:54:22 -05:00
Dirk Hohndel
fba14709bc Disable kirigami plugin when copying the components
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-01 16:40:07 -05:00
Dirk Hohndel
2efa047999 Merge branch 'kirigamiPort' of https://github.com/sebasje/subsurface into mergeKirigamiPort
This merge was a bit more challenging given how far things had diverged,
but I hope I got it mostly right.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-31 22:36:15 -05:00
Dirk Hohndel
2069526e74 Update script to pull Kirigami
Now with it's own repository and slightly different paths.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-31 18:43:58 -05:00
Dirk Hohndel
cc2b815a4d QML UI: simplify the code to cancel edit / add
This way we have one function that correctly ends both modes.
As a positive side effect this fixes a bug where one could exit the
add mode by tapping Dive list in the main menu which would not delete
the partially created dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 20:49:00 -05:00
Dirk Hohndel
6a3e761d8f QML UI: scroll to top of dive list when tapping title bar
This helps you get to the latest dive when you are stuck at the bottom
of a dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 20:39:25 -05:00
Dirk Hohndel
1cf1fa9cac QML UI: add property to reflect when dive list is shown
This makes it easier to have actions that are only valid in this case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 20:38:51 -05:00
Dirk Hohndel
13c49276d1 Revert "QML UI: make dive list fold dive trips"
This reverts commit 83c72e7a79.

The folding as implemented is too painfully slow and buggy on devices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 20:17:41 -05:00
Dirk Hohndel
27a62a0210 Revert "QML UI: make dives outside of dive trips always visible"
This reverts commit a065b97472.

The folding as implemented is too painfully slow and buggy on devices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 20:16:50 -05:00
Linus Torvalds
f0be2764da Be smarter about dive renumbering when merging dives
We really have two different cases for merging dives:

 (a) downloading a new dive from a dive computer, and merging it with an
     existing dive that we had already created using a different dive
     computer.  This is the "try_to_merge()" case, called from
     "process_dives()

 (b) merging two different dives into one longer dive.  This is the
     "merge_two_dives()" case when you explicitly merge dives using the
     divelist.

While a lot of the issues are the same, many details differ, and one of
the details is how dive numbering should be handled.

In particular, when you download from a dive computer and merge with an
existing dive, you want too take the *maximum* dive number, because the
dive computer notion of which dive it is may well not match what the
user dive number is.

On the other hand, when you explicitly merge in the dive list, you end
up renumbering not just the dive you are merging, but also all
subsequent dives, since you now have one fewer dives overall.  So that
case already has to be handled by the caller.

Now, the simpler "download from dive computer" case was broken by commit
ce3a78efca ("Assign lower number to a merged dive instead of higher
one").  It fixed the numbering for the divelist case, but broke the
download case.

So this commit reverts commit ce3a78efca, and instead extends and
clarifies the dive renumbering that "merge_two_dives()" already did.  It
now explicitly renumbers not just the following dives, but also
renumbers the merged dive itself, so now we can go back to the old "take
the bigger dive number" for the core merging, which fixes the download
case.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 20:16:19 -05:00
Dirk Hohndel
94a549e767 QML UI: brute force password saving
This is embarrassing. I should have done this in the first place instead
of trying to hack around it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 21:43:37 -05:00
Dirk Hohndel
cae180036e QML UI: really force passwords to be saved
The logic looked so easy, but the preference needs to be hard coded twice
because there are two scenarios:
- new install, make sure we load the password from settings (so it needs
  to be hard coded BEFORE we load preferences)
- update where previously for some reason the user stored that they
  didn't want to store the password, so we need to also hard code it after
  the settings were loaded

Looks odd, but that should do the trick.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 21:23:28 -05:00
Dirk Hohndel
5e8930a179 If the cache was valid, we don't want to reload just because of changes
This was exactly backwards. If there already are changes we do NOT want to
reload - that would overwrite those changes for no good reason; after all, the
starting point was correct, so why throw the changes away?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 20:46:12 -05:00
Dirk Hohndel
501f8ba6a4 QML UI: remove a few obsolete properties and references
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 20:24:34 -05:00
Dirk Hohndel
a11e719f1a QML UI: add SAC rate to dive detail view
Not sure why this wasn't there before, it's certainly one of the more
interesting values for me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 20:18:06 -05:00
Dirk Hohndel
a065b97472 QML UI: make dives outside of dive trips always visible
Create small visible separation from the dive trip before. And make the dive
trip header a slightly different color so they stand out between dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 20:08:15 -05:00
Dirk Hohndel
83c72e7a79 QML UI: make dive list fold dive trips
This makes it MUCH easier to deal with a lot of dives.

Instead of needing a more complicated model we simply use the meta data that
allows us to create the dive trip sections to hide (make invisible + height 0)
all dives that aren't in the selected trip.

I'll admit that this was much easier than I expected it to be.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-29 19:42:34 -05:00
Dirk Hohndel
1b0c3d8df5 Update mobile version
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-28 17:05:49 -05:00
Dirk Hohndel
dd0d88f9d7 QML UI: take device pixel ratio into account when scaling pixmaps on iOS
This way warning icons and tank change icons and other event markers are no
longer ridiculously tiny on retina screens. Oddly this doesn't appear to be
needed on Android, only on iOS.

Fixes #1033

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-28 17:05:29 -05:00
Dirk Hohndel
8185d24e61 QML UI: force local saving of password
commit d99c931219 ("QML UI: remove the checkbox for remembering the
password") made the incorrect assumption that this would always be true
by default when it actually was false by default. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-27 19:28:31 -05:00
Dirk Hohndel
4670373731 QML UI: tighten credential input screen
This way even on smaller screens both email and password should fit
above the keyboard which makes data entry so much easier.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-27 19:10:58 -05:00
Dirk Hohndel
a4977f2a90 QML UI: add some diagnostics to App log
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-26 21:49:20 -07:00
Dirk Hohndel
d4357b3b21 QML UI: allow writing to App log from QML
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-26 21:49:19 -07:00
Dirk Hohndel
7434e4213b QML UI: show keyboard when entering credential screen
If the user goes to the credentials screen, they likely want to edit
something.  So put the focus on the first entry field and show the
keyboard.

We also need to hide the keyboard when the credential screen becomes
invisble so that the keyboard doesn't stay around when the dive list
is shown.

Suggested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-26 21:49:19 -07:00
Robert C. Helling
e216f91ebc Prevent unintentionally running as root
Some users try to run Subsurface as root for example to get around
permission problems with dive computer devices. This is a bad idea
since config files get touched as root and then cannot be read
as normal user anymore.

This patch allows running as root only with verbose option on. We can
assume if somebody manages to start subsurface as root this happens
from the command line.

For some reason, I couldn't get translation working at this stage.

Windows version is a stub.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-26 20:08:08 -07:00
Dirk Hohndel
d99c931219 QML UI: remove the checkbox for remembering the password
In the context of the mobile app this simply makes no sense. If the user
doesn't select this option, the app doesn't really work. So why have the option
in the first place?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 21:42:20 -07:00
Dirk Hohndel
246422d03f iOS build: fix typos
Can't believe I didn't notice them earlier... I must have stared at these
strings countless times.

Reported-by: Scott Ireland <scott@sdj.ca>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 21:36:42 -07:00
Dirk Hohndel
8f5a662441 QML UI: add the position source reported to the log
I've seen iPads without GPS report that they support satellite positioning.
Seems like a Qt bug to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 17:48:20 -07:00
Dirk Hohndel
dc1cd40721 Revert "iOS build: enable access to GPS location"
This reverts commit 78a8137963.

These keys don't enable access, they require the device to have GPS support.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 17:28:47 -07:00
Dirk Hohndel
a9cf089e1c QML UI: remove verbose option from Developer menu
We now log everything that's relevant to the application log that is shown
in the UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 16:37:23 -07:00
Tomaz Canabrava
5f9df02ffc Fix tests linkage
I wasn't linking the tests against the qrc library, which made trying to
load the xslt transformation files for the parse test fail.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 16:32:38 -07:00
Dirk Hohndel
f298802b99 QML UI: GPS location service - correctly calculate the delta
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 11:50:51 -07:00
Dirk Hohndel
b1037abdb7 QML UI: GPS location service - only show the fixes we store
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 11:50:46 -07:00
Dirk Hohndel
9a62685f0b Read GPS location service thresholds from settings
We used to faithfully save them, but not restore them at start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 11:18:20 -07:00
Dirk Hohndel
6c9247b56b QML UI: improve About screen
This should actually give a correctly positioned logo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 09:44:05 -07:00
Dirk Hohndel
aa4e3ba537 Give more information about the GPS location service
On iOS it seems that I get a fix every second. Even though the
QGeoPositionInfoSource is set up with an update interval of 5 minutes...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 08:49:45 -07:00
Dirk Hohndel
2a65eab745 iOS build: add another Info.plist key to enable positioning
This key is needed so that the iOS app asks the user for permission to use the
GPS position information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 07:54:48 -07:00
Dirk Hohndel
78a8137963 iOS build: enable access to GPS location
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-24 05:41:44 -07:00
Dirk Hohndel
f9e68f13f3 iOS build: add missing icon
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 23:31:12 -07:00
Dirk Hohndel
854eb57ef5 QML UI: always convert the cloud user name to lower case
Mixed case user names cause the connection to the cloud storage to fail.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 23:12:03 -07:00
Dirk Hohndel
fcb93362ac QML UI: reduce application log clutter
We don't need to flood this with the profile scaling data anymore; that's
hopefully fixed for good.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 21:22:55 -07:00
Dirk Hohndel
b16e8e7b4e QML UI: work around missing back button on iOS
Especially when showing the dive details and editing dive details,
having the option to go back in the context menu is nicer on iOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 21:15:01 -07:00
Dirk Hohndel
fb157b873a iOS build: fix executable name
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 19:45:07 -07:00
Dirk Hohndel
509b664a29 Another small signed / unsigned warning fix
This is in the Mac support file that wasn't compiled on Linux when I tried to
finish the cleanup.

Now this compiles without warnings on Mac and iOS as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 17:26:46 -07:00
Dirk Hohndel
788d65a527 Make code easier to read (and avoid warning)
The old expression wass correct because if dive_table.dives[j]->number is != 0,
then !dive_table.dives[j]->number is 0 and vice versa. But come on...
The new code seems much more natural and easier to read.
And of course the Apple compilers by default gave a warning because they
suspected a precedence bug with the old code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 17:26:46 -07:00