aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets
AgeCommit message (Collapse)Author
2019-01-19Import: control process_imported_dives() by flagsGravatar Berthold Stoeger
process_imported_dives() takes four boolean parameters. Replace these by flags. This makes the function calls much more descriptive. Morover, it becomes easier to add or remove flags. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
2019-01-19Import: add add_to_new_trip flag to process_imported_dives()Gravatar Berthold Stoeger
If this flag is set, dives that are not assigned to a trip will be assigned to a new trip. This flag is set if the user checked "add to new trip" in the download dialog of the desktop version. Currently this is a no-op as the dives will already have been added to a new trip by the downloading code. This will be removed in a subsequent commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: split process_imported_dives() functionGravatar Berthold Stoeger
Split the process_imported_dives() function in two: 1) process_imported_dives() processes the dives and generates a list of dives and trips to be added and removed. 2) add_imported_dives() calls process_imported_dives() and does the actual removal / addition of dives and trips. The goal is to split preparation and actual work, to make dive import undo-able. The code adds extra checks to never merge into the same dive twice, as this would lead to a double-free() bug. This should in principle never happen, as dives that compare equal according to is_same_dive() are merged in the imported-dives list, but perhaps in some pathologival corner-cases is_same_dive() turns out to be non-transitive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: add merge_all_trips parameter to process_imported_dives()Gravatar Berthold Stoeger
When importing log-files we generally want to merge trips. But when downloading and the user chose "generate new trip", that new trip should not be merged into existing trips. Therefore, add a "merge_all_trips" parameter to process_imported_dives(). If false only autogenerated trips [via autogroup] will be merged. In the future we might want to let the user choose if trips should be merged when importing log-files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: merge dives trip-wiseGravatar Berthold Stoeger
The old way of merging log-files was not well defined: Trips were recognized as the same if and only if the first dives started at the same instant. Later dives did not matter. Change this to merge dives if they are overlapping. Moreover, on parsing and download generate trips in a separate trip-table. This will be fundamental for undo of dive-import: Firstly, we don't want to mix trips of imported and not-yet imported dives. Secondly, by merging trip-wise, we can autogroup the dives in the import-data to trips and merge these at once. This will simplify the code to decide to which trip dives should be autogrouped. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Import: add trip_table argument to DiveImportedModel::repopulate()Gravatar Berthold Stoeger
In the future we want to download trips into a distinct trip-table instead of the global trip-table to allow for undo of import. Therefore add a trip_table argument to DiveImportedModel::repopulate() and a trip_table member to DiveImportedModel. To correctly set these, add a DownloadThread::trips() function, which currently simply returns the global trip table. Finally, make "struct trip_table *" a Q_METATYPE, so that the corresponding arguments can be passed from QML. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Parser: add trip_table parameter to parsing functionsGravatar Berthold Stoeger
To allow parsing into arbitrary trip_tables, add the corresponding parameter to the parsing functions and the parser state. Currently, all callers pass the global trip_table so there should be no change in functionality. These arguments will be replaced in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Core: add trip_table parameter to trip-functionsGravatar Berthold Stoeger
Currently trips are added to the global trip table. If we want to make dive-import undoable, we should be able to parse trips of a log-file into a distinct table. Therefore, add a trip_table parameter to - insert_trip() - create_and_hookup_trip_from_dive() - autogroup_dives() - unregister_trip() - remove_dive_from_trip() Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Core: keep trips in table(s)Gravatar Berthold Stoeger
Currently, all trips are kept in a linked list. Replace the list by a table in analogy to dive_table. Use this to keep the trip_table sorted as suggested by dump_trip_list(). When inserting a trip into the table do that after adding the dives, to avoid warnings coming out of dump_trip_list(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09Core: Rename functions to more generic namesGravatar Berthold Stoeger
Rename - dive_get_insertion_index() -> dive_table_get_insertion_index() - unregister_dive_from_table() -> remove_from_dive_table() - get_idx_in_table() -> get_idx_in_dive_table() - sort_table() -> sort_dive_table() This will make it more straight-forward to generate these functions from macros. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-02update year to 2019 in about screensGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-12-29Mobile: fix editing dive siteGravatar Berthold Stoeger
Commit 68961a169efc37039cd3fda334efb9ad9927444f made it impossible to edit a dive site on mobile if a dive-site was already set: If divesite was non-null, no actions were taken. Remove the conditional. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-21Mobile: deal with BT name and address when tapping DownloadGravatar Dirk Hohndel
Instead of trying to update this whenever the connection text changes, instead deal with it right before it actually gets used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
2018-12-21Mobile: force update of ui on pasteGravatar Miika Turkia
Apparently this does the trick of updating the dive list when pasting data on mobile. Tnx janmulder. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21Mobile: initialize copy variablesGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21Mobile: copy the dive data when configuring settingsGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21Mobile: UI for selecting what to copy-pasteGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-17Import: unglobalize downloadTableGravatar Berthold Stoeger
To make data flow more clear, unglobalize the downloadTable object. Make it a subobject of DownloadThread. The difficult part was making this compatible with QML, because somehow the pointer to the download-table has to be passed to the DiveImportedModel. Desktop would simply pass it to the constructor. But with objects generated in QML this is not possible. Instead, pass the table in the repopulate() function. This seems to make sense, but for this to work, we have to declare pointer-to-dive-table as a Q_METATYPE. And this only works if we use a typedef, because MOC removes the "struct" from "struct dive_table". This leads to compilation errors, because dive_table is the symbol-name of the global dive table! Sigh. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17Cleanup: make DCDeviceData a "normal" singletonGravatar Berthold Stoeger
DCDeviceData was using that weird pattern where the instance variable was set in the constructor. There is no apparent reason to do so, therefore convert to a "normal" singleton. Access that directly in QMLManager instead of saving it in a member variable first. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23Mobile: don't format trip heading for all divesGravatar Berthold Stoeger
QML's ListView uses the "section" property to test if items belong to the same section. Apparently, this must be a string and therefore we can't pass e.g. a dive-trip object. Therefore a specially formatted string was passed in, which was guaranteed to be unique (contained the dive-trip pointer value) and the fully formatted trip-title and short-date. The disadvantage of that approach is that the formatting is performed for every dive and not every trip. Perhaps not a problem now, but it makes it for example necessary to cache the number of filtered dives. To be more flexible, pass in only the pointer value formatted as hexadecimal string and provide a function to convert that string back to a trip-pointer (in the form of a QVariant, so that it can be passed to QML). Moreover provide two functions for formatting the title and the short-date. The three new functions are members of DiveListSortModel. This might not be the perfect place, but it is easy to reach from the DiveListView. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-20Core: replace tripflag by notrip booleanGravatar Berthold Stoeger
The only remaining use of the tripflag was to mark dives that were removed explicitly from a trip, i.e. shouldn't be autogrouped. Therefore replace the enum by a simple boolean. Currently, there is no way of unsetting the notrip flag. But this shouldn't result in a user-visible change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-18Dive list: replace dive-list of trips by a tableGravatar Berthold Stoeger
The dives of each trip were kept in a list. Replace this by a struct dive_table. This will make it significantly easier to keep the dives of a trip in sorted state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-18Core: unify insert_trip() and insert_trip_dont_merge()Gravatar Berthold Stoeger
There were two versions of the insert_trip() function: one would merge trips if a trip with the same date already existed, the other wouldn't. The latter was introduced with the dive-list undo work. The problem is that the "date" of a trip (i.e. the first dive) seems ill-defined as this is a volatile value. Moreover in the context of making dive-import undoable this is a very dangerous notion, as the caller needs control over when the dives are added to a trip. Therefore, unify these two functions and never merge trips. The decision on merging dives now has to made by the caller. This will be implemented in a future commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-18Mobile: visual indication for copy and paste operationsGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18Mark cache invalid to get data savedGravatar Miika Turkia
Seems that we need to invalidate the cache to get the modifications actually saved. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18delete-copy-paste buttons layed out properlyGravatar Miika Turkia
Now these buttons are finally shown with long press and seem to be working more-or-less as intended. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18Verify that copy is doneGravatar Miika Turkia
Naturally the paste button should be disabled, if this is the case, but it still makes sense to do this check. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18Support for copy-pasting specific fields on mobileGravatar Miika Turkia
Initial implementation/prototype of copy-paste support for Subsurface-mobile. The UI part is really lacking; right now the copy button is initially visible and paste is achieved by long press on a dive and clicking the paste button when it appears. Delete is currently not possible at all, as I just failed to layout the buttons properly using QML. It just sounds so simple, to put all the copy-paste-delete buttons next to each other... The data to be copied is currently hard-coded. A dialog to choose inteded fields would be nice, but it'll take quite a bit effort to get used to QML enough to be able to hack something together. Anyway, this seems to work, even though the UI is not always reflecting the paste without switching dives (when testing on laptop). Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-15Mobile: Allow multiple divemastersGravatar Jocke
While not something that many will use, editing a dive on Subsurface-mobile should not result in data loss. This makes the divemaster field behave in the same way as the buddy field with regards to multiple entries. Fixes #1853 Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-31Mobile/filtering: don't show the filter line when pulling divelist downGravatar Dirk Hohndel
Even though the height was zero, when pulling down the dive list for refresh, the filter input line would still be visible. With this fix it no longer is. Also remove unused property. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-29Dive site: replace dive->dive_site_uuid by dive_siteGravatar Berthold Stoeger
Replace the UUID reference of struct dive by a pointer to dive_site. This commit is rather large in lines, but nevertheless quite simple since most of the UUID->pointer work was done in previous commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: replace UUID by pointer in mobile codeGravatar Berthold Stoeger
Replace UUIDs by pointers to dive-site in mobile code. In both cases, the value is transported via a QVariant. The function getCoordinatesForUUID(), which was only used from mobile, can be replaced by a getCoordinatesFor() function taking a variant supposed to contain a dive-site pointer. Likewise, the variant of the centerOnDiveSite function is now supposed to wrap a pointer-to-divesite. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: return pointer to dive_site in create_dive_site_*()Gravatar Berthold Stoeger
This changes more of the dive-site interface to return pointers instead of UUIDs. Currently, most call sites directly extract UUIDs afterwards. Ultimately, the UUIDs will be generally replaced by pointers, which will then simplify these callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: return pointer to dive_site in get_dive_site_*()Gravatar Berthold Stoeger
As a first step in removing dive-site uuids, change the interface of the get_dive_site_*() functions to return pointers instead of uuids. This makes code a bit more complicated in places where the uuid is extracted afterwards (needed NULL check). Nevertheless, these places should disappear once pointers instead of uuids are stored in the dive-structures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-27QML UI: we don't need Controls 2.4Gravatar Dirk Hohndel
In commit 99c06dec3d ("Mobile/filtering: simple busy indicator") we switched to Controls 2.4 which requires Qt 5.11. Revert that one line of the commit as it isn't necessary. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: make busy indicator smallerGravatar Dirk Hohndel
Suggested-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: update number of dives shown when resetting filterGravatar Dirk Hohndel
Otherwise we start showing an illogical '0' there when first opening the filter dialog, and the equally wrong previous count when closing and then re-opening the filter dialog. Reported-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23QML UI: remove some of the log file noiseGravatar Dirk Hohndel
A couple came from this series, others are much older. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: show a better message while waiting for the filterGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: implement the filter update through a threadGravatar Dirk Hohndel
It's important to disconnect the model from the ListView, otherwise the update in a different thread will fail. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: remove redundant busy indicator on dive listGravatar Dirk Hohndel
We should use the global one instead. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: simplify the filter toggleGravatar Dirk Hohndel
Simply make it always reset the filter. There's no point remembering the last filter pattern and explicitly setting it, if the last thing we do is to reset this pattern. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: update filter in separate threadGravatar Dirk Hohndel
We can't use that while the model is shown, which is why this isn't hooked up. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: add properties for dive list model and filter textGravatar Dirk Hohndel
This allows us to modify those from different parts of the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23QML UI: add busy indicator to the main windowGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23QML UI: make the QML window object part of the QMLManager classGravatar Dirk Hohndel
This way we can access it from that code (which we'll need to invoke methods in QML code from C++). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: clean up whitespace from last commitGravatar Dirk Hohndel
This one does nothing but whitespace - separating it into two commits makes the previous one a lot easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23Mobile/filtering: add background rectangle for filter rowGravatar Dirk Hohndel
We are still trying to ensure that the filter is indeed shown in front of the dive list. This is working when running on the desktop without the rectangle, but on Android this appears to be needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>