aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.h
AgeCommit message (Collapse)Author
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-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-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-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-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/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: remove selectedDiveTimeStamp logicGravatar Berthold Stoeger
Since the selection is now handled in the core this is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile: remove updateSelectedDive logicGravatar Berthold Stoeger
Selection is now be handled by the core. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile/undo: create EditDive commandGravatar Berthold Stoeger
Command that just swaps two dives. This is rather complex, as for example a dive site might be created. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile UI: use undo-command for adding dive.Gravatar Berthold Stoeger
Instead of using the model, copy the code we have in the desktop version which manually creates a 15m/40min dive and passes that to the addDive undo command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile/divelist: select dive after swipeGravatar Berthold Stoeger
After swiping through the dive list, select the currently visible dive. Thus, the dive is highlighted in the overview pane. The connection with the QMLManager feels atrocious, but I would prefer to have as little logic in QML as possible. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile/divelist: don't set currentIndex on undo of dive deletionGravatar Berthold Stoeger
The core sets the current dive when undoing something. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile/divelist: when clicking on a row, use select_single_dive()Gravatar Berthold Stoeger
This is a small step in unifying mobile and desktop. I'm unsure whether it is correct to play this via the QMLManager or whether we should call form QML directly into the model? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09mobile/undo: remove deletedDive and deletedTrip from QMLManagerGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile/undo: create undo-action and connect to undo of dive deletionGravatar Berthold Stoeger
Still buggy: Removing a dive followed by undo shows the wrong dive in the list. But clicking on it gives the correct dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09cleanup: fix NOCLOUD_LOCALSTORAGE leakGravatar Berthold Stoeger
The macro NOCLOUD_LOCALSTORAGE creates the path to the local git repository as a C-string. None of the users were freeing the string and thus leaking memory. Replace the macro by an inline function that creates a QString and pass down to C-functions using the qPrintable() macro. Note that every qPrintable() invocation does a UTF16->UTF8 conversion. This could be avoided by either using a std::string or a QByteArray. However, we are talking about microseconds of CPU time in operations that typically take seconds. Not worth it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-07debug: try to capture changes that don't invalidate git cacheGravatar Dirk Hohndel
At least in those cases where we are sending a divesChanged signal we can easily check if the cache was properly invalidated. Of course this won't help in cases where we don't notify the dive list about changes, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01filter: introduce people- and tags-filtering in the mobile UIGravatar Berthold Stoeger
Add a combo-box where the user can switch between "fulltext", "people" and "tags" filtering. Connect the combobox to the already existing filter-code. Dirk: make combo-box smaller by using a smaller font and restricting the width. Setting both maximum and preferred widths gives more consistent results. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-17mobile/export: remove most of the export optionsGravatar Dirk Hohndel
A tablet or phone is not a computer. What would you do with a CSV or TeX/LaTeX file on a phone. Yeah, I get it, feature parity. This should never have been merged. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-29mobile-widgets: add oldStatus variable to qmlmanagerGravatar jan Iversen
oldStatus() is kept in qmlPrefs during the login process to allow for a couple of special cases: - if a user have added dives in NO_CLOUD mode and changes to use the cloud these dives are copied to the Cloud, instead of being lost. - if a user does a bailout from the login process (this should not happen anymore) the old status is restored. The pure solution would be to have oldStatus at the top level (e.g. a property in qml) and only change it when actually being in the login process, however due to way the qmlmanager is written it proved very difficult and not worth the effort. In order to be able to remove qmlPrefs, oldStatus are moved to qmlManager. This commit only contain the creation of the variable and the supporting code. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28mobile-widgets: make verifyCredentials() an internal functionGravatar jan Iversen
Move verifyCredentials() from public slots to private, eliminating the need to MOC and making the C++/QML interface on function less complicated. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-28mobile-widgets: make saveCredentials() an atomGravatar jan Iversen
Add pin parameter to saveCredentials() thereby having all info about credentials in one function call. Add "" as pin in saveCredentials() - main.qml, when verifying credentials. replace verifyCredentials() with saveCredentials() in the register button on the pin page. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-25mobile-widgets: make saveCredentials() an atomGravatar jan Iversen
Call saveCredentials with username/password to avoid first setting the two and then calling. Change saveCredentials() to use newUser, newPassword. Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-12mobile-widgets: activate uploadDiveShare in qmlmanagerGravatar jan Iversen
Remove "TO BE IMPLEMENTED" and add call doUpload Connect signal to signal in QMLManager to avoid registring the upload class. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11mobile-widgets: make upload signals available to QMLGravatar jan Iversen
Connect signal to signal in QMLManager to avoid registring the upload class. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03mobile-widgets: add export functionality to qmlmanagerGravatar jan Iversen
Add enum with different export types (used to signal which type of export QML desires). Add QML export functions (one for file and one for upload to web) Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-10Mobile: add ability to directly open support emailGravatar Dirk Hohndel
This is even easier and more obvious than copying the logs on the About page and then manually creating an email and pasting those logs. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-21Mobile: allow editing dive numberGravatar Dirk Hohndel
No checks regarding duplicate numbers - we trust the user knows what they are doing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13Mobile: add helper function to keep selection in syncGravatar Dirk Hohndel
Without this the core data structure never gets updated to reflect which dive is currently selected. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-27Revert the singleton PRGravatar Dirk Hohndel
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-25Cleanup: unify idiosyncratic singletonsGravatar Berthold Stoeger
The way we handle singletons in QML, QML insists on allocating the objects. This leads to a very idiosyncratic way of handling singletons: The global instance pointer is set in the constructor. Unify all these by implementing a "SillySingleton" template. All of the weird singleton-classes can derive from this template and don't have to bother with reimplementing the instance() function with all the safety-checks, etc. This serves firstly as documentation but also improves debugging as we will now see wanted and unwanted creation and destruction of these weird singletons. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21Mobile: make sure QML gets notified when value changesGravatar Dirk Hohndel
This addresses the following warning when running the mobile app: INFO: QQmlExpression: Expression qrc:/qml/DownloadFromDiveComputer.qml:339:5 depends on non-NOTIFYable properties: INFO: QMLManager::DC_forceDownload Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-14Mobile: use value semantics for DiveObjectHelper in qmlmanager.cppGravatar Berthold Stoeger
Instead of creating a pointer-to-DiveObjectHelper in commitChanges, use a normal object. Thus, we don't have to think about ownership issues with respect to this object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-11Mobile: add helper function to check cloud credentialsGravatar Dirk Hohndel
This should do the right thing in the various situations of correct & verified credentials, credentials needing PIN verification, invalid email/password combination, incorrect PIN, correct PIN. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-10Mobile: update dive site model if dive sites are createdGravatar Berthold Stoeger
Always keep the dive site model up to date when adding dive sites. This hopefully avoids creation of invalid indexes followed by crashes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: introduce proxy model DiveSiteSortedModelGravatar Berthold Stoeger
The LocationInformationModel used to sort its entries and was completely rebuilt after every change. This makes it rather complex to support incremental changes. Instead, keep LocationInformationModel sorted by UUID so that indexes are consistent with indices in the core dive site table. Implement sorting by other columns than name and enable sorting in the dive site view. Finally, don't cache the list of dive site names for the mobile app, since that would also need some rather convoluted methods of keeping the list up to date. Calculate it on the fly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-14Mobile: only show dive computers in the Bluetooth connection listGravatar Dirk Hohndel
And offer an option to show all devices in the settings. This is intentionally not stored in the preferences as this should never be needed. We don't support BT or BLE dive computers that we don't recognize. This is a last resort in case a new firmware were to change the name or some other weird issue causes us not to recognize a dive computer - and that should be fixed instead of worked around. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-19Import: don't add to new trip while downloadingGravatar Berthold Stoeger
Since process_imported_dives() can add dives to a newly generated trip, this need not be done in the downloading code. This makes data flow distinctly simpler, as no trip table and no add-new-trip flag has to be passed down to the libdivecomputer glue code. Moreover, since now the trip creation is done at the import step rather than the download step, the latest status of the "add to new trip" checkbox will be considered. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-21Mobile: add helper function to fill in the BT nameGravatar Dirk Hohndel
For some devices the BT device name is different from the product name. Make sure that name is available to the mobile UI. This helper fills it in from the scan data (based on the device address). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>