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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Commit 68961a169e 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
We don't need to toggle visibility, toggling height is sufficient. This
dramatically simplifies the transitions. But as a result we need to use the
'enabled' property to reset the filter.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QML's logic for who gets focus is a bit complicated. But forceActiveFocus()
cuts through the confusion and makes sure that your field does indeed get
focus.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a usability / performance tradeoff. I like it better when it filters as
I type, but on mobile this may make things feel sluggish.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
[Dirk Hohndel: this is the starting point of my following commits, I decided to
leave it in place to give Jan credit for the work he did on
figuring out some of the plumbing needed to get things to work]
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add 2 icons for filter and sort capabilities. And as before, these
icons are coming from the Google Material design set.
[Dirk Hohndel: Jan's commit forgot to add the actual icons, I added
those so the commit matched its message]
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Back in 8ab8a67f the checkbox where made resizable.
This applies the same functionality to the selector switch and makes the
two objects match in vertical size.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Instead of having people treat latitude and longitude as separate
things, just add a 'location_t' data structure that contains both.
Almost all cases want to always act on them together.
This is really just prep-work for adding a few more locations that we
track: I want to add a entry/exit location to each dive (independent of
the dive site) because of how the Garmin Descent gives us the
information (and hopefully, some day, other dive computers too).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
There is no reason (any more?) to have a property defined
that basically renames the global pageStack into a local
pageView. Just cleanup.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
AddDivesToTrip, CreateTrip, AutogroupDives, RemoveAutogenTrips
and MergeTrips basically all did the same thing as RemoveDivesFromTrip,
which was already implemented. Thus, factor our the common functionality
and hook it up to make all these functions undo-able.
Don't do the autogroup-call everytime the dive-list is rebuilt
(that would create innumberable undo-actions), but only on dive-load /
import or if expressly asked by the user [by switching the autogroup
flag].
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Disable the Download button when one of the fields vendor, product,
connection is not filled in. The app will crash when trying.
In addition, make the underlying core code to actual download
more safe by checking this, and silently fail instead of crash.
And, yes, this is a double fix in this scenario, but the core code
is used in more places, so better safe than sorry.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The code to disable a quick button has moved to the DC matching logic,
in order to inactivate the correct button also for USB DCs.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
After the previous commits, we now have a preference that nicely
preserves the state of the UI, and we have the well known git_local_only
global, that is used to denote whether we want to use to local repo
only, or we want to interact with the online cloud as well.
This commit gets rid of the now superfluous syncToCloud logic. Instead
we simply set the git_local_only directly.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Hook up the new preference to the UI. So now, an earlier choice
if automatic or manual download to the cloud is preserved in
between sessions. Strictly speaking this fixes issue 1725.
Notice that there is also a higly related syncToCloud thing
present. As factoring out that seemingly duplicate piece
of code is non-trivial, this will be done in a seperate
commit.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
We disabled the drawer menu button to switch between auto/manual
sync when in no cloud mode. Unfortunately, disabeling does not
give a visual cue to the user (like greyed out). Instead, just
make this button invisable in no cloud mode.
In conjunction a question. The manual sync to cloud menu item
takes you to the Cloud Credetials page in case pressed in
no cloud mode. While valid, this seems strange. This is not
changed in this commit.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This simple one-liner fixes an actual bug. On switching from
a no-cloud account to a actual cloud account, the dives from
the no-cloud are added to the actual cloud account. And indeed
the dives appear correctly. However, when exiting the app
right away, these added dives are not commited to the local
storage. Simply, the divelist needs to be marked dirty.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The background color was plain white, where we use a slightly different
color in other places. In addition, the background when clicking on a row
did not follow the theme setting. Consistency fix.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Something I only see on mobile-on-desktop, so at this point in time
not very relevant to the device apps. When hovering on the action
button, a toast message shows a hint box. These where empty in some
cases. So, just give the actions a text attribute where it was
missing.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
process_imported_dives() is more efficient for downloaded than for
imported (from a file) dives, because it checks only the divecomputer
of the first dive.
This condition is checked via the "downloaded" flag of the first
dive. Instead, pass an argument to process_imported_dives().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Dives are now in all cases imported via distinct dive_tables.
Therefore the "preexisting" marker is useless. Remove.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When starting the mobile app, I noticed a short display of an empty
page with title "Cloud creditials" just before showing the
divelist. Simply a not nice visual effect.
This commit simplifies some logic and resolves this. As the code
in this part is fragile, this is tested for normal and clean
startup of the app, switching credentials, from no cloud to
valid account (which even nicely imports the no cloud dives:
this surprised me as I have never seen this working).
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
We need to delete all related data when forgetting dive computers or we will
have an issue if we connect a DC from the same vendor but of a different model.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Improve the logic when auto selecting a DC for download.
Some USB cables only supply vendor information but we can select the correct
model if we have downloaded from it before.
For BT/BLE our discovery process adds the device name to the address, so we need to keep that in mind when we try to match against what we seen before.
When we have a positive match for a DC we have seen before we deactivate the
corresponding button of our saved DCs.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
A technically trival commit, but one with long story. This commit
basically reverts dd1d90b529 (1.5 year ago). While upgrading
Kirigami after Kirigami commit 26b8bdea24c39, we suddenly have
overlapping divelist and details pages in case they are both
on the pageStack (this occurrs when navigating from divedetails
to the divelist using breadcrumb navigation). At this point, its
not clear (to me) if this the by design of Kirigami, or an unintended
effect of the mentioned Kirigami commit.
This all said. Simply clipping resolves our issue of overlapping
pages, and it does not harm.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Something that I simply overlooked earlier with respect to scaling the
divelist. The trip databox did scale a bit, but it was not nicely
related to the hight of the trip header. So there was a tiny
overflow on the small scale on a small device. Fixed here.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Partially cosmetic and partially a bug fix. 1) the seperator line
between trips and dives that are not in a trip was drawn in the
background color => the line was invisible. 2) When looking very
closely, there was a 1-2 pixel wide error between the seperator line
between trips and dives that are not in a trip. 3) there was a comment
that the trip separator needed to be extra thick. IMHO, this
looks ugly, and is superfluous as there is a nice sidebar along
the dives that belong to the trip. Finally, the line shall not
be displayed when not in a trip.
So, basically, the line (the QML rectangle) is completely rewritten,
to take care of all issues. There is 1 hack: the line color is
taken from the dive separator line. But its fully unclear to me
where that color is defined in Qt/QML or Kirigami, so I hardcoded
the proper color. That just works.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
A small cosmetic change. The delete from divelist button was "glued"
to the top of the line. Not nice, so just center it vertically, and
make the button a tiny bit smaller, so that it fits nicely on the line.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Fully usure why the code was as it was. The trip header had 2
overlapping mouse areas, to expand the trip and vise versa. Simply
remove the smallest one.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
A very unimportant change, but found when looking through the code
for places where size of icons where used. The one changed here
has nothing to do with icon related placement of a string, so
its replaced by a way more logical placement of the affected string.
Simply center the "no dives in the dive list" for an empty logbook
on the screen, instead of at some random place in the upper left
corner. Like I said: very unimportant, but it just looks nicer
in the UI.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
A relatively big change for such a simple page. Most relevant
changes are:
1) Do not use Kirigami.Header anymore. It appears that this header
has word wrapping on (and we cannot override that). This is
annoying on this page, as headings seems randomly be split over
2 lines, even in cases where there is more than enhough room to
display it on one line. And as the Kirigami.Header is just a
trivial wrapper of a Text field, we can simple replace it.
2) A lot of the toplevel GridLayouts had width properties set. These
are not needed (and confused my debugging code), so they are removed
withput any visual change. As a general rule, do not try to set
properties that are not needed. In general, it can only lead to
binding loops or undefined behavior.
3) Add a font size to our Theme. The step from regular to title size
was a little too big.
4) And, obviously, numerous font.pointSize lines are added to actually
resize the font.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
There was a strange big margin at the top of the the dive details
page. Just make it a bit more "normal".
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
There was a significant of not needed whitespace on the download from
DC page. Most importantly, the bottom buttons where not on the bottom,
so we had to truncate the downloaded dives early (to prevent overflowing
the buttons). Further, a tiny bit of padding is removed between the
3 top pull down items.
All this, results in the diplay of more dives without scrolling.
For example, previously, only 1 dive (with 1 stored DC) was shown
on my 5.5" device, and now 3 (scale: regular).
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Changed some hard coded size and positioning of the SsrfCheckBox,
in such a way that is scales nicely to the current setting of the
mobile_scale.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The select buttons in the downloaded dives delegate overlapped
the dive data. Simple margin change fixes this.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Make the ssrfButton and the pull down menu's on the download page
resizable. Notice that also the contents of the pulldown
menu's is scaled based on the font size.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
A user reported problems with editing the Suit and DiveMaster fields.
Apparently, editing does not change the currentText. Without doing
a deeper analysis, simply use editText (a more proper fix might be
changing the currentIndex on editing).
(Parially?) fixes#1694
Reported-by: Mark Powell <mcpowell123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Changing the scale, it seems that the header of trips is not rescaled.
The reason for this is simple. That string does not use our manipulated
font but a different one. In fact, this is the only ocurrence on the
divelist that did not scale. However, other screens hardly rescaled at
all. All these will be fixed in seperate commits.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
After the work in the previous commit, it gets very simple to implement
font scaling. Just assign a the new desired font scale to the used
font metrics. The QML engine does all the work.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
By manipulation the used font pointSize property, we can dynamically
scale fonts and derived UI objects. At the same time, we have
some logic to determine the default font, its size, etc, for example
depending on screen properties. The scaling of the UI (and its font)
does not need to interfere with those defaults.
However, when we want to reset the pointSize, we alter the default, so
a backup of the default is needed. Ok, not al full backup, as the only
thing we like to manipulate is the pointSize, to which we want to be
able to return.
All this leads to this commit. A basePointSize property is added, that
is initialized from the default. Due to the binding logic of the QML
engine, it is not a classic initialization, but a binding between the
2 properties. We need to break that binding explicitly, so that
the original PointSize is always preserved.
In addition, a display of the new font property is added to the
developers theme test.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This theme test display created a new local FontMetrics object, that
does not per definition correspond with the "global" font metric
as defined in main.qml. The fix is simple. Display the font theme
data based on the one and only font metric from main.qml
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
It seems the documentation is incorrect - unless you explicitly set the
ApplicationWindow font to the the Application Font (just writing this
down sounds so silly...), it doesn't actually work.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Disable the button for the currently selected DC.
This gives an extra visual hint of which DC is currently selected.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
To prevent stale data in the download DC path we need to clear the entire
qPrefDiveComputer.vendor() object when the user purges the used DCs.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Since we now store the last used DCs in out preferences we can use the information
to pre-populate the DC selector.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
process_dives() is used to post-process the dive table after loading
or importing. The first parameter states whether this was after
load or import.
Especially in the light of undo, load and import are fundamentally
different things. Notably, that latter should be undo-able, whereas
the former is not. Therefore, as a first step to make import undo-able,
split the function in two versions and remove the first parameter.
It turns out the the load-version is very light. It only sets the
DC nicknames and sorts the dive-table. There seems to be no reason
to merge dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We only store the address part of the connection name, so don't try to find an
exact match, try to find the sub-string.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need to explicitly refresh the divelist when switching between
metric and imperial unit systems. Or the changes will not be visible until
we restart the app or scroll outside of what's in the current cache.
This will update both the divelist view and the dive profiles to show the new units.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
The unit types are set from system locale when the app starts.
We need to explicitly set the units to match the unit system that is saved in
the git repo. Or we end up with situations where the preferences and git say
"metric" but the units are "imperial".
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When starting the app in "No cloud mode" we need to make sure that the units
and unit_system match.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add the option for the user to set the desired unit system for
Subsurface-mobile regardless of system locale
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Trivial rename of a UI string. The string "Subsurface GPS data webservice"
reminds me too much of the legacy webservice.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Use qPrefLocationService::set_time_threshold and remove from
qmlprefs.cpp and qmlmanager.cpp
Remark: mobile UI shows time in minutes, while it is stored (and calculated)
in seconds. Therefore a /60 when reading and *60 when setting.
Signed-off-by: Jan Iversen <jani@apache.org>
Remove distanceThreshold from qmlprefs and use qPref instead
update qml
no user experience change
Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove developer from qmlprefs and use qPref instead
Update qml
show_developer is saved on disk, and thus remembered between starts.
Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to address the C++ object directy in qml, a different
registration is needed.
qmlRegisterType, registers the C++ class, allowing qml code to inherit
from it and make qml objects. This is needed for graphical elemnets
like profile and map
setContentProperty, registers the C++ object, thus allowing signals to be
catched.
Signed-off-by: Jan Iversen <jani@apache.org>
Despite the fast that this code is sitting in core, its used mainly
from mobile. In 987e221f8e, the buttons to interact with the GPS
webservice were deleted from the UI. Now, delete all the code that
was used under these buttons.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This is the first commit related to the removal of the GPS
webservice. It is nothing more then removing 2 buttons from the
menu to upload and download from the server, so technically
a trivial change.
As with the desktop application: Be very careful here as this
forces our users to use Subsurface-mobile, and a online cloud
account as that is the way to transfer GPS data from a mobile
device to the desktop.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
When installing for the first time cloudCredentials needs to be added,
this commit a problem with updating them correctly
this problem was caused by
da6e8a4cd5
Signed-off-by: Jan Iversen <jani@apache.org>
Add the UI components to let the user set the default cylinder and select
the chosen cylinder when adding a new dive.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
To enable undo of divelog-importing it is crucial that parse_file()
can parse into arbitrary dive tables.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A trivial cleanup: replace void by properly typed pointers in
cylinder_none() and weightsystem_none(). Moreover, remove the
unused function no_weightsystems().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).
Signed-off-by: Jan Iversen <jani@apache.org>
remove General from SettingsObjectWrapper and reference qPrefGeneral
update files using SettingsObjectWrapper/General to use qPrefGeneral
this activated qPrefGeneral and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
remove LocationService from SettingsObjectWrapper and reference qPrefLocationService
update files using SettingsObjectWrapper/LocationService to use qPrefLocationService
this activated qPrefLocationService and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
With the new setup we need to know which state we are coming from
when we are saving cylinder related info. When we are adding
a new dive we explicitly should save cylinder data to the first cylinder.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Same as for cylinder info, we need to make sure that the gasmixes gets saved to the correct cylinder.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Save the edited cylinder in the correct slot.
Since the cylinder number and the used cylinder number need not be
the same we first need to test if the cylinder are used.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
This displays the used cylinders in a dive so that they can be edited.
Currently limited to 5 as a POC.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
If we don't know the vendor or product, let's not overwrite information
that we may have remembered from the last time the user downloaded from
this dive computer.
Note that this doesn't try to associate a specific cable with the
information used last time. We could be smarter here for people who have
multiple dive computers, but for the most typical user with just one
dive computer, this does seem like a good solution.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We do strip the user friendly name from BT addresses and this mistakenly
mangled 'USB device' to 'device'.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Parse the device string and try to figure out what was plugged in.
In some cases we know exactly which vendor and product was plugged in,
in other cases we only know which vendor it was, in some cases we don't
even know that (if all we see is a generic FTDI cable).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This only works if the USB device contains enough information to do so.
We need to collect more information to understand what information we
get if those get plugged in. Maybe we'll get only the vendor and need to
leave it to the user to set the product (which we can do by passing an
index of -1 for product).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Unless, of course, the user was editing or adding a dive - that would
be annoying to have interrupted (even though, of course, it's the user
plugging in the device which would trigger this in the first place).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And try to guess which one from the device string we get from the Intent.
The function is named to indicate its future use (because once the user
plugs in such a device, we should show the download page).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the user plugs in a device on Android we get a device string that
should allow us to figure out which dive computer was plugged in. Make
that string available to the QML UI.
Right now all we do is log it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
add enum to qPref and remove elsewhere
update source core to reference qPref.
the enum cannot be in pref.h because it is to be used in qml and Q_ENUM
need the enum to be defined as part of the class
Signed-off-by: Jan Iversen <jani@apache.org>
Use Q_ENUM instad of Q_ENUMS (which is depreciated) since it does the
meta registration for all Qt platforms.
Q_ENUM require the enum to be defined in the class and cannot refer to
a global class, therefore copied enum to class.
This commit is made to get the release to work, with minimal changes,
this class will be moved to qPref and the double definition solved
Signed-off-by: Jan Iversen <jani@apache.org>
Remove cloud_storage_status from qmlprefs.h.
usage to qPref::
enum cloud_storage_status is not used from C, but only from C++, and
having the same structure defined multiple times is a maintenance
challenge.
Signed-off-by: Jan Iversen <jani@apache.org>
The clipboard fails if we attempt to copy more than 1MB of data. But the
data buffer used is shared between all transactions 'in flight' and we
cannot tell what else is currently using that buffer. Limiting ourselves
to 500k of text for the logfiles seems reasonable and hopefully makes it
more likely that the transaction will succeed (sadly, Qt doesn't tell us
if it failed).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On some devices (e.g., a Sony Xperia phone) the GenericDataLocation is
not app writeable. Instead of just giving app, try a few other default
locations as well (and since all of these are actually string lists,
try all of the options that Qt gives us).
Reasonably, we should only set the libdivecomputer logfile name if we
found a writeable location.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The info text from the download process wasn't rendered correctly.
maximumWidth ended being a recursive reference and as a result the text
would render as very narrow and super-tall field.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>