Commit graph

487 commits

Author SHA1 Message Date
Dirk Hohndel
b75eae95c1 QML UI: remove unused property
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-20 13:23:59 +09:00
Dirk Hohndel
7ec9c206b5 QML UI: store nocloud data when adding cloud credentials
We want to allow people to keep dives they collected without a cloud
account. The code was mostly there, we just got confused about the
existing status because we ran through this twice (no cloud -> unknown
-> verified). This way we explicitly remember this kind of transition.

Fixes #1404

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-20 11:13:13 +09:00
Dirk Hohndel
a5380bb741 core: add free_samples helper
And use it in the UI and planner code.

See #1411

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-20 09:27:11 +09:00
jan Iversen
49f3da3bfd mobile: set alloc_samples to 0 when resetting.
set alloc_samples = 0 when settings dc->sample = 0 and dc->samples = 0

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-20 07:59:07 +09:00
jan Iversen
b8eb348f54 mobile: move settings from qmlmanager to qmlprefs
add settings variables/functions to qmlprefs
remove settings variables/functions from qmlmanager
change manager. to prefs. in qml files for setting variables/functions

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-15 14:12:14 -07:00
jan Iversen
62ca5e90e1 mobile: move NOCLOUD_LOCALSTORAGE from qmlmanager.cpp to .h
Make NOCLOUD_LOCALSTORAGE public for other qml functions

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-15 14:12:14 -07:00
jan Iversen
470c218b79 core: remove qml properties from downloadfromcthread
Remove Q_OBJECT and qml properties from DCDeviceData class
Remove DCDeviceData register from mobile-helper.cpp
Change DCDeviceData constructor to be without parameters

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09 21:19:46 +02:00
jan Iversen
682e1b63f5 mobile: add DCDeviceData properties to qmlmanager
add DCDeviceData qml properties etc. to qmlmanager

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09 21:19:46 +02:00
jan Iversen
76f61468e6 mobile: add timer to measure startup.
Subsurface-mobile has a long startup time; in order to isolate the problem(s) a
timer is added to see where time is "lost".

The collected startup times are added to the clipboard together with the other
logs, allowing test users to report back.

All this is only enabled when compiling with -DENABLE_STARTUP_TIMING

Closes #1340

[Dirk Hohndel: collapsed multiple commits and minor white space cleanups, added
               missing QMutex variable]

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-30 21:47:07 -07:00
Berthold Stoeger
0de862971e Cleanup: remove reply and request member variables in QMLManager
The reply member variable was used to access the reply in the
handleSslErrors, handleError and retrieveUserid slots. This is a
very scary proposition in the light of multi-threading. Instead,
the reply can be accessed by using the QObject::sender() function.
Thus, we can remove the member variable.

The request member was just downright weird. This was only used
locally to describe a network request. Since QNetworkAccessManager::get()
copies the request, it can be destructed right away. Nevertheless,
the data was kept as a subobject. Remove member and make it function-local.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26 09:19:42 -07:00
jan Iversen
034f9a6ca2 mobile-widgets: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
jan Iversen
3646fa800b iOS: copy libdivecomputer.log to clipboard
Read libdivecomputer.log file and append to clipboard

Remark, subsurface_open is not available in iOS so using
QFile instead.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 07:57:14 -07:00
jan Iversen
997251d43a iOS: store libdivecomputer.log in documents (same dir as app log)
Make location of subsurface.log and libdivecomputer.log consistent

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 07:57:14 -07:00
jan Iversen
571965ec6d mobile: removed setting for libdivecomputer.log
Users need a simple way to report download problems. Asking them
to go into settings, activate logging, and repeat the download
is too much.

libdivecomputer.log will always be generated, but overwritten, with every
download, so the latest log is ready.

The download is very slow due to BT, so there are no impact of having the log
active, neither in terms of size (a concern on small mobiles) or write time.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 07:57:14 -07:00
jan Iversen
a181020b19 mobile: add "Copy log to clipboard" button
on iOS it is practically impossible to copy the App log
to e.g. a mail! in iOS 11 the log file is stored within
the subsurface container and you first need to copy (actually
using the clipboard) out from there to the "normal" document
shared space, before it can be used.

At least iOS users (and I believe Android users) are not really
used to work with files, so the process is not easy to document
in an understandable way.

The alternative is to provide a button, which simply puts the
log on the general clipboard, allowing it to be pasted in a
multitud of applications.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-18 12:43:15 -07:00
Murillo Bernardes
97090aeb47 mobile: fix wrong coords when saving new location
This one place it was not being multiplied by 1000000,
as expected for degrees_t.

Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
2018-05-17 07:25:56 -07:00
Berthold Stoeger
920ff15f71 Planner: don't return static data in fake_dc()
fake_dc() used to return a statically allocated dc with statically
allocated samples. This is of course a questionable practice in
the light of multi-threading / resource ownership. Once these
problems were recognized, the parameter "alloc" was added. If set
to true, the function would still return a statically allocated
dc, but heap-allocated samples, which could then be copied in
a different dc.

All in all an ownership nightmare and a recipie for disaster.
The returned static dc was only used as a pointer to the samples
anyway. There are four callers of fake_dc() and they all have access
to a dc-structure without samples. Therefore, change the semantics
of fake_dc() to fill out the passed in dc. If the caller does
not care about the samples, it can simply reset the sample number
to zero after work.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 13:11:53 +03:00
Dirk Hohndel
dcc308e929 QML UI: recalculate derived information after editing dive
For example, when changing the cylinder, the SAC rate wasn't updated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-15 10:05:41 -07:00
Dirk Hohndel
e107abba23 Debug location saving
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:37:44 -07:00
Dirk Hohndel
1d95cc4cbf QML UI: if we don't have a current position, update it later
Once we get a new fix we asynchronously update the text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:37:44 -07:00
Dirk Hohndel
0df43252be iOS: log messages
So far we only wrote messages to subsurface.log on Android (since we couldn't
figure out how to make that file user accessible on iOS). Now that that's
fixed, we also need to actually write to the file in the first place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:43 -07:00
Dirk Hohndel
27b921fb1d iOS: make logfile accessible to user
By creating it in the Documents path and setting the two magic keys,
iOS will make the log file available to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:43 -07:00
Dirk Hohndel
114904a48f iOS: always create subsurface.log file
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:43 -07:00
Berthold Stoeger
d1572a8d95 Cleanup: introduce copy_qstring() function
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common
occurrences that they seem worthy of a short helper-function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
b72cc1f317 Cleanup: consistently use qPrintable()
Replace constructs of the kind
  s.toUtf8().data(),
  s.toUtf8().constData(),
  s.toLocal8Bit().data(),
  s.toLocal8Bit.constData() or
  qUtf8Printable(s)
by
  qPrintable(s).

This is concise, consistent and - in principle - more performant than
the .data() versions.

Sadly, owing to a suboptimal implementation, qPrintable(s) currently
is a pessimization compared to s.toUtf8().data(). A fix is scheduled for
new Qt versions: https://codereview.qt-project.org/#/c/221331/

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
7da214a8c4 Mobile: pass QString as value to registerError()
registerError() may be called from a different thread context. Passing
the message as a const-reference may lead to a dangling reference.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-12 15:18:13 +02:00
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
8f81a22e7f Make report_error() reentrant
Remove the global error buffer and pass the error string directly
to the frontend. The frontend is then responsible for accumulating
errors.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +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
3d02edf61e Mobile: start message timer on startup
Since the timer will be started on first message anyway, we might
just start it at application startup.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-18 17:35:35 +02:00
Berthold Stoeger
84b96ac2ae Mobile: don't show timer twice in log-message
This was probably an oversight - the timer was only shown for very
specific messages. This was change to show the timer for all messages.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-18 17:35:35 +02:00
Berthold Stoeger
a116ff85f8 Remove redundant local variables cloudPwd and cloudUser
These were assigned the member variables QMLManager::m_cloudPassword
and QMLManager::m_cloudPassword. Use the member variables directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-18 08:56:00 +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
Berthold Stoeger
e85ecdd925 Introduce helper function empty_string()
There are ca. 50 constructs of the kind
  same_string(s, "")
to test for empty or null strings. Replace them by the new helper
function empty_string().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Jan Mulder
6193aef9ac mobile: fix crash on delete dive from divelist
This is a somewhat hacky commit. For a very long time, the delete
from the divelist on mobile crashed. That is, not always for anyone,
but for me almost consistently. This commit tries to solve it.

I found that trying to save the delete immediately after removing
data from the underlying model seemed to cause the crash. Hacking
around, I found that a simple beginResetModel/endResetModel between
the delete of the underlying model data and actual save is
sufficient to solve the crash.

The big question is, why does this all work? I suspect some of race
condition between deleting model data, and giving the QML engine
the opportunity to do its thing.

This is also related to issue #311, but that is not implemented
here.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 20:34:16 +01:00
Berthold Stoeger
099662023c Move resetting of current file out of clear_dive_file_data()
This is the only case where C-code sets the current file.
Remove this call for a better separation of C-backend and
C++-frontend parts.

There were four callers of clear_dive_file_data(). Two of them
would call set_filename() anyway. For the remaining two add an
explicit call to set_filename().

This commit fixes a bug introduced in commit b3901aa8f9:
The cloud-online menu entry was still enabled after "closing" the
cloud storage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 12:01:04 +01:00
Berthold Stoeger
e5980942aa Remove redundant call to clear_dive_file_data()
In QMLManager::saveCloudCredentials(), clear_dive_file_data() was
called just before calling openLocalThenRemote(). The latter calls
the former anyway, so remove the former.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-07 13:02:12 +01:00
Dirk Hohndel
b4b8a9db4e Cleanup: avoid out of bounds access
sizeof() is clearly the wrong way to get to the size of that array...

Coverity CID 208297

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26 15:57:45 -08:00
Dirk Hohndel
2c8614e43e Cleanup: check we have dive before dereferencing
Coverity CID: 208341

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26 13:41:58 -08:00
Dirk Hohndel
648fec7a3d Cleanup: fix potential uninitialized use of uuid
And make sure we don't create a dive site for an empty location string.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 09:12:44 -08:00
Jan Mulder
b59778abd8 mobile: use short date format in edit mode
See issue #949. In the dive list, dates are shown in short format, and
when we start to edit an existing dive, the date field on the edit
page is shown in sort format. However, when adding a new dive, the
initial date shows up in long (normal) format. This in not only
inconsistent, but also introduces the parsing problem, as described
in the mentioned issue.

This can be fixed by using short formatted dates in all cases in
the mobile app. As the screen real estate is precious on mobile,
this seems the most logical choice.

Fixed: #949

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-17 09:04:16 -08:00
Jan Mulder
b1d94b2470 mobile: manual add dive and cancel fails when repeated
This commit fixes a very subtle bug. Probably there for ages,
but never noticed. When manually adding a dive, and canceling
the add right away, the divetable was extended by 1 dive (using
the core function add_single_dive), but canceling never removed
that dive (using delete_single_dive). This is corrected here.

Notice that commit ef543da5af claims to fix issue #950.
With this commit, however, that issue can be seen sometimes
again.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-16 19:04:57 -08:00
Berthold Stoeger
c21e998277 Don't create GeneralSettingsObjectWrapper object
Instead use the application-wide instance. Creating a local
object defeats the whole purpose of these objects - nobody
can receive signals in case the settings changed.

No other cases of locally created SettingsObjectWrapper
objects were found.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-14 17:01:34 +01:00
Jan Mulder
5707554e98 mobile: do not just create a new dive site
This fixes an annoying bug. When entering an existing divesite
in the mobile app, always a new divesite (with same name) was
created, resulting in multiple sites on the same gps location.

So, be more carefull in checking and creating a new site.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-13 05:05:49 -08:00
Berthold Stoeger
ea0cbba804 Remove second parameter (bool force) in set_filename()
The last force=false case was removed in commit 96d1cc570e.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-11 00:17:39 +01:00
Dirk Hohndel
4ccb70011c Cleanup: mark unused variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-08 16:29:49 +01:00
Joakim Bygdell
e9bcca9103 Mobile: Enable editing multiple buddies
While the autocomplete function only works for the first entry
adding multiple comma separated buddies can still be done.

Fixes #608

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-12-07 21:43:17 -06: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
Murillo Bernardes
4dbbf1ff27 iOS: report location services availability
This enable use of current location on Add/Edit

Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-05 08:57:18 -08:00
Berthold Stoeger
fb7116a722 Fix argument to set_filename() in QMLManager::finishSetup()
The second argument to set_filename() is a boolean, but was given
an empty string. Since an empty string evaluates to true, directly
pass true for clarity.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-03 19:07:03 -08:00
Dirk Hohndel
789e86480d QML UI: add versions of key libraries to the log
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-27 10:11:52 -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
Berthold Stoeger
6ae16b87d0 Constify strings in pref.h
Make all char * pointers in pref.h const to make it clear that these
strings are not mutable. This meant adding a number of (void *) casts
in calls to free(). Apart from being the right thing to do, this commit
makes the code more consistent, as many of the strings in pref.h were
already const.

While touching core/qthelper.cpp turn three instances of (void*) into
(void *).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-18 21:57:33 +01:00
Jan Mulder
f7da06c76b mobile: fix initial setup with no repo or meta info
First, obviously, I could have squashed this small commit into
the previous one, but I explicly decided not to. It shows
the fragility of all this credential processing code, and
the complex flow control troughout the code.

Testing on a brand new install, and immediately going for
a no cloud setup, the PIN screen was shown, instead of an
empty divelist. Looking at this small code change shows why.
In case of a no cloud situation, there is no PIN to verify
(or email and passwd rules checked). So just do not force us
there.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-17 14:29:17 +02: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
ea577aa8f2 Fix stupid syntax errors
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-16 05:27:30 -04: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
Lubomir I. Ivanov
56e755b711 Use lrint() for all degrees_t related rounding
In certain places the '(int)' cast is used, while in other the
llrint() or lrint() functions. Make the conversation from degrees
in the 'double' form to the 'int' degrees_t consistent using lrint().

lrint() is the function which should give the best results,
because it accepts a 'double' and results in a 'long'
even if degrees_t is 'int'. If the truncation from 'long' to 'int'
is discarding some of the precision then the next step
would be to turn degrees_t into a 64bit signed integer type.

Possible fix for #625.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-09 13:38:58 +03:00
Jan Mulder
fb42213111 mobile: do not clear email and passwd when cancelling
Commit cf8e87545f implemented a way to cancel pin setup,
and this also has effects on an exit from the app after pressing
the android exit. The change button started with clearing the
email and passwd in order to get the credentail page(s) active
again. While this worked ok, it confuses users that exit the
app from the credential pages, resulting in the need to enter
the credentials again after a restart. It appears that clearing
the credential state is sufficient to get the pages active.

Notice that the android exit is still not working (it seems
a no-op), but the interaction with the buttons in the app
preserves the email/passwd.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-08 19:45:40 +03:00
Jan Mulder
f4165a9eea mobile: only set old credential status in one place
The old credential status should only be set when changing the
actual credential status using the setCredentialStatus function.
Setting it here is just wrong. It sets the old status to the
current, and than adds the current to the prefences,
obviously, resulting in old = current, which can not be right
and results in a wrong flow of control in the credential state
processing.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-08 19:45:40 +03:00
Jan Mulder
dbed88bd81 QML UI: rework single credential page to two pages
This commit tries to implement most of issue #515. It reworks the
one credential page, which its dynamic PIN part, into two pages.
Main driver of selecting one of the two pages is the showPin
boolean. Page 1 contains the email/passwd field (and the
option to use a no cloud setup). Page 2 only contains the PIN
part (and the option to cancel the process).

The Kirigami central button does not seem very handy here. We
need, for example, a cancel, sign-in and register, only register,
etc. buttons, which are not easy to handle in specific icons.
Therefore, normal pushbuttons are chosen to deal with user
interaction, and the Kirigami button is removed from these
pages.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -07:00
Jan Mulder
0af64e4986 mobile: make sure that the old credential status is correct
This commit is just a precaution. It makes sure that the old
(aka previous) credential status is correctly set on all changes
of this status.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -07:00
Jan Mulder
85dfdaa3e5 mobile: only deal with localrepo in NOCLOUD mode
This is a very subtile bug. Testing/developing on the desktop for mobile,
with a normal logbook in a git repo, resulted in a surprising effect.
When swichting from a cloud account to a NOCLOUD situation, the no cloud
repo was (not always) reset to the NOCLOUD_LOCALSTORAGE, but to the
normal logbook. Resuling in commits in the wrong repo.

This can easily be solved by setting the filename to NOCLOUD_LOCALSTORAGE,
when switching to NOCLOUD mode.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -07:00
Jan Mulder
6ea3fd3d92 mobile: do not care about email/passwd when NOCLOUD
In case the credential state is NOCLOUD, the saving of credentials
in the preferences was suppressed in case of invalid data in the
email/passwd fields.

There is no reason to check these fields for correct input, as they
are not used in case of NOCLOUD mode. A simple if statement is added.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -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
801b1bc5f5 mobile: propagate "still PIN required status"
Makes sure that the CS_NEED_TO_VERIFY status is carried forward
and sets the showPin flag that triggers the 2 different states
in de QML UI.

The new credential UI will have one page for username/passwd,
used for setting up an account or switchting to a different
account, and a second page to enter a PIN only.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -07:00
Jan Mulder
46f10362fc mobile: do not go to NO_CLOUD status from UNKNOWN
In case the credential status is UNKNOWN, and the cloud username
and password are empty, do not go automatically to NO_CLOUD status.
This is (again) preparation for future work on credential management.

For example, the user entered an email address with a spelling
error, so does not receive a PIN code email. This user needs a
way out, so there needs to be a <cancel> button on the PIN code
screen. And the most logic was of cancelling is emptying the
entered username/passwd and let the user try again.

Without this change, the user immediately gets into the (somewhat)
final NO_CLOUD state, which will result in (very) confused users.

With this change, there is exacly one way (left) to get into a
NO_CLOUD setup: hitting the proper button, so a deliberate user
action.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-09-29 08:13:25 -07:00
Jan Mulder
2e91de9d95 mobile: initialize credential data in one place
It appears that the onCompleted of the StartPage item is triggered
before the onCompleted of the rootItem. This is logical as the
Startpage is a child of the rootItem. And, yes, this does matter.
As the divelist also contains the logic for initial cloud
registration (and is the default page shown in a state where
the cloud credentials are valid (CS_VERIFIED state)), we need to
know the correct credential state at start of the app.

The move of this one line of code makes sure of that, in addition
to setting the credential state from the preferences. Now, the
setupActions function can reference correct credential data.

This is further preparation for a better cloud creation
process from mobile.

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
Jan Mulder
b9404b0905 mobile: go to the correct credential state
When we want to go the NOCLOUD credential state, do not go the
incorrect INCOMPLETE state.

This is the first in a series of unraveling the preference parameter
prefs.cloud_verification_status and the data that is carried around
in the QMLManager::credentialStatus_t.

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
Jan Mulder
9a2759fc1f mobile: make sure old credentialStatus is defined
In commit e76f527fe5, the scenario of switching between 2 already
VERIFIED cloud accounts was identified, which was working poorly. It
needed a restart of the app to get the new account visible.

Reason for this, was the setting of the credentialStatus to the value
of an undefined (never set) old credentialStatus. This commit makes
sure we have a defined credentialStatus, just before changing it to
the new one.

A really mini step forward, as the behavior is still not perfect. Now,
the user has to select the dive list manually, after entering
credentials of the new clould account.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-31 11:40:37 -07:00
Jan Mulder
61a35d0bd7 Trivial log string correction
The PIN (and cloud account creation) is not limited to the
desktop (any more). Correct the string accordingly.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-29 08:30:08 -07:00
Jan Mulder
fd03621a4b Mobile: honour location service time threshold
Independ of the settings, the threshold to reset the GPS data was
hard coded to 5 minutes. Now, honour the entered (and updated during
a session) time to refresh the GPS data in the location service.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-25 22:12:19 +09:00
Miika Turkia
97b770b837 Error message on mobile cloud credentials
Display proper error message when cloud credentials are incorrect.

See #481

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-25 10:04:20 +09:00
Joakim Bygdell
d51fe03bd9 QML UI: move location services to GPS menu
Move the location services switch to the GPS menu, indicate both with icon and text if the service is active or not.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-07-23 23:47:22 +09: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
Jan Mulder
915b760d54 Android: truncate logfile and add date
Trucate the logfile on open to remove any data from previous sessions.
This confused me very much, as the new logfile started from the
top, leaving old data on the bottom.

Also added system date for easy reference.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-19 11:13:03 +09:00
Dirk Hohndel
7f49ba745c Fix compile errors
This was fixed in my local tree but I forgot to amend the commit
before pushing it out. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-15 08:17:05 -07:00
Dirk Hohndel
a0c6ceeb3d QML UI: enforce rules for cloud credentials
Email addresses are checked for a someone useful pattern, passwords are
letters, numbers, and +-_. only. Reject anything else.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-14 22:41:25 -07: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
7b922a1f72 QML UI: actually write libdc logfile
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 18:23:16 -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
9111ce01e7 QML UI: show progress messages on the download page
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 16:07:48 -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
d2a5bf87c4 QML UI: add dev_info data to AppLog
This should make it easier to tell how far we get downloading data
from dive computers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 12:50:22 -07:00
Dirk Hohndel
c9c9a8390a QML UI: start BT discovery a tiny bit later
This way the AppLog starts with the name and version of Subsurface-mobile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-06 09:34:37 -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
2b01ab7d50 Clean up git storage update messages
Translate all of them, but also remove some redundant or possibly
misleading messages. These are now seen by users, not just developers
trying to debug the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-18 01:00:30 -07:00
Dirk Hohndel
4866dd6f45 QML UI: show debug output in the App Log
We have unified the debug output to the console and to the App Log, let's
use it consistently everywhere.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-17 23:23:41 -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
c7a3509800 Android BT: fix compile bug
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>
2017-06-12 09:51:13 -07: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
Dirk Hohndel
3b993fbaad QML UI: adjust to modified logging API
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>
2017-06-11 13:55:41 -07:00
Jan Mulder
78ee3f40a5 Silence compiler warnings
Silence some compiler warnings about implicit double to int conversions.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-02 11:31:00 -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
3b4091a0b9 Android BT: do not force BT on
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>
2017-06-01 16:53:29 -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
b9760f1db0 QML UI: try to also detect OSTC BT dive computers
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>
2017-05-31 10:16:29 -07:00
Dirk Hohndel
286bac6d30 Android: connect to BT via uuid instead of port
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>
2017-05-31 10:15:40 -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
a568562503 QML UI: try to match BT names to known dive computers
So far this just adds data to the log.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 12:25:21 -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
20f525cedd QML UI: correctly update dive list after editing timestamp
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>
2017-04-16 07:43:48 -07:00
Dirk Hohndel
03b2b854bf QML UI: correctly parse manually edited date
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>
2017-04-16 07:43:48 -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
bd0c99dfb7 MOBILE: Display pO2 and Setpoint for CCR dives
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>
2017-03-26 21:57:57 -07:00
Dirk Hohndel
d87d97a794 Sync unit system to Subsurface-mobile (part 2)
Missed a spot.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-11 16:09:06 -08:00
Dirk Hohndel
ae9ab68096 Correctly sync unit system to Subsurface-mobile
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>
2017-03-11 15:23:42 -08:00
Joakim Bygdell
0277d5aacc Merge informational_prefs into git_prefs
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>
2017-02-05 12:29:51 -08:00
Joakim Bygdell
11dcae436e MOBILE: Read profile settings from git
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 11:59:47 -08:00
jbygdell
0e57033042 QML UI: Parse multiple buddies when editing a dive
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>
2017-01-29 14:55:33 -08:00
Dirk Hohndel
b15b3c195c QML UI: allow magic phrase for multiple buddies to be localized
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-22 18:20:03 -08:00
Joakim Bygdell
1219dc6931 QML UI: deal with multiple buddies correctly
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>
2016-09-17 13:46:15 -07:00
Dirk Hohndel
80eafb8db7 Fix some warnings
At least the warnings about size potentially being uninitialized seem correct
and valid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04 10:27:56 -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
Tomaz Canabrava
5651abfd75 Settings update: Simplify code by using the SettingsObjectHelper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Robert C. Helling
2c715542fd Unify handling of QDateTime time zone information
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>
2016-08-10 15:04:39 -07:00
Dirk Hohndel
8d83edc48a QML UI: correctly check cloud verification status
Oops. That's embarrassing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-17 04:23:46 -07:00
Dirk Hohndel
07512cb2c8 QML UI: allow entering the cloud PIN on the mobile UI
Now the user doesn't need to do this on the desktop app anymore.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-13 16:42:36 -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
Dirk Hohndel
d2f9803883 QML UI: serialize checking credentials
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>
2016-06-13 15:25:17 -07:00
Dirk Hohndel
f7daadb1cd QML UI: don't proceed unless cloud credentials are verified
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-12 18:05:33 -07:00
Dirk Hohndel
f2e03022fa QML UI: disable GPS functionality on iOS
I still haven't figured out how to make GPS work on iOS. So let's not
pretend this works.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-12 12:09:49 -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
bca2c2a101 Connect to the reply, not the manager
This way if there are other pending connections we don't get triggered by
the wrong completion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 10:16:00 -07:00
Dirk Hohndel
879482e977 QML UI: forceRemoteSync means connect even without unsaved changes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 10:15:56 -07:00
Dirk Hohndel
711e5e76e8 QML UI: better diagnostics when cloud connection fails
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 10:15:15 -07:00
Dirk Hohndel
05a51f7984 Only create the path to no cloud local storage once
This required a small change to the helper function, but this seemed
totally worth it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 09:46:29 -07:00
Dirk Hohndel
4a2a0a426e Fix logic for when to mark dive list as changed
Since saving checks if there are changes, we have to always mark the dive
list as changed before asking for the changes to be saved.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-30 09:46:01 -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
c6205b5819 QML UI: fix order of tests when saving changes
Only check for previous cloud connection when actually trying to save
to cloud

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 14:03:50 -07:00
Dirk Hohndel
f536da0ee3 QML UI: make sure nothing is lost when changing cloud credentials
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:48:43 -07:00
Dirk Hohndel
9ca0f7334b QML UI: handle failure to read local dive data
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
3946f83ff2 only set index if we have specific target
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
bdf8bc676b QML UI: with a local default file setup, open that at start
And set no cloud mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -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
7c156f3ba1 QML UI: in no cloud mode, save to a default local repo
And set that up as the default file to load at start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-27 15:05:37 -07:00
Dirk Hohndel
660f421d6d QML UI: correctly show if we are accessing remote or local storage
This makes sure that if the user switches to offline mode they don't get
incorrect notifications that tell them that they are accessing cloud
storage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-19 10:34:49 -07:00
Dirk Hohndel
fe62da3a6b QML UI: always show the time stamp when logging data
This should help understand some of the issues with git storage and GPS
fixes better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-19 04:20:12 -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
Dirk Hohndel
ecf44bb2fa QML UI: quit on back key while showing dive list
Make sure you save first, though.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 14:42:08 -07:00
Dirk Hohndel
71d74f9e3c QML UI: rewrite the commitChanges function
I couldn't figure out how to break this down into small, useful commits.
Part of the problem is that I kept going while working on this and as you
can see from looking at the commit, diff tries so hard to find small code
fragments that moved around, that the diff overall becomes quite
unreadable and it seemed impossible to recreate the sequence of steps
after the fact.

It all started with adding the parsing for the GPS coordinates. But while
testing that code I found several issues with the rest of the function.
Most importantly it seemed ridiculous that we carefully tried to match the
texts that the DiveObjectHelper would create for the various fields,
instead of just using the DiveObjectHelper to do just that. And once I had
converted that I once again realized just how long and hard to understand
that function was getting and decided to break out some of the more
complex parts into their own helper functions.

But of course all this didn't happen in this logical, structured, ordered
way. Instead I did all of these things at the same time, testing,
rearranging, etc.

So in the end I went with one BIG commit that does all of this in one fell
swoop.

This adds four helper functions to deal with start time/date, duration,
location and gps coordinates, and depth of the dive.

To avoid mistakes when dealing with the GPS coordinates, there's another
helper to encapsulate the creation of the dive site and we switched to a
current GPS location.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:16 -07:00
Dirk Hohndel
00ac1c12db QML UI: fix the save to cloud logic
There were several logical flaws here. Ugh.

Don't save things if there are no unsaved changes, if we haven't
initialized this repository from the cloud or if we are already saving
things.

Then, once we decide that we should save, first always save to the local
cache and then check if we should save to the cloud and do so if
requested.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:16 -07:00
Dirk Hohndel
6985c123d4 QML UI: stop using "--" for empty strings
I can't remember why we started doing this, but at this point I find it
just weird.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:22:08 -07:00
Miika Turkia
9e787a2476 Copy coordinates when renaming site
Let's not discard our GPS location when editing site name on mobile.

Fixes #1051

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 12:57:40 -07:00
Dirk Hohndel
67742856b2 QML UI: don't try to scroll to dive at time 0
If no timestamp is available, just start at dive 0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 11:49:25 -07:00
Dirk Hohndel
6e6cce770b QML UI: keep QML manager and the UI in sync about selected dive
The manager can now directly update the index of the selected dive, and
the UI tells the manager the timestamp of the currently selected dive.
This allows the manager to pick the best possible dive as selected dive
if things change (for example if the dive list gets reloaded because it
changed in cloud storage).

Fixes #1009

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:43:33 -07:00
Dirk Hohndel
2878236268 QML UI: clear the flag indicating that we are accessing storage
If the automatic sync is turned off we could be stuck in a state where we
always thought that we were already in the middle of a save.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:43:33 -07:00
Dirk Hohndel
9a2e3ce7e8 Remove unused function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-13 09:28:55 -07:00
Robert Helling
7bca367c57 Upon undoing a dive deletion select that dive
Before it had the next dive still selected.

Fixes #1053

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-11 12:41:41 -07:00
Dirk Hohndel
ccff227596 Fix wrong function call for desktop build of Subsurface-mobile
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-11 09:56:35 -07:00
Dirk Hohndel
18b7ee3875 QML UI: try to do the right thing for changes on all platforms
On Android we can save locally right away, but we don't want to make the user
wait for a network sync. Sadly, on Android currently the saving in the
background doesn't work and the save will run when the user comes back.
Definitely not ideal.

On iOS the situation is different - a save to the local git cache takes
surprisingly long. Must be the shitty file system they use or something.
Because of that we only mark the dive list changed and instead save the next
time the app is not in the foreground (which works on iOS but not on Android -
go figure).

On all the other OSs (I guess that would be desktop builds of
Subsurface-mobile? But there may be other mobile OSs that people might want to
build it on) we save both locally and to the cloud right away.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-10 19:22:16 -07:00
Dirk Hohndel
4ed369b975 QML UI: only force network access when user asks us to
So when the user taps on the manual cloud sync, we always force access to
the cloud server. Otherwise we only access the cloud server if
git_local_only isn't set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:37:17 -07:00
Dirk Hohndel
685d31cd4f Simplify code - we now can rely on git_local_only to do the right thing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:34:29 -07:00
Dirk Hohndel
e2e4bb6c2a QML UI: change order of cloud backend accesses
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-08 12:28:05 -07:00
Dirk Hohndel
9f7e509f9a QML UI: break the sync into explicit save local and save cloud
This makes the code much cleaner and easier to understand and should allow
us to then switch back to doing at least the local save right after we make
any changes to the data.

This commit also tries to make sure that the accessingCloud status stays
correct and consistent throughout all the various success and error paths.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06 11:47:12 -07:00
Dirk Hohndel
961b80ec20 QML UI: after successfully opening storage, store the filename
We rely on the filename being valid elsewhere in the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06 11:44:58 -07:00
Dirk Hohndel
6a23e0ef66 QML UI: save with unchanged credentials returns to dive list
If the user is on the credentials page, doesn't change the credentials
but simply taps on save, they now get back to the dive list.

Fixes #1047

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-06 11:42:38 -07:00
Dirk Hohndel
922c945f5a QML UI: more hacking around with git progress reporting
I gave up on the magic numbers and instead report simply linear progress.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 23:39:54 -07:00
Dirk Hohndel
3555cadb77 QML UI: don't fetch the remote twice when loading
We first check the sha to see if we want to load at all. But at that
point we already have the repository and the branch and we have synced
with the remote. So when we decide that we need to reload from storage,
we don't need to repeat those steps, instead we can go directly to the
git load.

For that to work we need to pass the repository pointer and the branch
name back to the caller so that we can directly call git_load_dives().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 22:57:16 -07:00
Dirk Hohndel
8b670c3f3f QML UI: restructure (and fix) the saveChanges logic
We first want to save any exiting unsaved changes to the local repository
(and ONLY to the local repository). After that we want to make sure that
we are syncing remotely, fetch the remote and then (possibly after a
merge) push the changes to the remote. In the end we reset the previous
"local git only" preference which we overwrote for this manual forced
sync.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 22:57:16 -07:00
Dirk Hohndel
8af4534286 QML UI: don't try to save again if we are already saving
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:36:15 -07:00
Dirk Hohndel
c3ab4dfc3e QML UI: simplify code for loading data from the cloud
We had a redundant check of the server reply hidden in there, and the
logic which values were set where didn't really make much sense. This
seems clearer to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:32:28 -07:00
Dirk Hohndel
afb5bb8b06 QML UI: simplify git tracking output
And don't waste quite as much time on updating the UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:20:33 -07:00
Dirk Hohndel
1634c62b9a DiveListModel: don't add the dives one at a time
Most of the time we are adding all the dives, so do this in a single model
operation. This makes the case when adding a single dive (in the undo delete
function) slightly more complicated, but that seems totally worth it for the
speedup in the common case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:17:37 -07:00
Dirk Hohndel
f16a3a1709 Keep the instance in static variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 21:16:25 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.

And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.

This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:33:58 -07:00
Renamed from qt-mobile/qmlmanager.cpp (Browse further)