Commit graph

58 commits

Author SHA1 Message Date
jbygdell
0e57033042 QML UI: Parse multiple buddies when editing a dive
This allows the user to enter multiple buddies as a comma separated list,
the "Multiple Buddies" entry is still a special case as we can only populate
the combobox with a single name for each entry.

fixes #168

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-01-29 14:55:33 -08:00
Dirk Hohndel
b15b3c195c QML UI: allow magic phrase for multiple buddies to be localized
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-22 18:20:03 -08:00
Joakim Bygdell
1219dc6931 QML UI: deal with multiple buddies correctly
When editing adive in Subsurface-mobile we can only handle one buddy
due to the limitations of the combobox. To prevent loss of data when editing
a dive with more than one buddy we display "Multiple Buddies" in the buddy
field. This creates a special case where no changes are written to the buddy field
unless the user changes buddy for that dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17 13:46:15 -07:00
Dirk Hohndel
80eafb8db7 Fix some warnings
At least the warnings about size potentially being uninitialized seem correct
and valid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 10:27:56 -07:00
Joakim Bygdell
674d8331f5 QML UI: Enable cylinder edit
This adds the option to select a cylinder when adding or editing a dive.
Due to limited screen size we restrict the editing to the first cylinder only.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 07:36:13 -07:00
Tomaz Canabrava
5651abfd75 Settings update: Simplify code by using the SettingsObjectHelper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Robert C. Helling
2c715542fd Unify handling of QDateTime time zone information
Subsurface uses "local time" which in particular means we never
display time zone information to the user. The user (and our file
format) only sees times like 5pm or 17:00. A better name than
local time (which could mean "local at the dive spot) would
be "watch time", the time displayed by the diver's watch when
she entered the water.

Internally, we store times as time_t, seconds since Jan 1 1970 0:00
UTC. Our convention for conversion between 5pm and time_t as always
been to treat 5pm as if it were UTC.

Then confusion arose since Qt's QDateTime (which is tied to UI elements
like QTimeEdit and similar) is time zone aware and by default assumes
the system time zone. So when we set a QDateTime to 5pm and then later
convert it to time_t we have to take care about the difference between
UTC and the system time zone.

This patch unifies our solution to this problem: With it, we set all
QDateTime's time zone to UTC. This means we don't have to correct for
a time zone anymore when converting to time_t (note, however, the
signedness issue: Qt's idea of time_t is broken since it assumes it
to be unsigned thus not allowing for dates before 1970. Better use the
millisecont variants).

We only need to be careful about time zones when using the current time.
With this convention, when assigning the current time to a QDateTime, we
need to shift for the time zone since its value in UTC should actually be
the watch time of the user who is most likely used to the system time zone.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:04:39 -07:00
Dirk Hohndel
8d83edc48a QML UI: correctly check cloud verification status
Oops. That's embarrassing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-17 04:23:46 -07:00
Dirk Hohndel
07512cb2c8 QML UI: allow entering the cloud PIN on the mobile UI
Now the user doesn't need to do this on the desktop app anymore.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13 16:42:36 -07:00
Dirk Hohndel
5fa965df54 QML UI: prepare to enter the cloud PIN on mobile UI
This just creates the properties to connect QML and C++ code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13 16:41:26 -07:00
Dirk Hohndel
d2f9803883 QML UI: serialize checking credentials
If we run the backend to verify credentials without waiting for it to
finish, the redirect might happen before we know if the credentials are
invalid, unverified or verified - which will cause us to give the wrong
information to the user.

Yes, this additional wait is annoying, but I can't come up with a better
way to do this and avoid incorrect information. At least the UI isn't hung
while we wait.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13 15:25:17 -07:00
Dirk Hohndel
f7daadb1cd QML UI: don't proceed unless cloud credentials are verified
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-12 18:05:33 -07:00
Dirk Hohndel
f2e03022fa QML UI: disable GPS functionality on iOS
I still haven't figured out how to make GPS work on iOS. So let's not
pretend this works.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-12 12:09:49 -07:00
Joakim Bygdell
80274b0968 Add init function to qmlmanager
In order to get autocomplete to work on manual dive add
we apparently need a separate init function.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21 06:59:38 -07:00
Dirk Hohndel
ba9288fab6 QML UI: when first entering cloud credentials, force cloud connection
With offline the default now, we need to force a connection at least once
so that the repos are in sync. And then of course we need to return to the
correct state, regardless on whether this connection succeeded or failed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 11:08:33 -07:00
Dirk Hohndel
bca2c2a101 Connect to the reply, not the manager
This way if there are other pending connections we don't get triggered by
the wrong completion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 10:16:00 -07:00
Dirk Hohndel
879482e977 QML UI: forceRemoteSync means connect even without unsaved changes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 10:15:56 -07:00
Dirk Hohndel
711e5e76e8 QML UI: better diagnostics when cloud connection fails
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 10:15:15 -07:00
Dirk Hohndel
05a51f7984 Only create the path to no cloud local storage once
This required a small change to the helper function, but this seemed
totally worth it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 09:46:29 -07:00
Dirk Hohndel
4a2a0a426e Fix logic for when to mark dive list as changed
Since saving checks if there are changes, we have to always mark the dive
list as changed before asking for the changes to be saved.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 09:46:01 -07:00
Dirk Hohndel
4ad73fb807 QML UI: when switching from no cloud to cloud usage, don't drop local data
This is rather simplistic, it just imports the local data into the remote
repository and therefore loses the git history of the local data - but I
wasn't able to make the git merge without shared base commit work, so I
went this much easier to implement route instead.

One thing we need to be careful about is that contacting the remote server
could fail. If we don't manage to merge the dives from cloud server and
local storage, we need to revery to no cloud status in order not to lose
the local data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 14:36:00 -07:00
Dirk Hohndel
c6205b5819 QML UI: fix order of tests when saving changes
Only check for previous cloud connection when actually trying to save
to cloud

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 14:03:50 -07:00
Dirk Hohndel
f536da0ee3 QML UI: make sure nothing is lost when changing cloud credentials
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:48:43 -07:00
Dirk Hohndel
9ca0f7334b QML UI: handle failure to read local dive data
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
3946f83ff2 only set index if we have specific target
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
bdf8bc676b QML UI: with a local default file setup, open that at start
And set no cloud mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
4b1edceca0 Add helper function for the consumption of loaded dive data
This allows us to call that part of the process from multiple places
in the future.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
7c156f3ba1 QML UI: in no cloud mode, save to a default local repo
And set that up as the default file to load at start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
660f421d6d QML UI: correctly show if we are accessing remote or local storage
This makes sure that if the user switches to offline mode they don't get
incorrect notifications that tell them that they are accessing cloud
storage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-19 10:34:49 -07:00
Dirk Hohndel
fe62da3a6b QML UI: always show the time stamp when logging data
This should help understand some of the issues with git storage and GPS
fixes better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-19 04:20:12 -07:00
Dirk Hohndel
1819cc1ccc QML UI: make the state of the GPS service available to QML
This exposes a locationServiceAvailable property to QML and keeps it in
sync with the corresponding state in the GpsLocation widget.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-17 22:59:19 -07:00
Dirk Hohndel
ecf44bb2fa QML UI: quit on back key while showing dive list
Make sure you save first, though.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 14:42:08 -07:00
Dirk Hohndel
71d74f9e3c QML UI: rewrite the commitChanges function
I couldn't figure out how to break this down into small, useful commits.
Part of the problem is that I kept going while working on this and as you
can see from looking at the commit, diff tries so hard to find small code
fragments that moved around, that the diff overall becomes quite
unreadable and it seemed impossible to recreate the sequence of steps
after the fact.

It all started with adding the parsing for the GPS coordinates. But while
testing that code I found several issues with the rest of the function.
Most importantly it seemed ridiculous that we carefully tried to match the
texts that the DiveObjectHelper would create for the various fields,
instead of just using the DiveObjectHelper to do just that. And once I had
converted that I once again realized just how long and hard to understand
that function was getting and decided to break out some of the more
complex parts into their own helper functions.

But of course all this didn't happen in this logical, structured, ordered
way. Instead I did all of these things at the same time, testing,
rearranging, etc.

So in the end I went with one BIG commit that does all of this in one fell
swoop.

This adds four helper functions to deal with start time/date, duration,
location and gps coordinates, and depth of the dive.

To avoid mistakes when dealing with the GPS coordinates, there's another
helper to encapsulate the creation of the dive site and we switched to a
current GPS location.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:16 -07:00
Dirk Hohndel
00ac1c12db QML UI: fix the save to cloud logic
There were several logical flaws here. Ugh.

Don't save things if there are no unsaved changes, if we haven't
initialized this repository from the cloud or if we are already saving
things.

Then, once we decide that we should save, first always save to the local
cache and then check if we should save to the cloud and do so if
requested.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:16 -07:00
Dirk Hohndel
6985c123d4 QML UI: stop using "--" for empty strings
I can't remember why we started doing this, but at this point I find it
just weird.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:08 -07:00
Miika Turkia
9e787a2476 Copy coordinates when renaming site
Let's not discard our GPS location when editing site name on mobile.

Fixes #1051

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 12:57:40 -07:00
Dirk Hohndel
67742856b2 QML UI: don't try to scroll to dive at time 0
If no timestamp is available, just start at dive 0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 11:49:25 -07:00
Dirk Hohndel
6e6cce770b QML UI: keep QML manager and the UI in sync about selected dive
The manager can now directly update the index of the selected dive, and
the UI tells the manager the timestamp of the currently selected dive.
This allows the manager to pick the best possible dive as selected dive
if things change (for example if the dive list gets reloaded because it
changed in cloud storage).

Fixes #1009

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:43:33 -07:00
Dirk Hohndel
2878236268 QML UI: clear the flag indicating that we are accessing storage
If the automatic sync is turned off we could be stuck in a state where we
always thought that we were already in the middle of a save.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:43:33 -07:00
Dirk Hohndel
9a2e3ce7e8 Remove unused function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-13 09:28:55 -07:00
Robert Helling
7bca367c57 Upon undoing a dive deletion select that dive
Before it had the next dive still selected.

Fixes #1053

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-11 12:41:41 -07:00
Dirk Hohndel
ccff227596 Fix wrong function call for desktop build of Subsurface-mobile
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-11 09:56:35 -07:00
Dirk Hohndel
18b7ee3875 QML UI: try to do the right thing for changes on all platforms
On Android we can save locally right away, but we don't want to make the user
wait for a network sync. Sadly, on Android currently the saving in the
background doesn't work and the save will run when the user comes back.
Definitely not ideal.

On iOS the situation is different - a save to the local git cache takes
surprisingly long. Must be the shitty file system they use or something.
Because of that we only mark the dive list changed and instead save the next
time the app is not in the foreground (which works on iOS but not on Android -
go figure).

On all the other OSs (I guess that would be desktop builds of
Subsurface-mobile? But there may be other mobile OSs that people might want to
build it on) we save both locally and to the cloud right away.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-10 19:22:16 -07:00
Dirk Hohndel
4ed369b975 QML UI: only force network access when user asks us to
So when the user taps on the manual cloud sync, we always force access to
the cloud server. Otherwise we only access the cloud server if
git_local_only isn't set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:37:17 -07:00
Dirk Hohndel
685d31cd4f Simplify code - we now can rely on git_local_only to do the right thing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:34:29 -07:00
Dirk Hohndel
e2e4bb6c2a QML UI: change order of cloud backend accesses
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:28:05 -07:00
Dirk Hohndel
9f7e509f9a QML UI: break the sync into explicit save local and save cloud
This makes the code much cleaner and easier to understand and should allow
us to then switch back to doing at least the local save right after we make
any changes to the data.

This commit also tries to make sure that the accessingCloud status stays
correct and consistent throughout all the various success and error paths.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06 11:47:12 -07:00
Dirk Hohndel
961b80ec20 QML UI: after successfully opening storage, store the filename
We rely on the filename being valid elsewhere in the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06 11:44:58 -07:00
Dirk Hohndel
6a23e0ef66 QML UI: save with unchanged credentials returns to dive list
If the user is on the credentials page, doesn't change the credentials
but simply taps on save, they now get back to the dive list.

Fixes #1047

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06 11:42:38 -07:00
Dirk Hohndel
922c945f5a QML UI: more hacking around with git progress reporting
I gave up on the magic numbers and instead report simply linear progress.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 23:39:54 -07:00