summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
AgeCommit message (Collapse)Author
2020-05-07cleanup: invert control-flow when resetting the core structuresGravatar Berthold Stoeger
To reset the core data structures, the mobile and desktop UIs were calling into the dive-list models, which then reset the core data structures, themselves and the unrelated locationinformation model. The UI code then reset various other things, such as the TankInformation model or the map. . This was unsatisfying from a control-flow perspective, as the models should display the core data, not act on it. Moreover, this meant lots of intricate intermodule-dependencies. Thus, straighten up the control flow: give the C core the possibility to send a "all data reset" event. And do that in those functions that reset the core data structures. Let each module react to this event by itself. This removes inter-module dependencies. For example, the MainWindow now doesn't have to reset the TankInfoModel or the MapWidget. Then, to reset the core data structures, let the UI code simply directly call the respective core functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21cleanup: replace constructs of the type &vector[0] by vector.data()Gravatar Berthold Stoeger
It appears that some misguided compiler / library combinations crash on &vector[0] for empty vectors. Even though very unfriendly, they are technically correct, so let's remove these constructs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13mobile: don't call main loop for notifications once initializedGravatar Berthold Stoeger
Calling qApp->processEvents() in QMLManager::setNotificationText() caused crashes, because it could lead to the context-menu that initialized the call being deleted. Something that QML apparently doesn't like. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile/startup: fix potential crash when switching back and forthGravatar Dirk Hohndel
If the user switches away from Subsurface-mobile and back while we are in our initialization phase, that code might run more than once leading to undesirable results. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cleanup: create helper function to hide verbose castsGravatar Dirk Hohndel
The strange enum casts (that apparently we needed in order to have strongly typed enums in QML) are really ugly and confusing in the code. Since we had this three times it seemed worth to create a little helper that hides this nonsense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cloud-storage: correctly transition from no-cloud to cloudGravatar Dirk Hohndel
We know that we have valid credentials, so calling openLocalThenRemote() makes no sense, worse, it doesn't respect the special case of transitioning between accounts. That's the whole point of having a separate loadDivesWithValidCredentials() call. Once we have transitioned state, we need to record the now current state as the old state so that future transitions will work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cloud-storage: fix test for no cloud to cloud transitionGravatar Dirk Hohndel
The noCloud variable contains our desired state, we need to test for the previous state for this to make sense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/cleanup: remove outdated comment and fix whitespaceGravatar Dirk Hohndel
We haven't supported the GPS web service for a long time. Also, add another message for the log to be able to more easily trace one error case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/undo: set undo stack as clean after saveGravatar Berthold Stoeger
If we're using the undo stack for determining the whether there are unsaved changes, we have to mark the undo stack as clean after save. This duplicates code from desktop. It is planned to unify this in the near future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile/undo: consider undo-stack when checking for unsaved changesGravatar Berthold Stoeger
In analogy to desktop, also consider the state of the undo-stack when testing for unsaved changes. This prevents us from missing changes. This adds duplicate code, which will be unified in the near future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile/edits: ensure changesNeedSaving is calledGravatar Dirk Hohndel
These appear to be the only cases where we forgot to ensure data is saved. And pastDiveData is currently not called as the UI to use it has been removed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile: when creating gps dive site use the new dive site nameGravatar Berthold Stoeger
The code was using the pre-editing dive site name, which appears weird. Not sure if that was on purpose. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile: properly recognize changed dive siteGravatar Berthold Stoeger
QMLManager::checkLocation() would only return true if the dive-site itself was changed, not if the dive-site was set to a different site. Thus, in some cases edit events could be lost. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04mobile UI: delay reading the dive list until app is activeGravatar Dirk Hohndel
This way the launch screen is shown significantly shorter on a device, and instead the user sees our progress notifications. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/core: remove locking for git accessGravatar Dirk Hohndel
We have convinced ourselves that only the main thread will ever trigger a save operation, therefore the locking is not needed (and it has recently started to cause user problems where local changes aren't saved to storage and get lost). Fixes #2718 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile/startup: show progress update earlierGravatar Dirk Hohndel
Instead of not showing a notification until after we are done loading the data into our models, tell the user that we are about to do that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile UI: setup callback for the new notification mechanismGravatar Dirk Hohndel
This simply passes the text to the existing notification text mechanism. The call to processEvents() ensures that Qt processes the UI events after we updated the notification and that the user gets timely updates; otherwise the UI might look like the app is hanging. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04mobile: add indication if the app has finished initializingGravatar Dirk Hohndel
This will help us to ensure that notifications are actually shown on the UI during the startup phase. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04undo/mobile: keep track of dive sitesGravatar Berthold Stoeger
When editing the dive site of a dive, the dive-table of the corresponding dive site was not properly updated by the undo commands. Try to get this right. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31mobile: don't call saveChangesLocal() twice on non-iOSGravatar Berthold Stoeger
QMLManager::changesNeedSaving() behaves differently on iOS: it only saves locally with saveChangesLocal(), whereas all other OS save to cloud with saveChangesCloud(). Nevertheless, even for other OS saveChangesLocal() is called even though that will be called in saveChancesCloud anyway. Therefore, compile the saveChangesLocal() call in changesNeedSaving conditionally. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30mobile/dive-list: add indicator that dive list is being processedGravatar Dirk Hohndel
This should deal with the rather confusing 'No dive in dive list' shown while loading and processing the dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-29mobile/cleanup: use a mutex to protect storage accessGravatar Dirk Hohndel
Instead of the crude and error prone bool, let's just use the right tool for this job. In order to avoid issues with a goto across a mutex boundary, this slightly restructures the code in one place - 'git show -w' makes it clear that this is really rather simple in its changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-28mobile/save-changes: untangle the handling of alreadySavingGravatar Dirk Hohndel
I'm suspicious that an issue that some people have seen around changes not being saved is caused by our handling of alreadySaving. When starting with Subsurface-mobile in no-autosync mode, we were able to end in a scenario where alreadySaving was true, even though there were no unsaved changes. And in that case no changes made during such a session were saved unless the user forced a manual sync with the server. This commit radically changes our approach to handling the flag. It moves it right next to the actual calls into code that could modify git storage, and ensures that the flag can never stay set. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-28mobile/cleanup: tiny coding style issue that bugged meGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26iOS: ensure changes are saved locallyGravatar Dirk Hohndel
This was disabled in the past because it was deemed to slow. A lot of time has passed, since. Maybe on current phones / iPads this is acceptable again? Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26cleanup: remove dead codeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26mobile/dive-list: add ability to create tripGravatar Dirk Hohndel
This adds a context menu entry for top level dives that allows the user to create a trip for that dive. Unfortunately this creates a new string to translate right before a release... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21mobile/divelist: add UI to toggle dive invalid flagGravatar Dirk Hohndel
This reuses the corresponding undo command. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-18mobile: remove QMLManager::updateSiteList()Gravatar Berthold Stoeger
The location information model is updated automatically by the divelist-model and the undo commands. Therefore remove the QMLManager::updateSiteList() function. We do have to keep the locationListChanged() signal though, because the list of dive sites is not exported via model/view but rather via a Q_PROPERTY. We really should change that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17git: load into arbitrary dive tablesGravatar Berthold Stoeger
The git parser loads into the global dive table, even if it is called indirectly via parse_file(). However, parse_file() may be given a different table. Fix this by extending the git parser state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17mobile/cleanup: add some more log messagesGravatar Dirk Hohndel
This will help understand the control flow in the log. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-17mobile/cleanup: remove the second access to cloud dataGravatar Dirk Hohndel
While I remember some of the thinking that went into doing things this way, the more I read the code, the less it makes sense to me. This is a rather drastic step, but in reasonably extensive testing it seems to work in every case that I tried. That's rather embarrassing, actually. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-17mobile/edit: don't add dive site twice to tableGravatar Berthold Stoeger
When editing a dive on mobile we might have to create a new dive site. That site is added to the global dive site table in the undo command. However, the code in QMLManager created the dive site with create_dive_site*() functions, which already adds it to the table. The undo command then added the dive site again leading to a hang of the application. To solve this problem, create new alloc_dive_site*() functions that do the same as create_dive_site*() but do not add it to the table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-16mobile/DC-download: show USB devices before BT/BLEGravatar Dirk Hohndel
This makes sense because USB devices will only show up when connected, while BT/BLE will get listed once they are paired, even if not currently connected. So the higher likelihood of being the device a user is looking for is for any USB devices that show up, so those should go first. Suggested-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: better memory managementGravatar Dirk Hohndel
Instead of relying on the std::vector staying unchanged and not freeing its members, instead keep a copy of the object in our DCDeviceData class. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: simply restart the download after receiving permissionGravatar Dirk Hohndel
If the user tries to download from a device that he hasn't given the app permission to read from, Android will pop up a dialogue asking for that permission. With this after giving the permission we continue (well, technically, restart) the download which is likely the expected behavior. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16mobile UI: rescan button on DC Download page rescans BT/BLE/USBGravatar Dirk Hohndel
This way even if a USB device wasn't added through an Android intent, we still have a way to scan for it and select it. This is especially important in case a user has a cable that we haven't seen yet (i.e. with a VID/PID that we haven't added to Subsurface-mobile), but that nevertheless works with the android usb serial drivers. This also makes the flow a little more logical / consistent when deciding which connections to show. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: pass in the UsbDevice when downloadingGravatar Dirk Hohndel
This finally allows us to download from not just the first device, but specifically the device that the user picks. Passing the object through a void pointer is not nice - but since this traverses C code other solutions (like passing an index into the list) seemed even worse. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: parse the usbDevice when responding to intentGravatar Dirk Hohndel
This vastly simplifies our handling of devive information as we simply use what is already in the descriptor. This way we do not duplicate information about USB devices in the QMLManager. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12mobile UI: make user and log messages consistent for no cloudGravatar Dirk Hohndel
A number of our messages were misleading in the no cloud case. This should help to reduce confusion. Adding the save_dives() call after creation of the repo appears to help us have a valid repo in place. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-11Grammar: replaces 'indexes' by 'indices'Gravatar Robert C. Helling
Grammar-nazi ran git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g' to prevent future wincing when reading the source code. Unfortunatly, Qt itself is infected as in QModelIndexList QItemSelection::indexes() const Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-10Android: remove USB devices we don't supportGravatar Dirk Hohndel
The HID devices and the Atomics Aquatics Cobalt cannot work on Android right now. We should claim to support them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile: add ability to update trip detailsGravatar Dirk Hohndel
This creates up to two undo events. This seems like such a small issue that it's not worth creating yet another undo command for this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile UI: don't call into the event loopGravatar Dirk Hohndel
While this has worked fine for a long time, it now suddenly seems to trigger crashes. So let's not do that (there are a number of discussions online that talk about how this could indeed lead to BadThings(tm) happening. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile/trip-handling: add helper to add dive to a tripGravatar Dirk Hohndel
This again uses an undo command and should be completely symmetrical to removing a dive from a trip. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile UI: add ability to remove dive from its tripGravatar Dirk Hohndel
If we remove the newest dive from its trip, it becomes inaccessible in the app, but the dive data saved to disk appears to be correct. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile: replace undoDelete() with generic undo()Gravatar Dirk Hohndel
Since we are using the existing command infrastructure, this isn't specific to undoing a delete. This commit renames the function and removes its use in the UI, the next commit will then add the generic undo to the UI. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile UI: make the text of the undo/redo action available to QMLGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile: remove no longer used DiveListModelGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile/filter: connect directly to filterGravatar Berthold Stoeger
Since the divelist model is now placed on top of the common models, we can directly reset the filter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>