Add conditional so globe.cpp builds with older versions of Marble

In commit 7f3b487c77c7 ("Restore the previous globe zoom level after
showing dive without GPS") I was a bit too aggressive in replacing a
deprecated API function - people still need to be able to compile against
Marble versions older than 4.10.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correct check for existence of DateTimeOriginal exif tag

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add images to all dive computers and refresh profile

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Marginal optimization of UDDF import

This speeds up Aquadivelog imports marginally by doing lookup to used
equipments only instead of all equipment ever used.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
User manual: document importing GPX files in companion app

Document the new "add" menu capabilities, partially as there are features still not
functional.
Documents the new feature with GPX files imports.
Corrects a typo.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix bug in handling of fake SAMPLE_EVENT_PO2 events

In commit bcdd6192fe45 ("Show translated event names in tooltip") I was
too aggressive in replacing the checking for event names with checking for
event types. It turns out that we are abusing an existing event type in
the planner (and use a different event name to mark the difference). By
just checking for the type this now caused incorrect information to be
displayed in the info box (a simply "PO2 warning" on a Suunto D9 could
turn into a "Bailing out to OC" notice).

The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from
libdivecomputer. Once we have those, we can do this the right way. For now
we just fall back to also checking the event name (which is what I wanted
to get away from so translated names don't trip us up).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Uemis downloader: handle more corner cases

After receiving another report of the Uemis downloader failing I tried to
make it more robust when unexpected things happen. The data structures
returned by the SDA are rather convoluted and not all relationships are
fully understood.

This makes sure we don't try to parse invalid dive entries, we only read
dive entries if we actually got new divelog entries, we only read dive
sites if at least one was referenced and we use a much more patient (and
hopefully, much more robust) algorithm to figure out which dive entry
corresponds to the new divelog entries.

What a pain.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix standard cylinder names

We need to pass the size as an integer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make rulergraph a pref as well

I don't see a point in treating it differently from the other graphs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix odd indentation

I need to fix this in the tool as well...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correctly parse boolean preferences

QVariant does the right thing, regardless of whether the value is stored
as int or as string - so let's just use that instead of manually checking
for integers (and failing if the values are stored as "true" and "false").

Fixes #511

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change the profile redraw logic after preferences were changed

I we are showing a calculated ceiling, then we have to replot the profile
after a preferences change as the gradient factors could have changed
which might change a calculated ceiling.

Also use the rulergraph preference instead of checking the settings
directly.

Fixes #511

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change EDIT_SELECTED_DIVES macro

The way this is implemented is broken in several ways.
This fixes the first issue.
For the invocations where we are in the 'WHAT' checking to see if the
value we are changing in the selected dive was previously the same as in
the current dive (which is the one shown to the user for editing), then we
need to make sure we change the current dive last, otherwise the
comparison will fail.

Of course, right now we only do this check for gps location, which is a
massive bug as far as I am concerned.

Fixes #515

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only change identical fields when editing multiple dives

This was broken when porting to Qt - we used to do this correctly in the
Gtk version.

When editing multiple dives we show the current dive to the user and allow
them to edit that and then apply those edits to all selected dives. The
way this is SUPPOSED to work is that we only change those selected dives
that had the same value for the edited field as the current_dive had for
that field.

Let's say you select ten dives. The current dive shows divemaster Joe. You
change that to divemaster Jim. Then only the selected dives that had
divemaster Joe should change to Jim. All other dives should stay
unchanged.

This seems to implement that logic.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Last minute Beta 4

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
More multi-edit fixes

This time for values that aren't simply text.
For normal integers this is rather straight forward. For the 'when'
timestamp we simply assume that this is a shift in time.

What is still missing is consistent handling of the three fields that are
implemented as tags: tags, buddy and divemaster. We have special code for
tags that makes no sense in a multi-edit scenario. And we treat divemaster
and buddy as a single string - which kinda works but treats "Bill, Joe"
and "Joe, Bill" as different.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Simplify string comparison

This is based on Linus' idea on the mailing list.
Treat NULL strings and empty strings as identical.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Revert "Save latitude and longitude on XML even if location not set"

This fixes the bug in #440 by accident, and introduces lots of empty
attributes and tags in the xml.

This reverts commit 6378bfd91ee6c0ad746b072d8a9389e0eba7c614.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Terminate the string before relying on strlen

Its a c-string we put, so it must be null-terminated.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Qt turns edited locations into null-strings

They aren't null pointers after you touched them, so we can't rely on
that to choose if we should use put_string or show_utf8.
show_utf8 would not print the tag if it only contains a \0 as body.

Fixes #440

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>