Commit graph

126 commits

Author SHA1 Message Date
Tomaz Canabrava
04704d02c8 Simplify: remove gps variable
And also use existing helper function to get the GPS string

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:47:07 -08:00
Tomaz Canabrava
e2bc3b0e24 Simplify: remove m_notes variable
I didn't understood the logic of the define & replace,
so maybe we want a few comments there.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:47:07 -08:00
Tomaz Canabrava
6f95242ff1 Simplify: remove Maxcns and OTU variables
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:59 -08:00
Tomaz Canabrava
75561ff956 Simplify: remove suit and trip
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:20 -08:00
Tomaz Canabrava
8929d6eb1a Simplify: remove waterTemp variable
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:12 -08:00
Tomaz Canabrava
8e8c32d26e Simplify: removed buddy and airTemp variable
also fixed a bug on the depth

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:12 -08:00
Tomaz Canabrava
a6796d9c80 Simplify: removed divemaster
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:11 -08:00
Tomaz Canabrava
0bb661c3e1 Simplify: removed duration and depth variables
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:11 -08:00
Tomaz Canabrava
ae222f147c Simplify: removed location variable
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:11 -08:00
Tomaz Canabrava
8ead18a43a Simplify: removed timestamp variable
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:11 -08:00
Tomaz Canabrava
820cd0c28d Simplify: remove uneeded variable, rating.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:11 -08:00
Tomaz Canabrava
438b5df089 Simplify: remove uneeded variable: id
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:46:00 -08:00
Tomaz Canabrava
ed97f9f315 Simplify: QML code handling series
The connection between the C++ core and the QML code leaves a lot of room
for improvement; the following series will do small but important updates
on the code regarding QML and QtWidget coexistence and behavior.

First: simplify wrapper class, removing uneeded variable.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 15:44:10 -08:00
Dirk Hohndel
9e85d76766 GPS data: create divesite when missing for applied GPS data
Otherwise things will of course crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 10:02:58 -08:00
Dirk Hohndel
19e95efd6f Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 06:14:45 -08:00
Dirk Hohndel
3c1a111404 Fix potential compile error
This compiled just fine for me but apparently the QStringList needs to be
explicitly included on Ubuntu 15.10.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-11 06:09:27 -08:00
Dirk Hohndel
602d1227a7 Compile fix for older compilers
Not every compiler supports non-trivial initializers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 22:24:30 -08:00
Dirk Hohndel
a3af5331ea Fix bug setting up DiveObjectHelper
Why would we bail there if the notes are empty?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 21:14:51 -08:00
Dirk Hohndel
4f10f7f7ae QML UI: refresh divelist after GPS data was successfully applied
And create a helper to do so to make the code simpler.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 20:44:22 -08:00
Dirk Hohndel
956b864319 GPS data: if deleting on server fails, remember to try again
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 20:44:22 -08:00
Dirk Hohndel
4d4f5ed89b GPS data: don't try to track what's uploaded
This has been the cause of issues in several cases. We should simply always try
to push all data to the server - it deals with redundant uploads quite nicely.
(previous commits already stopped responding to this flag, this simply removes
all mention of it)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 20:44:22 -08:00
Dirk Hohndel
69619ef5aa GPS data: delete fixes on the server
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 20:44:21 -08:00
Dirk Hohndel
88291f605c GPS data: more fixes
- load the data from settings as we start
- improve upload to server
- keep settings and in memory model in sync

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 20:44:21 -08:00
Dirk Hohndel
33142ed7f8 Reimplement the internal repesentation of GPS fixes
Instead of using the Settings as our data structure and constantly accessing
them, we now have a QMap for the GPS fixes and only access the Settings to keep
them in sync with the QMap. This should significantly speed things up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 20:44:21 -08:00
Miika Turkia
7701975d98 Support for imperial depth on worldmap export
This will use the depth units from user preferences when exporting the
worldmap.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 14:13:58 -08:00
Robert C. Helling
82c87204e4 If all else fails try loading images from cloud server
Of course, as of this writing, there are no images on the server.

In addition, this patch adds comments to explain the by now convoluted
image retrieval logic (local file, filename as URL, by hash, cloud server).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 14:12:36 -08:00
Robert C. Helling
3ae6326847 Simplify image hashing logic
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 14:12:23 -08:00
Salvador Cuñat
09c854fee0 Renumber dive list after manual dive merging
As Linus pointed out in mail list, user is forced to manually renumber
his dives after doing a merge, unless the merged dives were those at
the list tail.

This patch try to manage the more usual cases, letting the user to deal
with those more complex, based on some assumptions:

1.- We are working on an time ordered list of type:
      dive_table.nr           ... 100 -- 101 -- 102 -- 103 -- 104 ...
      dive_table.dives.number ... 234 -- 235 -- 236 -- 245 -- 246 ...
2.- It's unlikely to merge no consecutive dives, as merging is time
    based.
3.- It's unlikely (although possible) to find consecutive dives with
    no consecutive numbers.
4.- It would be rather bizarre to find that newer dive,of those to
    merge, has lower number than older.
5.- It can be found that one (or both) dives to merge are zero
    numbered.
6.- There is only need to renumber from merged dives in advance.

A variable, "factor", is fixed before reworking the dive table. This
number will be substracted from the original dive number.
If we are in point 5.- case, "factor" will be set to zero, meaning
that dive numbers will not change (if older dive is zero, merged one
will be numbered zero too and will let the user to manage this; if
newer dive is zero there won't be need of renumbering as following
dives will be correctly numbered, e.g. after splitting a dive which
is not at the tail of the table).

In most cases, "factor" *should* be set to 1.

While renumbering it can be found a dive with it's number set to zero,
this won't be changed and will remain zeroed to avoid negative
numbers. It, mostly, means that the user has pending work on his
dives.

I don't know why I've written such a big explanation for such a tiny
patch :-)

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-10 14:11:32 -08:00
Dirk Hohndel
b1f90b6aa0 QML UI: partial, slow and incomplete implementation of delete GPS fix
This only deletes the fix on the mobile device, not on the server.
And it is really really slow. Re-reading the data from the settings just isn't
a smart way to do this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08 23:18:41 -08:00
Tomaz Canabrava
25aa80846b Move Dive class from qthelper.h/cpp to it's own file
and rename it to DiveObjectHelper, since it should be an QObject
based class to make it easier on the QML, grantlee and widgets
side to display the dive's internal data.

each Q_PROPERTY defined in the DiveObjectHelper.h file
can be acessed directly via it's name.

So, if you are on a model that  returns a dive, acess it's name
by dive.name

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08 08:04:44 -08:00
Tomaz Canabrava
89eed5d36e Untangle Library Linkage
with the adittion of gpslistmodel/location, the libraries
qt-models had a direct dependency on subsurface-core, and
subsurface-core had a direct dependency on qt-models, this is
bad.

Moving a bit of code around I'v managed to clean this out, and
also to clear a bit of uneeded code (GpsTracker and gpsTracker where
basically the same thing.)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08 08:04:04 -08:00
Dirk Hohndel
7b155774c5 Compile fix
This makes the desktop version compile again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 22:43:13 -08:00
Dirk Hohndel
6c0259d540 Compile fix
While the conversion of uint64_t to QVariant works fine with some Qt /
compiler combinations, it fails on others. Use Qt's type instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 22:41:13 -08:00
Dirk Hohndel
c62baea032 Correctly adjust time stamp of GPS fixes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 22:08:04 -08:00
Dirk Hohndel
1eda61e115 Merge branch 'gpsList' 2016-01-07 21:43:22 -08:00
Dirk Hohndel
06dcc9ab8d Populate the model with the GPS fixes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 21:41:52 -08:00
Dirk Hohndel
1c66e399fa Download gps locations in the mobile app
This is not the same as the existing download to apply the gps fixes to the
dive list. This allows us to download and store the GPS fixes in the settings.

I may end up changing things around to have a shared implementation for
downloading the GPS fixes, but for now this seemed easier.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 21:32:24 -08:00
Dirk Hohndel
a7f8a7574e Create GpsListModel in order to be able to display GPS fixes
This will allow us to visualize the GPS fixes that are currently stored in the
QML UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 21:29:05 -08:00
Salvador Cuñat
ce3a78efca Assign lower number to a merged dive instead of higher one
At the moment, if we have, say, dives ... 100, 101 and 102 and we merge 101 and
102, we get a list numbered ... 99, 100, 102. This is, probably, an
undesired behavior. The patch simple chooses lower of both dive numbers instead
of higher one.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 18:40:20 -08:00
Dirk Hohndel
701f91e4fe Try harder to find the language name that includes country code
It seems that the first language in the list of languages isn't always the one
that specifies the country code. So try the first three to see which one is the
first to contain a country code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-05 23:41:30 -08:00
Dirk Hohndel
3bfa8de2f7 Cloud storage: fix potential crash when avoiding reloading dive list
If we loaded the dive list from cache and then try to figure out if the remote
repository had anything different, we were being super stupid if the SHA was
identical... we had already cleared the dive list by the time we decided that
we didn't need to load things. Granted, the model was still populated (oops),
but the backend data structure was cleared and accesses to it (e.g., when
drawing the profile) would cause things to crash.

The helper function duplicates some code, but trying to not duplicate the code
made things even harder to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-04 17:55:37 -08:00
Dirk Hohndel
14a09689a4 Location service: get the current position
If we have a fix that is fewer than 5 minutes old, take it, otherwise trigger
an update.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-01 17:26:18 -08:00
Dirk Hohndel
66cd83a70f Location service: support the concept of waiting for a position
There may be reasons where we want to get the position even if the criteria
aren't met.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-01 17:26:14 -08:00
Dirk Hohndel
a611bb22f7 Location service: restructure the way GpsSource is managed
It makes much more sense to have this as a private member of the class instead
of a static in one of the functions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-01 17:26:09 -08:00
Dirk Hohndel
a0aa27e864 QML UI: handle editing of depth
Getting closer to being able to really edit / add dives in the mobile UI.
This works for manually added dives - needs a bit more thought for dives
downloaded from dive computers as we don't necessarily want to change the
maxdepth in conflict with the samples.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-01 00:55:34 -08:00
Dirk Hohndel
c7c9fb0bb0 Git storage: be more careful when checking if this SHA is already loaded
In commit 8c1cc4524d ("Don't reload identical data") I got a little
carried away. Before comparing SHAs we need to make sure that
a) this is a git repository at all
b) we have an actual SHA before we claim to have the data loaded

Reported-by: Paul-Erik Törrönen <poltsi@777-team.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-28 08:21:03 -08:00
Stephen Hemminger
113a421228 ftdi: fix memory leak on error
Found by cppcheck. Minor memory leak if usb_reset fails

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27 21:31:13 -08:00
Stephen Hemminger
7a42215067 dive: paren error in set point handling
This probably is a serious bug, found by cppcheck.
Original code had paren's in probably the wrong place!

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27 21:31:13 -08:00
Dirk Hohndel
8c1cc4524d Don't reload identical data
If we already have the same SHA loaded and no changes have been made to the
dive list then there is no point in loading the dives again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27 10:06:33 -08:00
Dirk Hohndel
bc200c3089 Cloud storage: check the top commit without loading dives
This way we can check if the local cache is in sync with the remote without
always triggering a load of the dives from git.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27 10:06:33 -08:00