aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets
AgeCommit message (Collapse)Author
2019-09-21Mobile: pass section directly to tripTitle() and tripShortDate()Gravatar Berthold Stoeger
Instead of converting the section-heading string to a trip-pointer in QML and pass that to the tripTitle() and tripShortDate() functions, pass the string and convert in C++ code. Hopefully, this makes the code more robust. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-21Mobile: don't show filter button when entering credentialsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Android: print Android HW informationGravatar Dirk Hohndel
This uses Android methods through JNI. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Mobile: print out Qt information on the system we are running onGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Mobile: dump the information QML has about the screenGravatar Dirk Hohndel
Maybe this will allow us to customize things for certain devices? Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Mobile: correct font size of 'Previously used DC' labelGravatar Dirk Hohndel
This appears to be the one label where we didn't set the correct font size based on the global scaling. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Mobile: recalculate gridUnit and font size if width changesGravatar Dirk Hohndel
This could happen when you rotate a mobile device, or when running Subsurface-mobile on the desktop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21Mobile: move gridUnit and font adjustment to functionGravatar Dirk Hohndel
This way we can call it in other situations when needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-14Mobile: don't generate numerous DiveObjectHelpers in startEditMode()Gravatar Berthold Stoeger
Since that object is very heavy, generate one object and read out all the necessary values. The old code accessed the model again and again. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: transform DiveObjectHelper into value-typeGravatar Berthold Stoeger
Instead of handing a reference-to-dive to QML, prerender all the needed properties and store them as values in DiveObjectHelper. Exception: - date(): generated from timestamp - time(): generated from timestamp - cylinderList(): does not depend on dive anyway and should be made static. This hopefully avoids the random mobile crashes that we are seeing. Clearly, this code needs to be optimized, but it is a start. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: remove dive argument from DiveListModel::insertDive()Gravatar Berthold Stoeger
Since DiveListModel does not keep its own list of dives anymore, insertDive() doesn't use the DiveObjectHelper argument. Remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-14Mobile: replace clear()/addAllDives() pairs by reload()Gravatar Berthold Stoeger
The clear()/addAllDives() pair was bogus as the former didn't clear the model (this is not possible anymore - the model represents the core dive list) and the latter readded all dives again. Replace this by a reload() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return depthDuration directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this data directly from the model. In this case, don't remove from DiveObjectHelper, as these data might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return location directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return dive-number directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return dive-id directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. In this case, don't remove from DiveObjectHelper, as this datum might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: return dateTime directly from DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this data directly from the model. In this case, don't remove from DiveObjectHelper, as these data might be used by grantlee templates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: move tripNrDive from DiveObjectHelper to DiveListModelGravatar Berthold Stoeger
We don't want to generate a DiveObjectHelper numerous times for every item in the dive list. Therefore, return this datum directly from the model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: move tripId from DiveObjectHelper to DiveListModelGravatar Berthold Stoeger
The canonical way of displaying lists in Qt is via models. Thus, return the tripId directly from the DiveListModel instead of going indirectly via a DiveObjectHelper. In the future, this will allow us to make the DiveObjectHelper value-based, as it is not generated numerous times for every list item. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-11Mobile: deal better with incorrect credentialsGravatar Dirk Hohndel
This could happen if the password was changed from a different Subsurface instance. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11Mobile: check if credentials are valid before accepting themGravatar Dirk Hohndel
It seems crazy to simply assume that the later code can successfully untangle the various states that the credentials can be in - let's just stay on the credentials enrty page until we have verified credentials. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-09-11Mobile: adjust grid unit on very narrow screensGravatar Dirk Hohndel
If the default font size is big enough to leave us fewer than 21 grid units per row, shrink the grid unit. In order for this to create consistent results, we need to reduce the default column width to 21 grid units as well. And with that change, the columnWidth property becomes obsolete. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11Mobile: reserve space for the hamburger menu on Download pageGravatar Dirk Hohndel
Having a label with no width that can expand wasn't really a great way to do so. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11Mobile: use a default weight name when adding weight systemGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11Mobile: support editing of dives with no weightsystemGravatar Berthold Stoeger
If a dive has no weightsystems, editing the weight system has to add a new entry in the table. Implement that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10Mobile: catch null references in DownloadDCThreadGravatar Berthold Stoeger
There are reported crashes on Android that suggest a null "tables" attribute in DownloadDCThread. This should never happen, as the table() function connected to this attribute returns the address of a subobject. Thus, even if the original DownloadThread is null, this would not return a null pointer (the subobject is not at address 0). Catch these null-object accesses and write a warning message to the console. Hopefully, this will help is localizing the problem. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-08-08Cleanup: move error reporting function declarations to errorhelper.hGravatar Berthold Stoeger
Move the declarations of the "report_error()" and "set_error_cb()" functions and the "verbose" variable to errorhelper.h. Thus, error-reporting translation units don't have to import the big dive.h header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Core: dynamically resize weight tableGravatar Berthold Stoeger
Replace the fixed-size weightsystem table by a dynamically relocated table. Reuse the table-macros used in other parts of the code. The table stores weightsystem entries, not pointers to weightsystems. Thus, ownership of the description string is taken when adding a weightsystem. An extra function adds a cloned weightsystem at the end of the table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19Cleanup: move trip-related functions into own translation unitGravatar Berthold Stoeger
These functions were spread out over dive.c and divelist.c. Move them into their own file to make all this a bit less monolithic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Mobile: add checkbox to force downloading all divesGravatar Dirk Hohndel
This has been a feature people have asked for quite frequently. It is taking up some valuable screen real estate - so the question could become if there should be a switch to enable / disable it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-25Update (and fix) device mobile ID's for Scubapro dive computersGravatar Linus Torvalds
I'm not sure this is actually relevant for anything any more, but this adds the USB device ID's for the Scubapro G2 Console and HUD versions. It also fixes things to use the proper vendor name (a bit too much cut-and-paste, where the code said "Suunto" instead of "Scubapro"). The real device ID changes are in libdivecomputer, this is just the Android xml list for recognized USB devices that likely nobody really uses. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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-04-12Dive site: add dive site ref-countingGravatar Berthold Stoeger
Instead of setting dive->dive_site directly, call the add_dive_to_dive_site() and unregister_dive_from_dive_site() functions. In the parser this turned out to be a bit tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: move parse-function declarations out of "dive.h"Gravatar Berthold Stoeger
Move the declaration of these functions to "file.h" and "parse.h" according to the translation unit they are defined in. Thus, not all users of "dive.h" have to suck in "sqlite3.h". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: set UUID only on save or loadGravatar Berthold Stoeger
Since the UUID will be overwritten on save and is only used on save and load, set it only on save or load. For other created dive sites, leave the UUID field uninitialized. This means that the UUID will change between saves. Let's see how the git saver handles that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: make undo-system dive site-awareGravatar Berthold Stoeger
As opposed to dive trips, dive sites were always directly added to the global table, even on import. Instead, parse the divesites into a distinct table and merge them on import. Currently, this does not do any merging of dive sites, i.e. dive sites are considered as either equal or different. Nevertheless, merging of data should be rather easy to implement and simply follow the code of the dive merging. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Parser: parse into custom dive site tableGravatar Berthold Stoeger
To extend the undo system to dive sites, the importers and downloaders must not parse directly into the global dive site table. Instead, pass a dive_site_table argument to parse into. For now, always pass the global dive_site_table so that this commit should not cause any functional change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add dive site table parameter to dive site functionsGravatar Berthold Stoeger
To enable undo of dive site functions, it is crucial to work with different dive site tables. Therefore add a dive site table parameter to dive site functions. For now, always pass the global dive site table. Thus, this commit shouldn't alter any functionality. After this change, a simple search for dive_site_table reveals all places where the global dive site table is accessed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12get rid of some foreach and Q_FOREACH constructsGravatar Rolf Eike Beer
See https://www.kdab.com/goodbye-q_foreach/ This is reduced to the places where the container is const or can be made const without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7) and std::as_const (C++17) are not available in all supported setups. Also do some minor cleanups along the way. Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-03-27Cleanup: provide printGPSCoords in C and C++ versionsGravatar Berthold Stoeger
printGPSCoords() returned a newly allocated C-style string. Most callers simply made a QString out of it and freed the C-style string. This is paradoxical, as printGPSCoords internally works with QStrings and converts them to C-style on return. Therefore, let printGPSCoords() return a QString and create a printGPSCoordsC() wrapper for the two C-callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-24Cleanup: fix printGPSCoords signature and leaksGravatar Berthold Stoeger
The printGPSCoords() function returns a copied C-style string. Since the owndership is transferred to the caller, the correct return type is "char *" instead of "const char *". Thus a number of casts when calling free can be removed. Moreover a number of callers didn't free the string and thus were leaking memory. Fix them. Ultimately we might want two versions of the function: one for QString, one for C-style strings. 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: 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>