Commit graph

7275 commits

Author SHA1 Message Date
Dirk Hohndel
6820b13bd5 Don't store empty dive sites
And remove references to them from the dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 23:22:40 -08:00
Dirk Hohndel
ca72ab5749 When closing a dive, delete all the dive sites
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 23:11:36 -08:00
Dirk Hohndel
3ea2e15bd2 Don't add empty dive sites
It makes no sense to keep them around, it makes no sense to have dives
refer to them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 23:08:33 -08:00
Dirk Hohndel
7ca3d859dc Add helper function to detect empty dive sites
No point in keeping those.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 22:53:03 -08:00
Dirk Hohndel
cd77e2e700 Make sure there is a dive site if you try to edit it
If the user clicks on manage (or double clicks on the globe) and the
displayed_dive doesn't actually have a dive site associated with it (e.g.
because we are adding a dive or because it was imported or downloaded
without dive site information, then we need to make sure that there is an
empty dive site that we can make changes to.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 22:45:31 -08:00
Dirk Hohndel
e32459d313 When adding / planning a dive, reset the dive site manage screen
Otherwise old data is still shown if the user clicks manage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 22:42:57 -08:00
Dirk Hohndel
b60b4ef69d Fix crash when adding a dive
If a dive has no dive_site_uuid we would dereference a NULL pointer and
crash. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 22:08:08 -08:00
Dirk Hohndel
da60867ae3 Always print dive site uuids as 8 digits / leading 0s in git format
Otherwise there are ugly spaces in the file names. This didn't break
anything, per se, it's mostly cosmetic.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 22:06:57 -08:00
Dirk Hohndel
6dd6e90684 Don't force the first divecomputer to CCR just because there's po2 value
The existing code was bogus as it used cur_dive->dc instead of cur_dc
(i.e., it always changed the first dive computer, even if the po2 was
found in a different one).

But fundamentally I consider this bogus. We are not doing the right thing
here - some dive computer send us pO2 values that are just the calculated
pO2 at a depth and NOT a setpoint, yet we pretend those are setpoints and
then turn these dives into CCR dives.

This needs to done differently.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 21:07:22 -08:00
Dirk Hohndel
1527cd0d05 More useful debug prints
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:45:38 -08:00
Dirk Hohndel
2607fea2de Fix compile time warning
No idea why designer sometimes adds these zorder items.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:45:31 -08:00
Dirk Hohndel
32ad046f56 Allow editing of dive sites
And hook things up when double clicking the globe.

The user experience isn't consistent with what we do on the main tab
(i.e., no coloring of fields that are changed), but it seems to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:35 -08:00
Dirk Hohndel
06e578424e Finally remove location, latitude and longitude from struct dive
With this all references to these members should be gone and all the code
should be switched over to the dive site infrastructure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
6708e06872 Adapt GPS coordinate download from our companion app to dive sites
This is a bit awkward now. We are downloading what looks like fake dives
in the v2 format. So we create a dive site for every single fix.

After we merge those new dive sites into the existing dives we need to
throw away all the dive sites that weren't used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
be1b6c67c1 maintab change for get_dive_site_uuid_by_name
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
d8146445fc Add another helper funtion
We need to be able to get rid of dive sites as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
d2baa36312 Improve dive site creation from v2 git storage
Fix broken helper function, move helper functions into the .c file (there
really wasn't a good reason for these to be inline), fix the logic that
decides if we want to create a new dive site or use an existing one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
8c3efd2a22 Improve parsing of older XML files in order to auto create dive sites
While the existing code worked with a couple of hand crafted examples it
turns out it did a poor job with most of my files. Oops.

Depending on whether we find name or coordinates first, we need to
identify existing sites in either case and do the right thing.

The challeng here are multiple dives at the same site with slightly
different GPS coordinates. If the name is read first, these all get merged
into one (and we warn about the different GPS data). But if GPS gets read
first, we create separate dive sites with the same name.

We need a sane UI to consolidate these - but we can't completely automate
this... it's possible that these ARE the same site and the GPS data is
just imprecise (for example, multiple dives at the same time with GPS
locations from the Subsurface companion app). The user should be able to
either pick one of the GPS locations, or keep multiple (for example,
different buoyes for the same site and you want to keep the different
markers).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 12:42:44 -08:00
Dirk Hohndel
d4f2b72148 Make special backup when switching XML versions
Since the last few dozen commits change the format in irreversible ways
and could therefore be destructive and lose data for testers of the
development version, let's try to be extra careful and create "special"
backup files that aren't overwritten by subsequent backups. At least this
way people can go back to the previous state.

Of course people using the git backend don't have to worry about this as
they always can go back to any earlier save.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 23:35:52 -08:00
Dirk Hohndel
ae49a8a4f7 Get location from dive site for git commit message
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:54:39 -08:00
Dirk Hohndel
b2f0d21d43 Get location for Facebook from dive site
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Dirk Hohndel
253a137cc7 Get location from dive site for printing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Dirk Hohndel
4e95beabc2 Remove coordinates from main tab
It seems to make sense to only have them on the dive site screen. For the
main UI they were redundant (we have the map) and not all that useful. The
only time people would want them is if they wanted to manually add GPS
coordinates for a dive, but that should now be done via the dive site UI.

There are a couple of FIXMEs in the code and a few code blocks that have
been commented out as they will be needed in one form or another once this
GPS handling is done on the dive site UI, which right now it is NOT.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Dirk Hohndel
616cb18b29 Make filters work with dive sites
This simply tracks the names - if we have multiple dives sites with the
same name but different other data (e.g. different GPS), we could easily
get this right (well, somewhat easily, it's a UI question), but for that
we'd have to filter for dive site uuid instead of for dive location name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Dirk Hohndel
d032c2a5c5 Change UEMIS infrastructure to use dive sites
Which is actually much more natural to the way the UEMIS stores things...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Dirk Hohndel
9ca600e114 Fix remaining gps references when parsing XML files
Clearly I didn't run into these before in my testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:30:57 -08:00
Dirk Hohndel
c109b98f19 Change one more spot in divelist.c from locations to dive sites
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:30:57 -08:00
Dirk Hohndel
b7e53aaee6 Change from locations to dive sites in save-html and worldmap
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:30:56 -08:00
Dirk Hohndel
4c87ccf952 Switch from locations to dive sites in liquivision code
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:11:51 -08:00
Dirk Hohndel
32da12664d Switch components for cut/paste dive to dive site logic
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:11:51 -08:00
Dirk Hohndel
99ba2f0687 Switch from locations to dive sites in dive.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 20:56:46 -08:00
Dirk Hohndel
8bea7cbdc7 Show dive site name in dive list
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 12:54:20 -08:00
Dirk Hohndel
7fb35c98d3 Get trip location from dive's dive site
This adds another useful helper function as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 12:49:25 -08:00
Dirk Hohndel
0ce215e0d9 Fix dive site creation from v2 git storage
Clearly didn't test that part well enough.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 12:31:10 -08:00
Dirk Hohndel
a6336d13b3 Don't ever create a dive site without valid uuid
If you want a specific one, you can always overwrite it, but a dive site
with a uuid of 0 breaks some of our assumptions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 12:29:35 -08:00
Dirk Hohndel
0e6345f65b Correctly connect the maintab to dive site management
We now have a working uuid - use it. And populate the fields accordingly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
5c4d266060 Make editing a location work with dive sites
Not sure if this is the final implementation, but at least for simple
cases it works now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
cd28e88bee Improve helper functions
Sometimes we want to create a dive site just based on a name, sometimes we
have both a name and GPS coordinates. Let's make a helper for either case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
ccf833b45c Clear the location if we have no dive site
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
f8b63e1bb6 Update completion model for dive site names
This way the drop down works again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
801e584029 Another helper: for_each_dive_site()
This doesn't make the code necessarily more compact, but easier to read
and is consistent with our other patterns.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
d488c37cc1 Show dive coordinates on map based on dive site
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
9ef81d3ed3 Show GPS coordinates based on dive site on MainTab
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
6a812c6b6d Show location based on dive site on MainTab
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
05948530e9 Save and load dive sites in git format
Update the version to 3.

Continue to read version 2 files and create dive sites on the fly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
4b15b9dfe9 Save and parse dive site structures to XML
Read and write divesite sections in the XML file.

Read divelogs of version 2 and create dive site structures on the fly.
Read version 3 files that have divesiteid instead of location / gps.

Saves version 3 files where dives no longer have location and gps but
instead refer to a divesiteid

The commit contains quite a few fprintf(stderr,...) in order to allow
better monitoring of the parsing / transforming of locations and gps to
dive sites. This will need to be removed later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Dirk Hohndel
e720c82aa1 Some dive site helper functions
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:05 -08:00
Dirk Hohndel
dcfda29da6 Add dive site data structure
This leaves location and gps coordinates in the struct dive to allow a
step by step migration.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:18:12 -08:00
Dirk Hohndel
9edb7811ef Remove redundant function
We had two functions doing exactly the same thing. Let's drop the one with
the highly confusing name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11 16:34:02 -08:00
Tomaz Canabrava
42afb4972a Pass a fake dive site UUID to the callback.
This is the start of the preparations to edit the dive site,
passing a uuid so we can retrieve it later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11 16:34:02 -08:00