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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
A lot of this is still black magic, but at least this now documents what I
understand about the process.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The name subsurface-ios was used in many places and that was just not helpful
to fight against. This should work much better.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The saved_git_id could be updated in is_git_repository() under certain
circumstances, so we need to make sure we compare to the sha that was
current as we entered this function. Since the pointer is just to a static
buffer we need to actually copy it (and then free it later).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the load fails the get_dive(1) could return NULL. Let's catch that as
an error instead of having the test crash.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Otherwise parse_file() thinks that this data has already been loaded and
doesn't re-read it, even though our internal data structures have been
erased - so a subsequent parse_file after clear_dive_file_data() that
opens the same git repository finishes successfully, but leaves the
dive_table empty which is of course incorrect.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>