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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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 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>
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>
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>
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>