Commit graph

1534 commits

Author SHA1 Message Date
Dirk Hohndel
58d97c571d mobile/UI: correctly theme template spin box
This was all hard coded and wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-18 13:00:03 -07:00
Dirk Hohndel
4798382e70 mobile/dc-download: fix dark theme appearance
I noticed that the download from dive computer page looked especially bad
in the dark theme (a user sent us some screenshots for a different reason)
and a quick look at the sources showed that we weren't using our template
label. Switching to that gives us the correct size by default so we can
drop all those explicit font size parameters. And we get the correct color
as used in the theme.

One random whitespace cleanup snuck into this commit. Oh well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-18 13:00:03 -07:00
Dirk Hohndel
f6b09dd8c3 mobile/dive-details: show tags
So far the user can't edit them, but at least they are now shown as
part of the dive details. Usage of tags varries widely, I've seen
people who use a LOT of tags to classify their dives, so I'm giving
this a complete row by itself.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
6f96edd766 mobile/dive-details: less whitespace at the top
This always seemed odd - the location looked like it sat 'low' on the
screen.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
6e47bb11d5 mobile/dive-details: use our labels to create denser display
This makes better use of the screen real estate, without (IMHO) seeming
too crowded. This is a tough balance to strike.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
7720e97db5 mobile: reduce vertical white space around labels
Our labels all seem to have a lot of empty vertical space around them.
Try to be a bit more conservative with space.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
46d582ef0a mobile: add smaller, vertically dense template label
By default single line text has too much white space around it. This
smaller, denser label works well to more efficiently use screen real
estate, I think.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Berthold Stoeger
fb6210a99a cleanup: invert control-flow when resetting the core structures
To reset the core data structures, the mobile and desktop UIs
were calling into the dive-list models, which then reset the
core data structures, themselves and the unrelated
locationinformation model. The UI code then reset various other
things, such as the TankInformation model or the map. . This was
unsatisfying from a control-flow perspective, as the models should
display the core data, not act on it. Moreover, this meant lots
of intricate intermodule-dependencies.

Thus, straighten up the control flow: give the C core the
possibility to send a "all data reset" event. And do that
in those functions that reset the core data structures.
Let each module react to this event by itself. This removes
inter-module dependencies. For example, the MainWindow now
doesn't have to reset the TankInfoModel or the MapWidget.

Then, to reset the core data structures, let the UI code
simply directly call the respective core functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07 08:43:27 -07:00
Berthold Stoeger
9b8eed7821 cleanup: replace constructs of the type &vector[0] by vector.data()
It appears that some misguided compiler / library combinations crash
on &vector[0] for empty vectors. Even though very unfriendly, they are
technically correct, so let's remove these constructs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21 07:50:38 -07:00
Dirk Hohndel
47506028ca mobile UI: indicate status of verbose flag
This way the user can verify that they have set the log to verbose
mode in the developer menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-18 09:00:21 -07:00
Berthold Stoeger
3d4412ad1a mobile: don't call main loop for notifications once initialized
Calling qApp->processEvents() in QMLManager::setNotificationText()
caused crashes, because it could lead to the context-menu that
initialized the call being deleted. Something that QML apparently
doesn't like.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 08:33:47 -07:00
Berthold Stoeger
24eac8df87 mobile: remove overwriting of line special case in ui-notification
On startup, we showed progress of the population of the fulltext
and listmodels for every 100th dive. This worked by overwriting
the last line if the new line started with '\r'. Since we don't
do that anymore, we can remove this special case.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 08:30:51 -07:00
Dirk Hohndel
c7c5dac621 mobile/startup: fix potential crash when switching back and forth
If the user switches away from Subsurface-mobile and back while we are
in our initialization phase, that code might run more than once leading
to undesirable results.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:12:52 -07:00
Dirk Hohndel
8414f83926 mobile/cleanup: create helper function to hide verbose casts
The strange enum casts (that apparently we needed in order to have strongly typed
enums in QML) are really ugly and confusing in the code. Since we had this three
times it seemed worth to create a little helper that hides this nonsense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
6aaa9a40b6 mobile/cloud-storage: correctly transition from no-cloud to cloud
We know that we have valid credentials, so calling openLocalThenRemote()
makes no sense, worse, it doesn't respect the special case of
transitioning between accounts. That's the whole point of having a
separate loadDivesWithValidCredentials() call.

Once we have transitioned state, we need to record the now current state
as the old state so that future transitions will work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
7757ce878b mobile/cloud-storage: fix test for no cloud to cloud transition
The noCloud variable contains our desired state, we need to test for the
previous state for this to make sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
46032af320 mobile/cleanup: remove outdated comment and fix whitespace
We haven't supported the GPS web service for a long time.

Also, add another message for the log to be able to more easily trace
one error case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Berthold Stoeger
1de56d468f mobile/undo: set undo stack as clean after save
If we're using the undo stack for determining the whether there are
unsaved changes, we have to mark the undo stack as clean after save.

This duplicates code from desktop. It is planned to unify this in
the near future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 16:09:57 -07:00
Berthold Stoeger
a6567a0070 mobile/undo: consider undo-stack when checking for unsaved changes
In analogy to desktop, also consider the state of the undo-stack when
testing for unsaved changes. This prevents us from missing changes.

This adds duplicate code, which will be unified in the near future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 16:09:57 -07:00
Dirk Hohndel
1f180552c9 mobile/edits: ensure changesNeedSaving is called
These appear to be the only cases where we forgot to ensure data is
saved.  And pastDiveData is currently not called as the UI to use it has
been removed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:09:09 -07:00
Berthold Stoeger
96d12f5a39 mobile: when creating gps dive site use the new dive site name
The code was using the pre-editing dive site name, which appears
weird. Not sure if that was on purpose.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 14:30:06 -07:00
Berthold Stoeger
4cdea48926 mobile: properly recognize changed dive site
QMLManager::checkLocation() would only return true if the
dive-site itself was changed, not if the dive-site was set
to a different site.

Thus, in some cases edit events could be lost.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 14:30:06 -07:00
Dirk Hohndel
e43362fdcf mobile/download-from-DC: ensure that changes get actually saved
Calling saveChangesLocal() seems like the right thing to do, but it
doesn't do anything useful if the dive list hasn't been marked as
changed. The correct helper function to call is changesNeedSaving()
which makes sure we save the changes and update all UI information.

[Berthold: since this removes the last QML caller of saveChangesLocal()
we can make that function private.]

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
35080aad98 mobile/cleanup: fix whitespace and remove verbose messages
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
001fb7f4fa mobile UI: delay reading the dive list until app is active
This way the launch screen is shown significantly shorter on a device,
and instead the user sees our progress notifications.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
0673e53a68 mobile UI: only test for plugged in USB serial device on Android
This test makes no sense on other platforms (and the log file text is
frankly confusing when not running on Android).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
0e1b784afe mobile/core: remove locking for git access
We have convinced ourselves that only the main thread will ever trigger
a save operation, therefore the locking is not needed (and it has
recently started to cause user problems where local changes aren't saved
to storage and get lost).

Fixes #2718

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
37b1a97f89 mobile/dive-list: don't use cacheBuffer
QML documentation recommends against using the cacheBuffer for longer
lists and doing more testing shows that this really doesn't help at all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
66d3eaa943 mobile/dive-list: performance improvement for invalid dives
Small optimization that reduces the number of accesses to the underlying
model.  Instead of evaluating the isInvalid member eight times per
delegate, we only check it once.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
cf9303c862 mobile/dive-list: only show dive list notifications when it is visible
Without this check we'll show the 'Please tap the plus botton...'
notification during app initialization as we are showing the initial set
of messages - which makes no sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
85dfbfe67d mobile/startup: show progress update earlier
Instead of not showing a notification until after we are done loading
the data into our models, tell the user that we are about to do that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:24 -07:00
Dirk Hohndel
8801ae857e mobile/startup: show notification directly in the UI window
Until the app is initialized, we have problems getting the 'floating'
passive notifications to show up and be useful. Instead update the user
by filling a text block on the otherwise empty initial page of the app.

Delay the switch to the dive list until the app is initialized and then
use the passive notifications again. While we are initializing also show
a busy spinner so the user doesn't think the app is hung.

As a side effect of this change, the dive list isn't shown until our
models are initialized. And strangely this causes every single possible
delegate to be instantiated. We can prevent that by not setting the dive
list model until after we are done setting up the model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:24 -07:00
Dirk Hohndel
d317eefb67 mobile UI: setup callback for the new notification mechanism
This simply passes the text to the existing notification text mechanism.

The call to processEvents() ensures that Qt processes the UI events
after we updated the notification and that the user gets timely updates;
otherwise the UI might look like the app is hanging.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:24 -07:00
Dirk Hohndel
a37499bccd mobile: add indication if the app has finished initializing
This will help us to ensure that notifications are actually shown on the
UI during the startup phase.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:24 -07:00
Dirk Hohndel
f9ccbabb3d cleanup: update all copyright dates to 2020
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:24 -07:00
Berthold Stoeger
69d437bc86 undo/mobile: keep track of dive sites
When editing the dive site of a dive, the dive-table of the
corresponding dive site was not properly updated by the undo
commands. Try to get this right.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 11:49:23 -07:00
Dirk Hohndel
7bddef02cd mobile/dive-list: try to force focus on filter text field
This was triggered by a change in enabled, but what is really changing is
the visible property. This should work better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 20:33:11 -07:00
Dirk Hohndel
1549d6f528 mobile/dive-summary: make the drop downs smaller
Especially on smaller screens we had issues fitting this on the screen.
And it looks fine on larger screens as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 20:33:11 -07:00
Dirk Hohndel
4982751bbe mobile/dive-details: add option to toggle the invalid flag
Simply for consistency with the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 20:33:11 -07:00
Dirk Hohndel
9dd01da9c1 mobile/dive-details: fix incorrect call to create trip
This was using the myData alias that exists in the dive list but not on
the dive details. This might work (because the models both use the same
underlying base model), but given that we are using the currentItem of
this ListView, I'm guessing that this would just silently fail (maybe
with a warning in the log).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 20:33:11 -07:00
Dirk Hohndel
2bf394581f mobile/dive-details: if menu is open, close that with back button
A second tap on the back button will then end add/edit or close the dive
details and get us back to the dive list.

This fixes an issue where tapping on back with the context menu open
would bring you back to the dive list with the context menu still open,
and because then change the text in the context menu as those are
designed differently.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 20:33:11 -07:00
Berthold Stoeger
d13f73001b cleanup: make QMLManager member functions private
The
	- mergeLocalRepo()
	- openLocalThenRemote()
functions were not invoked from outside QMLManager.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31 08:56:45 -07:00
Berthold Stoeger
82f6c60856 mobile: don't call saveChangesLocal() twice on non-iOS
QMLManager::changesNeedSaving() behaves differently on iOS:
it only saves locally with saveChangesLocal(), whereas all
other OS save to cloud with saveChangesCloud(). Nevertheless,
even for other OS saveChangesLocal() is called even though
that will be called in saveChancesCloud anyway. Therefore,
compile the saveChangesLocal() call in changesNeedSaving
conditionally.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31 08:51:20 -07:00
Dirk Hohndel
49dc8b9065 mobile/dive-details: don't show virtual keyboard in dive view mode
At least in 4.9.3.1258/3.0.1 I was able to reproduce a situation where I
edit one dive, go back to the dive list, then tap on a different dive
and then the keyboard pops up, obscuring a big chunk of the screen.

This tries to make sure the keyboard isn't shown in dive view mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 08:42:20 -07:00
Dirk Hohndel
085b5ff0db mobile: improve Android back key behavior
There are two places where we try to prevemt unintended app exits.
Once, in the onBackRequested signal handler on the dive list. This was
missing special handling for the situation where one of the drawers was
open.
The second place is the onClosing signal handler in main.qml. Naively I
thought that this was enough to catch all cases where we were about to
exit the app, but apparently an explicit manager.quit() is a bit too
forceful and doesn't get to that signal handler.

With this commit we check for open drawers in both places. Belts and
suspenders, I guess.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 08:42:20 -07:00
Dirk Hohndel
aeb1794616 mobile/dive-details: remove the redundant 'map it' button
You can already get to the map by either clicking on the location text
or on the left action button. This third way to get there reduces the
available space for the location text, and can cause positioning issues
with very long location texts creating three or more lines of text,
which then overwrites the dateRow below.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 08:42:20 -07:00
Dirk Hohndel
c406ad83ea mobile/dive-list: avoid using undefined value as boolean
This gets rid of an annoying and noisy warning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 08:42:20 -07:00
Berthold Stoeger
eef41a3403 cleanup: remove loadFromCloud() declaration from QMLManager.h
This getter functions was not defined anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31 04:18:34 -07:00
Berthold Stoeger
da740dfc19 cleanup: use setPointSizeF() in themeInterface::set_currentScale()
The compiler complained that we were passing a float to the
QFont::setPointSize() function, which expects an integer.
Solve this by using the QFont::setPointSizeF() function.

This might introduce a user-visible change, albeit very unlikely:
We now may set the point-size to a non-integer number.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:58:10 -07:00
Berthold Stoeger
45a3fff62c cleanup: fix initialization order in QMLProfile constructor
The compiler complains that members were initialized out-of-order.
Even though this is not an issue here it is correct to emit a
warning, since only then it is guaranteed that the objects are
destructed in reverse-order with respect to construction.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:58:10 -07:00
Berthold Stoeger
38d70ba854 cleanup: un-slotify QMLManager functions
Some slots in QMLManager were not called from the outside, some
only directly from C++-code. Make the former private and the latter
public member functions.

The idea here is to document which functions are actually called
from the outside and which are called from QML or connected to
signals.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:58:10 -07:00
Berthold Stoeger
9d485f9626 cleanup: fold ThemeInterface::setup() into constructor
There appears to be no reason for two-phase initialization.
Let's keep things simple: let the constructor produce a
functioning object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:54:12 -07:00
Berthold Stoeger
0e9bd27bae cleanup: don't send values in changed-signals of ThemeInterface
According to the Qt-docs you *may* send the new values in the
NOTIFY signal of Q_PROPERTYs. However, since changes will lead
to a reevaluation of a whole expression, this argument will be
unused. All it does is make the code more verbose and brittle:
What happens if you send the wrong value?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:54:12 -07:00
Berthold Stoeger
ce1629ccce coding style: rename themeInterface to ThemeInterface
As per coding style, class names are PascalCase.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:54:12 -07:00
Berthold Stoeger
1702747459 cleanup: make color-constants in themeinterface.cpp static
There were no outside users - no point in exporting them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:54:12 -07:00
Berthold Stoeger
79bf243ec0 cleanup: make members of ThemeInterface non-static
We have a singleton class ThemeInterface, which means that it
is global and exists only once. It's members are static, i.e.
also global. A message from the department of redundancy department?
In any case, that makes no sense. Let's just make these members
local to the class.

I would even rip out the whole singleton thing, since the object
is not accessed anywhere outside from QML. Let's keep it for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30 13:54:12 -07:00
Dirk Hohndel
fbe68a6e07 mobile UI: don't exit when using back button to close drawers
An Android user might reasonably assume that they can use the back button to
close the global or context drawers. So act accordingly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-30 09:16:55 -07:00
Dirk Hohndel
2e07e9345f mobile/dive-list: add indicator that dive list is being processed
This should deal with the rather confusing 'No dive in dive list' shown
while loading and processing the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-30 09:16:55 -07:00
Dirk Hohndel
cbf1f35d63 mobile/dive-list: show/hide virtual keyboard as needed for filter
This should happen automatically, but for some reason it doesn't. So
let's try to force it manually.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-30 09:16:55 -07:00
Dirk Hohndel
ccb671685d mobile/dive-list: make sure filter input area is visible
Since apparently the header property of the ListView isn't reliably
making sure that our filter input line is visible, let's move the filter
header to be it's own visual element and manually manage the
relationship between that and the ListView.

The obvious idea was to anchor the ListView to the bottom of the
filterHeader, but that didn't work in my tests. So instead we are using
the topMargin to make sure that there is space to show the header.

Because this re-indents the whole filterHeader, 'git show -w' gives a
much better idea what this commit actually changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-30 09:16:55 -07:00
Dirk Hohndel
d12e86cb2b mobile/cleanup: use a mutex to protect storage access
Instead of the crude and error prone bool, let's just use the right tool
for this job.

In order to avoid issues with a goto across a mutex boundary, this
slightly restructures the code in one place - 'git show -w' makes it
clear that this is really rather simple in its changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-29 12:36:57 -07:00
Dirk Hohndel
98966fdd8a mobile/save-changes: untangle the handling of alreadySaving
I'm suspicious that an issue that some people have seen around changes
not being saved is caused by our handling of alreadySaving.
When starting with Subsurface-mobile in no-autosync mode, we were able
to end in a scenario where alreadySaving was true, even though there
were no unsaved changes. And in that case no changes made during such a
session were saved unless the user forced a manual sync with the server.

This commit radically changes our approach to handling the flag. It
moves it right next to the actual calls into code that could modify git
storage, and ensures that the flag can never stay set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-28 11:00:09 -07:00
Dirk Hohndel
73bbe1f02b mobile/cleanup: tiny coding style issue that bugged me
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-28 11:00:09 -07:00
Dirk Hohndel
60d2d051bb mobile UI: add create trip to DiveDetails context menu
Should have done that in the first place. That's what happens when you
are rushing it...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 16:48:48 -07:00
Dirk Hohndel
302404dac0 iOS: ensure changes are saved locally
This was disabled in the past because it was deemed to slow. A lot
of time has passed, since. Maybe on current phones / iPads this is
acceptable again?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 14:27:14 -07:00
Dirk Hohndel
8177dd4dc3 cleanup: remove dead code
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 12:59:00 -07:00
Dirk Hohndel
66fd93c9cc mobile/dive-list: add ability to create trip
This adds a context menu entry for top level dives that allows the user
to create a trip for that dive.

Unfortunately this creates a new string to translate right before a
release...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 12:59:00 -07:00
Dirk Hohndel
241d378f14 mobile/cleanup: pageStack.pop() doesn't take a string argument
This happens to do the expected thing, anyway, but let's not keep this
broken code around.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 11:49:46 -07:00
Dirk Hohndel
0301fc6905 mobile UI: undo partial dive add when canceling
When we start adding a dive, we actually create a diveAdd undo command
so we have a dive that the user can edit. Which means we need to undo
this action if we cancel.

Also, for a more consistent UI, we should pop the dive details page that
we used to edit this dive and bring the user back to the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 11:49:12 -07:00
Dirk Hohndel
f2a48e813f mobile/page-selection: consistently use showPage to select a page
We still used pageStack.push() all over the place.

Also, in showPage, disable the map hack if the user actively picks a
different page.

This should fix an issue where the user picked the map and then tried to
add a dive to the dive list - and instead of the dive edit was shown the
map again.

Reported-by: Hartley Horwitz <hhrwtz@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-26 11:49:05 -07:00
Dirk Hohndel
69272eefa8 mobile/profile: ensure profile opacity resets when zooming
It's possible for our code to think that the user wants to pan the
profile before realizing that the user actually is making a pinch
gesture. In that case the profile could get stuck in semi-transparent
mode. This prevents that from happening by explicitly resetting the
opacity to 1.0 when we start a pinch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-25 09:28:05 -07:00
Dirk Hohndel
f084852f5c mobile/debug: simulate zooming through mouse wheel on desktop
And allow touchpad gestures to be recognized as well. This has no
negative impact on the mobile platforms, but makes it much easier to
test profile scaling / panning on the desktop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-25 09:28:05 -07:00
Dirk Hohndel
c7dd1e1bab mobile/profile: don't pan unless we are zoomed in
This way someone trying to swipe from dive to dive won't inadvertantly
pan the profile instead. And panning it really only makes sense when
zoomed in in the first place.

This could leave us in a situation where we zoom in, pan, zoom out and
now the profile is out of whack and we cannot correct it. A simple click
on the profile fixes that.

The real solution would be some constraining / adjusting as we zoom and
pan to ensure we keep things correctly positioned. Maybe I'll figure out
the correct way to do this later...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-23 20:49:05 -07:00
Dirk Hohndel
bba73fdc87 mobile: show the new v3 user manual
I would love to figure out a way how to bundle the user manual and load
it from the device file system, but in the meantime this should continue
to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-23 20:48:03 -07:00
Dirk Hohndel
30e6102886 mobile/divelist: add UI to toggle dive invalid flag
This reuses the corresponding undo command.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 14:31:37 -07:00
Dirk Hohndel
c77cc93eec mobile UI: show dives marked as invalid with strike through
This matches the visual language of the desktop UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 14:31:37 -07:00
Dirk Hohndel
1453888e02 mobile/tripedit: close page after saving
That's consistent with how we do things on other pages.
Also hide the on-screen keyboard.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 13:27:00 -07:00
Dirk Hohndel
fbea54f8dd mobile/settings: attempt to fix the layout
The hardcoded widths with fixed values was just flat our broken and
created all kinds of strange artifacts.

But even with this somewhat more idiomatic approach this still isn't
perfect - on wider screens it doesn't shrink back to the minimum column
width. But that seems like a bit of a corner case. Overall this feels
like a huge improvement.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 13:27:00 -07:00
Dirk Hohndel
559547b7e6 mobile/DCdownload: try harder to get the right elements selected
The number of possible sequences of events when the user is connecting a
USB device is rather surprising. These changes try to ensure that in
every case we get USB connection information we do in fact show the
correct (or best guess) connection.

See #2686

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 13:27:00 -07:00
Dirk Hohndel
98ef01b2e4 mobile UI: stop the use of dark icon theme
This was used very inconsistently and had more bugs than positive
impact.

See #2686

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-21 13:27:00 -07:00
Berthold Stoeger
568a8d6254 mobile: remove QMLManager::updateSiteList()
The location information model is updated automatically by the
divelist-model and the undo commands. Therefore remove the
QMLManager::updateSiteList() function. We do have to keep
the locationListChanged() signal though, because the list
of dive sites is not exported via model/view but rather via
a Q_PROPERTY. We really should change that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-18 13:27:16 -07:00
Berthold Stoeger
ed3e68c36a git: load into arbitrary dive tables
The git parser loads into the global dive table, even if it
is called indirectly via parse_file(). However, parse_file()
may be given a different table. Fix this by extending the
git parser state.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17 16:50:20 -07:00
Dirk Hohndel
2042a47230 mobile/cleanup: add some more log messages
This will help understand the control flow in the log.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-17 16:49:53 -07:00
Dirk Hohndel
8e7711c054 mobile/cleanup: remove the second access to cloud data
While I remember some of the thinking that went into doing things this way,
the more I read the code, the less it makes sense to me.

This is a rather drastic step, but in reasonably extensive testing it seems
to work in every case that I tried.

That's rather embarrassing, actually.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-17 16:49:53 -07:00
Berthold Stoeger
4bd217299a mobile/edit: don't add dive site twice to table
When editing a dive on mobile we might have to create a new
dive site. That site is added to the global dive site table
in the undo command. However, the code in QMLManager created
the dive site with create_dive_site*() functions, which already
adds it to the table. The undo command then added the dive
site again leading to a hang of the application.

To solve this problem, create new alloc_dive_site*()
functions that do the same as create_dive_site*()
but do not add it to the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17 14:05:24 -07:00
Dirk Hohndel
ccd024f0ee mobile/DC-download: select reasonable connection after rescanning
This seems to make more sense than to not select anything (which was the
previous behavior).
If the same connection is still available, select it again. Otherwise
pick the top connection (which is the right thing to do if the user has
just plugged in a USB device and refreshes the list -- that device will
show up as top entry).

Based on a suggestion by Christof Arnosti <charno@charno.ch>

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 13:59:18 -07:00
Dirk Hohndel
2abfd16a10 mobile/DC-download: show USB devices before BT/BLE
This makes sense because USB devices will only show up when connected,
while BT/BLE will get listed once they are paired, even if not currently
connected. So the higher likelihood of being the device a user is looking
for is for any USB devices that show up, so those should go first.

Suggested-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 13:59:18 -07:00
Dirk Hohndel
2265a27912 android/usb: better memory management
Instead of relying on the std::vector staying unchanged and not freeing
its members, instead keep a copy of the object in our DCDeviceData class.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
0b72495413 android/usb: simply restart the download after receiving permission
If the user tries to download from a device that he hasn't given the app
permission to read from, Android will pop up a dialogue asking for that
permission. With this after giving the permission we continue (well,
technically, restart) the download which is likely the expected behavior.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
4619b4932e android/usb: refresh USB device list on entering download from DC
The usbRescan() code is smart enough not to duplicate entries that might
already be there. And with this the user doesn't have to manually tap
rescan if they didn't open Subsurface-mobile via the intent after a
device was plugged in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ff2f199eed mobile UI: rescan button on DC Download page rescans BT/BLE/USB
This way even if a USB device wasn't added through an Android intent, we
still have a way to scan for it and select it. This is especially
important in case a user has a cable that we haven't seen yet (i.e. with
a VID/PID that we haven't added to Subsurface-mobile), but that
nevertheless works with the android usb serial drivers.

This also makes the flow a little more logical / consistent when
deciding which connections to show.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
274dbc2ebf mobile UI: remove special case for Atomic Aquatics
This dive computer hasn't been supported on Android in quite a while.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ec3a968df9 android/usb: pass in the UsbDevice when downloading
This finally allows us to download from not just the first device, but specifically
the device that the user picks.

Passing the object through a void pointer is not nice - but since this traverses
C code other solutions (like passing an index into the list) seemed even worse.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
4cd453dc92 android/usb: parse the usbDevice when responding to intent
This vastly simplifies our handling of devive information as we simply use
what is already in the descriptor. This way we do not duplicate information
about USB devices in the QMLManager.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
822b05bec4 mobile/download: only use device guess if no USB device plugged in
If we explicitly open the download page after the use plugged in a USB
device, don't try to use guesses from the BT/BLE pairings to populate
the device/connection dropdowns.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ff68fd7c0c mobile/export: fix invalid reference
This just removes broken code. That file select dialog is still just a very
strange idea and should be revisited at some point.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Dirk Hohndel
f2a8562b5d mobile UI: stop trying to play with opacity
Since we are switching between pages, the whole opacity mechanics make no
sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Dirk Hohndel
84d45485fd mobile UI: remove duplicate StartPage
This was a merge error in the dive list rewrite and brought in a code block that
had moved, which caused issues with correctly switching to the dive list.

Calling setupActions() moves to the diveListView (where it really belongs).

Instead of messing with the visibility of components of the same page, we now
simply switch out the shown page.

Fixes #2667

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Dirk Hohndel
0d1510929f mobile UI: make user and log messages consistent for no cloud
A number of our messages were misleading in the no cloud case. This should help
to reduce confusion.

Adding the save_dives() call after creation of the repo appears to help us have
a valid repo in place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Robert C. Helling
285fa8acbc Grammar: replaces 'indexes' by 'indices'
Grammar-nazi ran

git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g'

to prevent future wincing when reading the source code.

Unfortunatly, Qt itself is infected as in
QModelIndexList QItemSelection::indexes() const

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-11 08:26:30 -07:00
Dirk Hohndel
f4589583ef Android: remove USB devices we don't support
The HID devices and the Atomics Aquatics Cobalt cannot work on Android
right now. We should claim to support them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 13:27:43 -07:00
Dirk Hohndel
0720e74c1a mobile UI: six new icons
I will (mis)use these for moving dives out of trips and to the trip above or
below and of course for undo/redo. And the weirdest one is the 'local offer'
icon that seemed a reasonably good fit to edit trip details.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
0683d97636 mobile UI: save changes to trip details
The logic when we show the save button is a little fragile (and visually I'm not
sure I love the disabled button), but hey, this works.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
eaa1a5126b mobile: add ability to update trip details
This creates up to two undo events. This seems like such a small issue that
it's not worth creating yet another undo command for this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
4b4df28ecd mobile UI: add divelist context drawer action to edit trip details
For now this only shows the trip details. They can be edited on the page, but
there is no way to save those edits, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
9e13777cc1 mobile/dive-list: add context menu when long-pressing on trip
This doesn't show the dive specific actions and sets the stage for trip edit
actions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
3bcc562150 mobile UI: don't call into the event loop
While this has worked fine for a long time, it now suddenly seems to trigger
crashes. So let's not do that (there are a number of discussions online that
talk about how this could indeed lead to BadThings(tm) happening.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
c8b55ddb76 mobile/dive-list: allow moving dives between trips
A dive that is already in a trip can directly be moved into the trip above or
below.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
476ecb8d72 mobile UI: more context actions in dive list
This adds the ability to delete a dive and to show its location on the map
directly from the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
7fc43c58be mobile/dive-list: long press on dive selects and opens context drawer
This way one can execute dive list manipulations without the detour
to the dive details screen. For example you can long-press on a dive and then
add it to a trip or remove it from a trip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
289d451294 mobile UI: fix autoclose of context drawer
The default policy closes the context drawer if there is a button release
outside the context drawer area. That messes with the intended UI. For us a
much more useful behavior is to have the next click outside of the drawer close
the drawer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
ffdcc8bf30 mobile UI: add context menu to dive list
This one exposes undo/redo as well as some basic trip manipulations, very similar
to what's already available on the dive details page. Except that here it also
makes sense to add a selected dive to a trip above or below (if those exist and
the dive isn't already in a trip).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
2c8f962ecc mobile UI: allow adding a dive to a trip from context menu
Right now this is only available on the DiveDetails screen. The menu entries
are only enabled if there is such a trip to add the dive to (and if the dive
isn't already part of a trip).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
a4043401c9 mobile/trip-handling: add helper to add dive to a trip
This again uses an undo command and should be completely symmetrical to removing
a dive from a trip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
3464e776e2 mobile UI: add ability to remove dive from its trip
If we remove the newest dive from its trip, it becomes inaccessible in the app,
but the dive data saved to disk appears to be correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
56db02a685 mobile UI: only show context menu when viewing a dive
In add and edit mode this is confusing and wrong.

There is a bug in Kirigami that creates lots of bogus error message about
missing mainFlickable. That needs to be patched out.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
65fe892cba mobile UI: set the correct location string when editing dives
In some situations we ended up with the wrong location name. One way to
reproduce the problem was to edit an existing dive location to be a substring
of an existing location name. Save the dive, then immediately edit it again.
The wrong location would be filled in.

The code here looks strange and unnecessary, but it seems to fix the issue.

The aliases don't seem to make the code any easier to understand. This replaces
them in the case of the location combo box with direct accesses to the data on
the DiveDetailsEdit page. It may be worth removing all of them. The
locationModel alias was unused.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
28bf078ff7 mobile UI: add context menu to DiveDetails
The undo and redo action actually work already.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
af4bd16f88 mobile: replace undoDelete() with generic undo()
Since we are using the existing command infrastructure, this isn't specific to
undoing a delete.

This commit renames the function and removes its use in the UI, the next commit
will then add the generic undo to the UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
8e6cc9b8d0 mobile UI: make the text of the undo/redo action available to QML
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
2936d203e2 mobile/divelist: add context drawer
This is just pulling in the object so it can later be used on other pages.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
3c2a192864 mobile: remove no longer used DiveListModel
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
6400867910 mobile/filter: connect directly to filter
Since the divelist model is now placed on top of the common
models, we can directly reset the filter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
79b04a2f01 mobile: remove selectedDiveTimeStamp logic
Since the selection is now handled in the core this is not needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
e700920e8e mobile: remove updateSelectedDive logic
Selection is now be handled by the core.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
57b96490b2 mobile/undo: create EditDive command
Command that just swaps two dives. This is rather complex,
as for example a dive site might be created.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
2009321894 mobile/divelist: better handling of selection change
This still has an odd bug. When we swipe the dive details to change the
selected dive and that action causes a trip to expand or collapse, then
the color change / highlight in the dive list isn't updated correctly,
even though the log file indicates that we made the necessary changes.

This also changes the coloring of the selected dive; having the same coloring
as a trip was very confusing. This is a bit stark, but it clearly communicates
the distinction.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
58dcbfff13 mobile: use undo-command to paste dives
The UI for this is currently disabled (this was lost in the dive list rewrite).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
6e9597027d mobile: random white space cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
c0f2563495 mobile: don't disconnect model on download
That makes no sense anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
2a88ff0ffb mobile: reduce the number of model reloads when opening cloud data
The whole load from cloud thing will have to be audited. It appears
to me that there are way too many model resets...?

The only thing that is left is dive editing. Let's do that next.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
5493e7cbf6 mobile UI: use undo-command for adding dive.
Instead of using the model, copy the code we have in the desktop version
which manually creates a 15m/40min dive and passes that to the addDive
undo command.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
2ad7b26f4b mobile UI: don't hide dive view when deleting dive
The next dive is automatically shown anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
69516c37ec mobile/divelist: select dive after swipe
After swiping through the dive list, select the currently visible dive.
Thus, the dive is highlighted in the overview pane.

The connection with the QMLManager feels atrocious, but I would prefer to have
as little logic in QML as possible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
dd8d8edc45 mobile/divelist: don't set currentIndex on undo of dive deletion
The core sets the current dive when undoing something.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
d55ea8f875 mobile/divelist: remove showDiveIndex QML-function
The currently shown dive is now controlled by the core.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
c34b7857fc mobile/divelist: implement model that shows all dives in trip-order
MobileSwipeModel is probably not an ideal name, but all I could come up with.

One of the main complications here is that our list is reversed with respect to
the source model. We should change that one day.  Probably by moving the
sorting down to the core-model.

Since looking up the source row is somewhat expensive, the lookup is cached for
a single entry because accesses come in bursts for a single dive. This should
be a good compromise and avoids keeping track of a full row-to-dive array.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
7e1ac2167b mobile/divelist: create memory management class for models
Since we want to add a second model, but not have to manage two models
everywhere, create a class MobileModels that contains both of the models. When
calling reset() on that class, it will reset both of the models, etc.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
8e9e536ffd mobile/divedetails: send current-dive changes up to mobile UI
To unify mobile and desktop, let's use the current_dive variable
of the core to indicate the current dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
1f669f9714 mobile/divelist: when clicking on a row, use select_single_dive()
This is a small step in unifying mobile and desktop.

I'm unsure whether it is correct to play this via the QMLManager or whether we
should call form QML directly into the model?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
0fc82e3398 mobile/divelist: switch to the correct model
This obviously breaks everything, but now we can start fixing
things.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
c8ec2f5b1c mobile: use undo-command to apply gps fixes
The goal is to send the signal for the correct dives / divesites
and thus not having to reload the whole model.

Right now the mobile UI does not yet catch the diveSiteChanged signals.

[Dirk Hohndel: small fix to ensure that we trigger a save to storage]

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:57 -07:00
Dirk Hohndel
ca911e6916 mobile: correctly reset model instead of disconnecting it
This is a much better workaround for the invalid accesses to the
underlying data while transitioning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:57 -07:00
Berthold Stoeger
0f390183e2 mobile/undo: remove deletedDive and deletedTrip from QMLManager
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09 12:41:57 -07:00
Berthold Stoeger
9fb52cc45c mobile/undo: create undo-action and connect to undo of dive deletion
Still buggy: Removing a dive followed by undo shows the wrong dive
in the list. But clicking on it gives the correct dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:57 -07:00
Berthold Stoeger
c0095f690f mobile/undo: compile undo commands and call undo command for deletion.
First steps towards full undo on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Berthold Stoeger
730fd26814 mobile/divelist: connect click on trip to toggle MobileListModel
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
edeaf7fa57 mobile: remove collapsed model that we no longer use
The dive list now uses the mobile list model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
b382445e59 mobile/divelist: rewrite the QML dive list
This isn't perfect yet, but it looks fairly reasonable.

This commit was mainly written by Dirk, but includes a few fixes from Berthold
which where squashed into this commit as they really should have been part of
the initial version.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
90f8c1138e mobile/DC-download: be more careful exiting download page
Don't just pop the top page off the stack, but pop the download page.
Also explicitly switch to the dive list afterwards.

Additionally, fix a typo in the code that attempts to deal with the
shortcut buttons. I believe that right now this code is completely
broken, but while I contemplate how this should work, let's at least fix
the stupid typo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00