Commit graph

61 commits

Author SHA1 Message Date
Jan Mulder
e4c8d6968f mobile: introduce simple private helper updateAllGlobalLists()
As we need to update our new stringlist models on multiple
locations, just refactor them into a new function.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
494ad26540 mobile cleanup: restyle construction of locationlist
See also e6e1473e6. The construction of the locationlist
was not the same as the 3 previous lists, and it needs
the inclusion of a new model file (divelocationmodel.cpp)
in the mobile app. In addition, as the mobile app is mainly
interested in a simple stringList (model) to populate a HintsText
field (or maybe later a combobox), this stringlist is added
to the model, to easy interfacing with QML.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
83259008e7 mobile cleanup: unduplicate code and do not loop over dives (3)
See e6e1473e6. Exact same commit but here for the
list of divemaster. The careful reader will spot a
small addition to the clearDetailsEdit() QML function.
Two more field are cleared.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
572fc47071 mobile cleanup: unduplicate code and do not loop over dives (2)
See e6e1473e6. Exact same commit but here for the
list of buddies.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
fed2c5b6a1 mobile cleanup: unduplicate code and do not loop over dives (1)
This is the first of a set of commits that are (very) similar.
It appeared that a number of more or less static lists, which are
constructed by a loop over all dives in the logbook, were executed
when changing focus to a next dive. For example, the in this
commit addressed list of used dive suits.

What was wrong was that the suitList was linked to a dive. There
is only a need to construct the list of used suits when data is
changed (and obviously, once on startup of the app). Further, it
appeared that a lot of code was duplicated and that we can use
(in this case) the same code from the desktop completionmodels.cpp.

Basically, this commit involves the following changes:
- include completionmodels.cpp in mobile and desktop (so move
it from the desktop only category to the generic category).
- remove double code from DiveObjectHelper.cpp
- Do not differentiate in the init phase and the normal refresh
of the list
- the per dive logic is now only the getting of a previously
constructed list (in init or update of the divelist).

There are no visible changes in the UI, other than a better
performance when scrolling over dive details.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Berthold Stoeger
f8f14c5edb Use error callback to log errors in QMLManager
Instead of manually logging errors after each potentially
error-producing function, use the error-callback. The error texts
are accumulated in the QMLManager object for further use.

The text is transported to the QMLManager object via a queued
connection. Thus, errors can be reported from other threads
without having to deal with manual locking.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00
Berthold Stoeger
a07b6b4d97 Remove function-call indirection in qmlmanager.cpp
QMLManager::tryRetrieveDataFromBackend() was a one-liner calling
void QMLManager::checkCredentialsAndExecute() with a pointer-to-member.
The latter was never called with a different pointer, therefore
fold the latter into the former and remove the indirection.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-25 08:39:20 +01:00
Berthold Stoeger
ee17024ac5 Remove redundant QML getter functions
QMLManager was full of redundant getter functions of the type
bool QMLManager::locationServiceAvailable() const
{
       return m_locationServiceAvailable;
}
These can be removed changing READ keywords to MEMBER keywords
in the QPROPERTY declarations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-18 08:56:00 +01:00
Robert C. Helling
afd46a60f7 Add button to rescan BT devices
Otherwise the divecomputer has to be in pairing mode
at app start time.

Unfortunately, this leaves less space for the progress message.
My time/qml knowledge does not suffice to move that to the next line
(when moving that out of the RowLayout it overlaps with
the buttons).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-05 20:05:16 -08:00
Dirk Hohndel
0e789c6016 We no longer support Subsurface-mobile without BT support
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-05 19:29:59 -08:00
Jan Mulder
806c7077f2 mobile: get GPS data from dive site name
When the user entered a dive site using autocompletion, it
is a known site, of which we might have a GPS location already.
Just fill the known site coordinates.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-25 08:13:42 -08:00
Jan Mulder
16b395a898 mobile: No cloud repo creation more explicit
Before this change, there was only one way to create the local
no cloud repo on the device. The user needed to add at least
one dive to the no cloud account (so that there is something
to save). While this worked in some scenarios, it could also
get things in an inconsistent state: credential status = CS_NOCLOUD
but no local repo. This was a dead end.

In this commit, the creation of the no cloud repo is made more
explicit. When asking for no cloud mode, just create an (empty)
repo for it when it does not yet exist, and otherwise, just
open the existing (possibly empty) repo.

Now, a user can have no cloud repo, next to (any number of)
cloud accounts.

This leaves one functional aspect left: how does a user abandon
the no cloud repo, by merging his data into a true cloud
account. This is code for this, that tries to do this merge in
a smart way. This seems to be broken (too). To be clear: this
is no part of this commit.

Fixes: #667

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-17 14:29:17 +02:00
Dirk Hohndel
a48a42efe0 Make sure we can still build without BT_SUPPORT
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-15 21:43:38 -04:00
Jan Mulder
ba4058667a mobile: enable switching BT on/off during session.
This commit implements possible switching BT on and off during a session,
so not needing a restart of the app when the user forgot to switch
it on when starting the app.

For this, the following needed to be done: 1) create a handler that
reacts on local BT device status changes. 2) repopulate the connection
list in the download screen when a BT status change is detected.

Notice the subtile change of the Q_INVOKABLE btEnabled() function
to a Q_PROPERTY. This gives a nice dynamic behaviour when
switching BT on/off with the app open.

Fixes: #556

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-12 09:43:40 +02:00
Dirk Hohndel
56c82081a5 Make compile succeed without BT_SUPPORT
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 10:06:47 -07:00
Jan Mulder
cf8e87545f mobile: add helper function cancelCredentialsPinSetup()
As written in 8d9ad3cfea7e4c0875, the user needs to be able
to exit the PIN entry UI, in case no PIN can be received due
to a wrong email address.

The simplest way seems to just clear the cloud credential data,
and let the user try again. Obviously, we could argue if the
exact previous state of the 1st credentials screen could
be restored, but as it is only 2 simple fields, of which
it is higly likely that the email adress is misspelled (and
the password hidden), it seems overly complex to implement.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -07:00
Jan Mulder
9a2d503d3b Unify credential states
Having two different enums around with more or less the same
definition has lead to unclear code. After removing two not needed
states on the mobile end, the remaining step to one enum for the
credential state becomes almost is simple rename operation.

Unfortunately, I do not know a way to embed a plain C enum
from pref.h into the QMLManager object. So after this, there
are still 2 enums around, but now identical.

This commit is not changing any functionality.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-04 07:38:30 -07:00
Jan Mulder
7e2803d6dd mobile: remove superfluous state INCOMPLETE
And here, the removal of a second superfluous state from QMLManager.
This is true no-brainer. While this state was set once troughout the
entire mobile code, it was never tested for this state. Testing shows
that it is safe to change to the UNKNOWN state.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-04 07:38:30 -07:00
Jan Mulder
190d80e509 mobile: remove superfluous state VALID_EMAIL
This is a no-brainer removal of the VALID_EMAIL state used in QMLManager.
All current usage of this state is "if state is VALID or VALID_EMAIL",
so there is no distinction between the two states.

It is even a little different. The comment suggests "when we can open
a local cloud storage, tied to a cloud account (so explicitly not
the no-cloud status), we have at least a valid email". While this
is formally true, this implies that there is also a cloud account
on the cloud server (ie. the cloud account is in a VERIFIED state).
In other words: currently, there can't exist a valid local storage
that is tied to a valid email adress, without valid cloud account
on the server.

Notice that this touches the discussion on GitHub for commit
e76f527fe5 (pull request #520). Can we implement the creation
of a valid cloud account without data link to the cloud server?
Currently, we need the server to confirm the email address (for
example for uniqueness reasons on server side). Obviously, we could
hack our way out of this, but we have a perfect solution already
in place. Create a no-cloud account, and transfer that later to
a true and valid cloud account.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-04 07:38:30 -07:00
Joakim Bygdell
6a47af2d16 QML UI: enable modification of ratings
This enables editing of visibility and ratings for a dive.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-08-02 18:49:47 -07:00
Joakim Bygdell
a66d876ed0 QML UI: add checkbox to show/hide developer menu
Add a checkbox to the preferences page to facilitate selective visibility of the developer menu. With the coresponding function in qmlmanager.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-07-23 03:20:58 +09:00
Jan Mulder
619fbaf1e2 QML UI: Allow cancel of ongoing download
This commit adds the capability to cancel a running download from DC.
The actual cancel is fully handled in the underlying libdivecomputer
code. As the user may be interested in the dives downloaded up to
the moment of cancel, do not just close the download screen (as
it was before this commit). Now, the <quit> button changes to
<cancel> when the download is started, and pressing cancel, only
cancels the download and does not close the download screen, but
presents the so far downloaded data. When no download is running,
the <quit> button just quits the screen as before.

Fixes: #485

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-19 21:49:37 +09:00
Dirk Hohndel
2c111bb4cc QML UI: make BT state available to QML
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-12 04:14:24 -07:00
Dirk Hohndel
0a0c93e3b7 QML UI: add variable for libdc logfile
It seemed cleanest and easiest to have this in the QMLManager and
not in the DCDownload object.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 18:08:06 -07:00
Dirk Hohndel
c59a74029b Android: write appLog to file
The trick is to pick a path that is accessible from other applications.
In theory QStandardPaths::GenericDataLocation should provide that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 17:40:29 -07:00
Dirk Hohndel
fd96daca6a QML UI: add progress message variable
To be shared between C/C++ and QML code in order to show the updates
and potential error messages from libdivecomputer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 15:07:44 -07:00
Dirk Hohndel
206df227f8 QML UI: remember the theme
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-23 19:49:57 -07:00
Dirk Hohndel
57e365222b QML UI: color the status bar on Android
This code is based on code from Marco Martin from the Kirigami Android
sample app. In order to simplify the QML code the QMLManager function is
there for all OSs, but it's a no-op on anything but Android.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-23 08:42:45 -07:00
Dirk Hohndel
b2b51c833a QML UI: redesign the user notification
The old system of cloud access updates with fake percentages just wasn't
helpful. Even worse, it hid a lot important information from the user.
This should be more useful (but it will require that we localize the
messages sent from the git progress notifications and make them more
'user ready').

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-17 23:22:37 -07:00
Jan Mulder
5c1d67e0c1 code cleanup: one more unused include
See c7a3509800. A forgotten include is now removed as well.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-16 05:31:41 +09:00
Jan Mulder
a7288cc912 QML UI: do not crash on selecting dive computers
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>
2017-06-12 09:49:05 -07:00
Dirk Hohndel
b14a522f4f QML UI: move BT handling into core code
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>
2017-06-11 13:55:41 -07:00
Jan Mulder
dbd1d1f41a Android BT: generalize pairing data
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>
2017-06-02 11:31:00 -07:00
Jan Mulder
ed392694db Android BT: pull the pairing data from a device
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>
2017-06-01 16:53:29 -07:00
Jan Mulder
f5adbe5662 Use #if defined() instead of #if
qtcreator (4.3.0) got confused whether BT_SUPPORT was defined. Using
work as expected.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-01 07:28:18 -07:00
Dirk Hohndel
be271e7d48 QML UI: add getBtAddress function
This allows us to get the BT address of the first dive computer that we found.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 10:14:24 -07:00
Dirk Hohndel
18eff8f2b3 QML UI: detect BT dive computers
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>
2017-05-29 15:08:28 -07:00
Dirk Hohndel
1ab6b50a34 QML UI: start BT discovery
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>
2017-05-29 12:00:27 -07:00
Tomaz Canabrava
0e4c996f51 QML UI: Fill the product list
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Dirk Hohndel
8525805f04 Add SPDX header to mobile widgets and QML files
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Dirk Hohndel
6a50efd80a QML UI: create completion list for cylinders as well
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>
2017-04-14 17:32:45 -07:00
Dirk Hohndel
01d091fbd5 QML UI: better handling of device pixel ratio
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>
2017-04-04 11:00:18 -07:00
Joakim Bygdell
674d8331f5 QML UI: Enable cylinder edit
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>
2016-09-04 07:36:13 -07:00
Dirk Hohndel
5fa965df54 QML UI: prepare to enter the cloud PIN on mobile UI
This just creates the properties to connect QML and C++ code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13 16:41:26 -07:00
Joakim Bygdell
80274b0968 Add init function to qmlmanager
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>
2016-05-21 06:59:38 -07:00
Dirk Hohndel
ba9288fab6 QML UI: when first entering cloud credentials, force cloud connection
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>
2016-04-30 11:08:33 -07:00
Dirk Hohndel
4ad73fb807 QML UI: when switching from no cloud to cloud usage, don't drop local data
This is rather simplistic, it just imports the local data into the remote
repository and therefore loses the git history of the local data - but I
wasn't able to make the git merge without shared base commit work, so I
went this much easier to implement route instead.

One thing we need to be careful about is that contacting the remote server
could fail. If we don't manage to merge the dives from cloud server and
local storage, we need to revery to no cloud status in order not to lose
the local data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 14:36:00 -07:00
Dirk Hohndel
4b1edceca0 Add helper function for the consumption of loaded dive data
This allows us to call that part of the process from multiple places
in the future.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
27fccbbe4e QML UI: when chosing 'no cloud', switch to dive list
Currently we don't remember that we picked 'no cloud' across restarts.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-22 11:59:16 -07:00
Dirk Hohndel
1819cc1ccc QML UI: make the state of the GPS service available to QML
This exposes a locationServiceAvailable property to QML and keeps it in
sync with the corresponding state in the GpsLocation widget.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-17 22:59:19 -07:00