aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
AgeCommit message (Collapse)Author
2016-09-17QML UI: deal with multiple buddies correctlyGravatar Joakim Bygdell
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-04Fix some warningsGravatar Dirk Hohndel
At least the warnings about size potentially being uninitialized seem correct and valid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04QML UI: Enable cylinder editGravatar Joakim Bygdell
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-08-27Settings update: Simplify code by using the SettingsObjectHelperGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Unify handling of QDateTime time zone informationGravatar Robert C. Helling
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-06-17QML UI: correctly check cloud verification statusGravatar Dirk Hohndel
Oops. That's embarrassing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13QML UI: allow entering the cloud PIN on the mobile UIGravatar Dirk Hohndel
Now the user doesn't need to do this on the desktop app anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13QML UI: prepare to enter the cloud PIN on mobile UIGravatar Dirk Hohndel
This just creates the properties to connect QML and C++ code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13QML UI: serialize checking credentialsGravatar Dirk Hohndel
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-12QML UI: don't proceed unless cloud credentials are verifiedGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-12QML UI: disable GPS functionality on iOSGravatar Dirk Hohndel
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-05-21Add init function to qmlmanagerGravatar Joakim Bygdell
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-04-30QML UI: when first entering cloud credentials, force cloud connectionGravatar Dirk Hohndel
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-30Connect to the reply, not the managerGravatar Dirk Hohndel
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-30QML UI: forceRemoteSync means connect even without unsaved changesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30QML UI: better diagnostics when cloud connection failsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30Only create the path to no cloud local storage onceGravatar Dirk Hohndel
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-30Fix logic for when to mark dive list as changedGravatar Dirk Hohndel
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-29QML UI: when switching from no cloud to cloud usage, don't drop local dataGravatar Dirk Hohndel
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-29QML UI: fix order of tests when saving changesGravatar Dirk Hohndel
Only check for previous cloud connection when actually trying to save to cloud Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29QML UI: make sure nothing is lost when changing cloud credentialsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27QML UI: handle failure to read local dive dataGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27only set index if we have specific targetGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27QML UI: with a local default file setup, open that at startGravatar Dirk Hohndel
And set no cloud mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27Add helper function for the consumption of loaded dive dataGravatar Dirk Hohndel
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-27QML UI: in no cloud mode, save to a default local repoGravatar Dirk Hohndel
And set that up as the default file to load at start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-19QML UI: correctly show if we are accessing remote or local storageGravatar Dirk Hohndel
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-19QML UI: always show the time stamp when logging dataGravatar Dirk Hohndel
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-17QML UI: make the state of the GPS service available to QMLGravatar Dirk Hohndel
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-15QML UI: quit on back key while showing dive listGravatar Dirk Hohndel
Make sure you save first, though. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15QML UI: rewrite the commitChanges functionGravatar Dirk Hohndel
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-15QML UI: fix the save to cloud logicGravatar Dirk Hohndel
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-15QML UI: stop using "--" for empty stringsGravatar Dirk Hohndel
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-14Copy coordinates when renaming siteGravatar Miika Turkia
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-14QML UI: don't try to scroll to dive at time 0Gravatar Dirk Hohndel
If no timestamp is available, just start at dive 0. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14QML UI: keep QML manager and the UI in sync about selected diveGravatar Dirk Hohndel
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-14QML UI: clear the flag indicating that we are accessing storageGravatar Dirk Hohndel
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-13Remove unused functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-11Upon undoing a dive deletion select that diveGravatar Robert Helling
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-11Fix wrong function call for desktop build of Subsurface-mobileGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-10QML UI: try to do the right thing for changes on all platformsGravatar Dirk Hohndel
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-08QML UI: only force network access when user asks us toGravatar Dirk Hohndel
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-08Simplify code - we now can rely on git_local_only to do the right thingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08QML UI: change order of cloud backend accessesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06QML UI: break the sync into explicit save local and save cloudGravatar Dirk Hohndel
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-06QML UI: after successfully opening storage, store the filenameGravatar Dirk Hohndel
We rely on the filename being valid elsewhere in the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06QML UI: save with unchanged credentials returns to dive listGravatar Dirk Hohndel
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-05QML UI: more hacking around with git progress reportingGravatar Dirk Hohndel
I gave up on the magic numbers and instead report simply linear progress. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05QML UI: don't fetch the remote twice when loadingGravatar Dirk Hohndel
We first check the sha to see if we want to load at all. But at that point we already have the repository and the branch and we have synced with the remote. So when we decide that we need to reload from storage, we don't need to repeat those steps, instead we can go directly to the git load. For that to work we need to pass the repository pointer and the branch name back to the caller so that we can directly call git_load_dives(). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05QML UI: restructure (and fix) the saveChanges logicGravatar Dirk Hohndel
We first want to save any exiting unsaved changes to the local repository (and ONLY to the local repository). After that we want to make sure that we are syncing remotely, fetch the remote and then (possibly after a merge) push the changes to the remote. In the end we reset the previous "local git only" preference which we overwrote for this manual forced sync. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>