When you start a new session with Download from DC, clear out the table
from the last attempt before adding the page.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds a central function to convert a BT name to a vendor/product pair
known to Subsurface. This allows interfacing from a paired BT dive
computer, without actively selecting its type, but by selecting it
from the list of paired BT devices. So, after this, downloading from
multiple (paired) DCs is also possible.
And not the niced piece of code ...
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added a list of paired BT devices for the "Paired BT Devices" vendor. The
devices under this vendor represent all BT devces that can be found
from the local BT interface. Some special processing is required, as
the BT provided data is (obviously) missing the specific data needed
to open a BT device using libdc code. This processing is not in
this commit, but will follow. This commit is preparation for that.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
One Andorid JNI include was missing. And removed the unused ones
from QMLManager.
[Dirk Hohndel: I had added the missing include elsewhere, so this commit
now only has the removal of the unused includes]
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
After the recent refactoring of QMLManager to btdiscovery, the
manager.getBtAddress() got superseeded by
downloadThread.data().getDetectedDeviceAddress(). Corrected this
here.
Futher some debug output is modified, so that it report the proper
function names.
This corrects the download from an automatically detected OSTC 3.
Manul selection of the same device from the fake vendor "Paired
BT Devices" does not work, however. Still work to be done in
that area.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For reasons unknown to me, the DCDeviceData instance was freed way too early,
and used afterwards, obviously resulting in a SIGSEGV. This commit creates
the DCDeviceData as a direct child of the QMLManager instance, ensuring
it does not get freed prematurely.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This shouldn't be part of the UI (qmlmanager), but part of our
overall handling of dive computers and BT devices.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
appendTextToLog prepends the elapsed time which can be useful, so let's
not remove that but instead have it log to qDebug() instead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
all qDebug / qCDebug and friends now will be properly
logged into developer -> log, on QML.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QML and C++ model don't interact too much, a new Rule
should be created and used on the QML
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds a list of paired BT devices to the QMLManager class. In addition,
a very simple implementation is made of getting the paired BT devices on
Linux, so that we can test further processing of selecting the proper
devices, in a mobile-on-desktop situation.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
It is very impolite to force BT on at start of the mobile app. We cannot
know if the user is going to import dives over BT.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
As Qt is not able to pull the pairing data from a device, a lengthy
discovery process is needed to see what devices are paired. On
https://forum.qt.io/topic/46075/solved-bluetooth-list-paired-devices
user s.frings74 does, however, present a solution to this using JNI.
Currently, this code is taken "as is".
Currently, only for Android (so not mobile-on-desktop, or even desktop).
And only generating logging data in the logcat.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The naming scheme of OSTC dive computers doesn't match their product names,
but they all behave the same from a download perspective, so we assume that
any BT device that has a name starting with OSTC is an OSTC 3.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We remember the offered service uuids as we detect the device and then
try the first one - likely this needs to be fixed / tuned to pick the
right one if multiple uuids are offered.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we detected a BT dive computer, we can already set up the vendor and
product for it (as well as the new BT checkbox).
Oddly, in my tests this doesn't set up the product correctly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we find something that looks like a known BT dive computer, set
things up so that we can use it later. If multiple dive computers are
found, simply use the first.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A delegate to display the dives in a better way,
based on the code from DiveList.qml
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far all this does is list all the BT devices that it finds
(and I worry if this will have negative battery implications
on a mobile device), but this should allow us to connect to
a standard BT dive computer (but that will of course require
more code to pick the right device).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This already takes into account which of those dives were selected.
Right now all we have is select all or none - this needs actual support
in the UI, but once that's there, it will just work (famous last words).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Still to do:
- select the dives to save
- record the downloaded dives
but download is already working. :)
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For this I had to also make the DCDeviceData accessible,
and for that it needed to be a pointer.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a new action on the drawer to display the
Download from Dive Computer options. Nothing works yet.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Once we re-inserted the dive in the list we aren't done, quite the
contrary - we now need to make sure that we handle any other changes
and mark the dive list as updated.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need to set the timeSpec after the QDateTime was parsed,
otherwise it gets converted to localtime again.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Trying to close the non-existing context drawer caused the function
to abort (and consequently not to delete the dive).
Fixes#309
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There was an extra BasicListItem inside the SwipeListItem.
This commit just removes 5 lines, the rest is indentation change.
Fixes#312
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We already have that for the other three fields where we offer auto
completion (buddy, divemaster, suit).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Prior to Qt Quick Components 2.1 there was no onPressed signal for a
TextField; in order to be able to build against Qt 5.7 (which comes with
Qt Quick Components 2.0) we need to work around the lack of this signal.
This code seems to do a pretty good job at simulating it.
My attempt in commit 73c66e1d7d ("QML UI: make run with Qt 5.7 again")
didn't work so well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Assigning actions in an imperative way on component complete,
seems to cause a crash on some devices, assign declaratively
the whole list instead, hiding the gps related actions on
iOS as they are not supported on that platform.
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a different take that seems to deal much better with different
width and font size combinations.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The editText property is not there anymore, we need text
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to make sure we don't render the initial profiles with the
wrong scale on devices, we need to seed the device pixel ratio with the
device default and then update it once the window has been created.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the device pixel ratio can be a fraction we should interpolate the
values. I still don't really understand why this is necessary, so this is
a hack on top of a hack - but for most values I tried this does seem to
give us a reasonably well placed (and well scaled) profile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fixes scrolling of the cloud credentials and simplifies code
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Completely adapt to the api changes of OverlaySheet in Kirigami2
in order to achieve the same look and behavior for the dive
edits that had with kirigami1
Port most components to QtQuickContrls2, except comboboxes
in the dive edit sheet that will need a new control type
Signed-off-by: Marco Martin <notmart@gmail.com>
For CCR dives we want to display the setpoint and pO2 information,
due to the limited screensize we have to remove the temperature graph or
the view will be to cluttered.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Sending nicely readable formatted coordinates to Google Maps does not
result in a correctly positioned map. Google likes unreadable
decimal format.
Little hacky solution. Added a gps_decimal attribute, populate that
with the standard function for format a coordinate to string, but
reset the preferences value temporarly so that it always converts it
to decimal style.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This fix seems to fix the enumerate problem: the problem that on a
seemingly non-determinstic way, all the profiles get enumerated
and rendered, causing freeze of the app, or even crash due
to out of memory.
Only 3 lines of code change, but this fix did not come easy. The
enumerate problem seems some kind of race condition between QML,
Kiragami and most definitely, the Subsurface QML code itself.
The breakthrough in my debugging was the setting of
highlightRangeMode: ListView.StrictlyEnforceRange based on
the QML documentation on snapMode: enumeration.
This fix deserves proper testing in multiple environments. As
could be seen on the developpers mailing list, I was (easily)
able to reproduce the enumerate problem, but Rick was not. So
I definitely do not claim to understand why this fix solves
the issue for me.
And as a sidenote: fixes#263 for me as well.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
It's unclear why this code was added in the first place - removing it
makes the highlight of the selected dive in the dive list work.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were doing the right thing switching from metric to imperial, but in
order to swtich back you had to restart. Now it works both ways.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
There is no need to have two variables for the same purpose.
[Dirk Hohndel: changed to keep the two separate functions as otherwise
we no longer parse existing repos successfully]
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows the user to enter multiple buddies as a comma separated list,
the "Multiple Buddies" entry is still a special case as we can only populate
the combobox with a single name for each entry.
fixes#168
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
The JS string function search returns the position of the string you
search for and -1 if that string isn't found. Also, search allows
regular expression, indexOf does just a string match. So let's use
that as it is much faster.
See issue #168
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
"Multiple Buddies" is magic in that it means "do not change the buddies
set for this dive". Allowing the user to edit that magic phrase defeats
the purpose.
This deals with part of issue #168 - but of course that magic phrase
shouldn't be fixed as English text.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When editing adive in Subsurface-mobile we can only handle one buddy
due to the limitations of the combobox. To prevent loss of data when editing
a dive with more than one buddy we display "Multiple Buddies" in the buddy
field. This creates a special case where no changes are written to the buddy field
unless the user changes buddy for that dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the option to select a cylinder when adding or editing a dive.
Due to limited screen size we restrict the editing to the first cylinder only.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now kirigami needs to be built with a C++ plugin.
In cases of mobile operating systems such as iOS (and in a lesser measuse,
Android) having a proper plugin loaded at runtime may be difficult, so
statically link it together with all of its qml files compiled as a
qresource inside the static library.
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Subsurface uses "local time" which in particular means we never
display time zone information to the user. The user (and our file
format) only sees times like 5pm or 17:00. A better name than
local time (which could mean "local at the dive spot) would
be "watch time", the time displayed by the diver's watch when
she entered the water.
Internally, we store times as time_t, seconds since Jan 1 1970 0:00
UTC. Our convention for conversion between 5pm and time_t as always
been to treat 5pm as if it were UTC.
Then confusion arose since Qt's QDateTime (which is tied to UI elements
like QTimeEdit and similar) is time zone aware and by default assumes
the system time zone. So when we set a QDateTime to 5pm and then later
convert it to time_t we have to take care about the difference between
UTC and the system time zone.
This patch unifies our solution to this problem: With it, we set all
QDateTime's time zone to UTC. This means we don't have to correct for
a time zone anymore when converting to time_t (note, however, the
signedness issue: Qt's idea of time_t is broken since it assumes it
to be unsigned thus not allowing for dates before 1970. Better use the
millisecont variants).
We only need to be careful about time zones when using the current time.
With this convention, when assigning the current time to a QDateTime, we
need to shift for the time zone since its value in UTC should actually be
the watch time of the user who is most likely used to the system time zone.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
since the contentItem is the default property of
ScrollablePage, putting another Item after it will change
contentItem with that one, in this case the Label
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we run the backend to verify credentials without waiting for it to
finish, the redirect might happen before we know if the credentials are
invalid, unverified or verified - which will cause us to give the wrong
information to the user.
Yes, this additional wait is annoying, but I can't come up with a better
way to do this and avoid incorrect information. At least the UI isn't hung
while we wait.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There was a column of whitespace in the divelist that looked strange.
It was there so a trash can icon can appear. Now the trashcan overlaps
with the item.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This sets the list models for autocompleting suit, buddy and
divemaster.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to get autocomplete to work on manual dive add
we apparently need a separate init function.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Hide the handles for the comboboxes, making the text input fields
look like the normal text fields.
This is left as a separate patch as there currently seems to be issues with autocomplete
on Android.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds autocompleting text input fields for suit, buddy and
divemaster.
[Dirk Hohndel: some whitespace cleanup]
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Splitting the bottomlayout in two leads to columns in the grid not lining up.
It was a workaround that hopefully isn't needed any longer.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The QML manual advises against setting width property of gridLayout children
directly, and recommends setting preferred, min and/or max width instead,
letting QML do the work to determine the optimum width. But we've found
letting QML determine gridLayout widths leads to infinite loops in too many
situations, so we're forcing a width. It's better to force a width by setting
it directly, rather than setting minimum = maximum.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I did this semi-automatically: I used the script from
the previous patch and then did some manual corrections.
This marks only title: and text: tags, there might be others
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The ApplicationWindow has the backRequested signal and if we don't accept
that event, Kirigami will exit the app which is never what we want.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While this seemed to work fine on iOS and when compiling the QML UI on
a desktop, on Android the nocloud button wasn't shown at app start.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The grid layout had each column fixed to a width
taken as a portion of the grid width, but since
the grid has a columnSpacing defined as well,
the computation doesn't add up, helping in causing
an infinite recursion problem in the attempt of
sizing and positioning all the children of the layout
[Dirk Hohndel: heavily modified, but the basic idea remains]
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
if the text in every column can wrap anywhre,
we don't have a stable way to know how large the columns
themselves may be. This can cause an infinite recursion
while trying to figure out the width of the items, as
the sizeHint(Qt::ImplicitSize) of those labels
(Buddy, Cylinder etc) will not be stable as it will once
return the size of the text wrapped and once the size of
the text not wrapped.
Signed-off-by: Marco Martin <notmart@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the big layout causes an infinite recursion in the Qt/QML layout
engine.
Also remove a no longer accurate comment.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With offline the default now, we need to force a connection at least once
so that the repos are in sync. And then of course we need to return to the
correct state, regardless on whether this connection succeeded or failed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>