Commit graph

27 commits

Author SHA1 Message Date
Dirk Hohndel
bd4629b293 Add nr of dives at the site to completion string
I'm not convinced that this is useful enough to keep, but let's give it a
try and see what people think.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-18 13:34:05 -07:00
Dirk Hohndel
1dbb6071bd Add helper function that checks if a dive site is in use
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-15 21:25:26 -07:00
Dirk Hohndel
9d622996ba Merge branch 'tomaz'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14 15:33:28 -07:00
Dirk Hohndel
8c0d0de2e6 Location completer: give distance if known
If both the displayed dive and the dive site which is shown as a potential
completion have a GPS fix, indicate the distance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14 11:52:17 -07:00
Tomaz Canabrava
ca5606d3e9 Create/retrieve dive_site by name.
When we are working on the location management, we want to get a new
dive_site if the dive_site name changed unless there's no dive_site by
that name, then we create it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13 15:42:35 -07:00
Dirk Hohndel
3478943f2f Fix memory handling for taxonomy data
The way we freed things and cleared out the variables potentially left
dangling data behind and could end up calling free on garbage data,
leading to random crashes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13 07:09:55 -07:00
Salvador Cuñat
097d65521a Clean double free in copy_dive_site()
This makes subsurface crash by simply clicking a dive in the list.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-07 10:37:53 -07:00
Dirk Hohndel
6ebeba3c7c Be more careful freeing taxonomy data
We want to only access data that we consider valid. And we need to clear
out pointers to freed memory.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 12:09:20 -07:00
Dirk Hohndel
bc8c54f1ee Rename enum values for taxonomy
This avoids confusion and namespace collisions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 10:22:31 -07:00
Dirk Hohndel
53b805131e Geo taxonomy: add the taxonomy information to dive sites
Make the helper functions handle it as well

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 12:28:15 -07:00
Tomaz Canabrava
1fd4e55240 Dive site rewrite: copy the changed dive site to the original
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
9d51326e48 Dive site rewrite: fix double free
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
05c5bf0919 Dive site rewrite: try to fix a crash
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Tomaz Canabrava
2fec1a88de Dive site rewrite: copy the current dive to the displayed dive
This way we can actually edit something.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 18:50:22 -07:00
Anton Lundin
7a594e3ec5 Simplify distance calculations
This simplifies the distance calculations and removes a dependency.

This version uses propper math instead of my to simple previous version.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 21:08:11 -07:00
Dirk Hohndel
d541c2b601 Add helper function to determine the distance between two points
And use this to find a dive site within a certain radius of a GPS fix.
This will be used to figure out if dive sites might be the same.

This uses a new Qt5 component (Positioning) which was added in Qt5.2.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 11:51:15 -07:00
Dirk Hohndel
f8a3a85210 Fix potential crash using std::sort
It's entirely unclear why std::sort sometimes accesses the element with
index -1. In my limited testing switching to qSort avoids that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 08:45:45 -07:00
Lubomir I. Ivanov
0f2d0211c3 divesite.c: use rand() instead of random()
random() is POSIX and seems to be missing in MINGW.
it can return a 64bit (if 'long' is 64bit) but
given ID's are 32bit rand() should suffice.

also random() is technically a better algorithm but for
cryptographically unsafe usage like generating IDs the
stdlib's LCPRNG rand() should siffuce.

also this patch makes it so that a true 32bit random value
is returned. how random it is, is another topic.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-14 07:53:13 -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
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
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
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
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