Commit graph

17368 commits

Author SHA1 Message Date
Berthold Stoeger
36754d3399 cleanup: move fill_default_cylinder from planner.c to equipment.c
Moreover, move the declaration from dive.h to equipment.h.
The result is a) more consistent and b) more logical.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
e008b42a59 core: add create_new_cylinder() function
Turn the code in CylindersModel that creates a new cylinder for
addition into its own function to avoid code duplication. This
will be used from the undo commands.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
f1e08fd470 core: introduce set_cylinder() function
We have a set_weightsystem() function. For symmetry, introduce
a set_cylinder() function so that we can more-or-less copy&paste
the weightsystem undo code for cylinder undo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
1ca25ec039 core: make free_cylinder() global
The cylinder undo commands will keep a copy of a cylinder
and therefore need the ability to free a cylinder object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
2453d4fc1f core: introduce clone_cylinder() function
We have a clone_weightsystem function. For symmetry, introduce
a clone_cylinder() function so that we can more-or-less copy&paste
the weightsystem undo code for cylinder undo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
64a5f10cfe delegate: don't add WSInfo entry in delegate
The weightsystem info for new weightsystem types is added by the
undo command. Remove this redundant code. Use the lookup only to
determine the weight and the canonical name (i.e. use the capitalization
according to the saved entry, in analogy to tanks).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-06 08:41:52 -07:00
Berthold Stoeger
fb76eb9a1a delegates: don't use starts-with search to fetch cylinder/weight data
In the wightsystem-type and cylinder-type delegates, when entering
data, when entering known weight- or cylinder-types, some ui fields
(notably weight, size and working-pressure) are automatically filled
out. The search was using the default flags provided by Qt: starts-with
and case-insensitive.

This had a few strange effects, when entering a string that is the
beginning of a known string (e.g. "AL6" when "AL63" already exists):

1) The wrong data was used if the new string didn't exist.
2) For cylinders it was impossible to create new cylinder types whose
   name is the starting string of a different type.
3) For weights, the new type was not added to the list of known types.
   This, however, is no problem, because it will be added by the undo
   command anyway. A future commit will address that redundancy.

Therefore use only the case-insensitive flag (which has to be performed
by passing the MatchFixedString flag - very weird).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-06 08:41:39 -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
46c6a3cb92 CHANGELOG update
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -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
ac9df93a13 build-system: pull newer libxslt
The older version stopped building for iOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
f92c7a20d2 Update CHANGELOG
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
00617aa924 core/models: give progress update while populating models
Especially with large dive logs this will prevent the user from thinking
that the app is hung.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 12:00:25 -07:00
Dirk Hohndel
3df0cf6196 core/fulltext: give progress update while populating index
Especially with large dive logs this will prevent the user from thinking
that the app is hung.

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
f58bc91d8b core: add additional notification callback
Especially on slower devices with a large dive list the startup time has
become really long. This callback allows us to give the user an idea of
what the app is doing during that time.

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
Dirk Hohndel
969b587e3d Next mobile version increment
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
039ed38067 GitHub Actions: add pkg-config to iOS build
Our builds fail because we are missing pkg-config.
I'm not quite sure if this is triggered by a new dependency or if pkg-config
used to be there and now isn't. Either way, this should hopefully fix things.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 11:09:17 -07:00
Dirk Hohndel
0d8324bfb4 iOS: fix libxslt build
We need to build libxml2 without LZMA.
We need to make sure that libxslt finds the libxml2 includes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 11:09:17 -07:00
Dirk Hohndel
6c5c2bfb18 iOS: clean up build shell script
Address shell linter comments. Follow our usual naming for build dirs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 11:09:17 -07:00
Dirk Hohndel
5178ea2d15 iOS: add libxml2 build
I don't know why this is suddenly needed and wasn't before, but hopefully
this fixes the broken builds on GitHub.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 11:09:17 -07:00
Berthold Stoeger
d5e6a65944 cleanup: copy saved_git_id, don't use local buffer
In an attempt to reduce the number of global variables, don't use
a local buffer to store the currently loaded git-id. The git-id
itself is still a global variable, which in the future can hopefully
be encapsulated in a "struct File" or similar.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 10:13:14 -07:00
Berthold Stoeger
8c63d4e2bd build: use -Wno-inconsistent-missing-override in Subsurface-mobile.pro
The inconsistent-missing-override warning is annoying as it prevents
us from adding "override" modifiers: It will warn if we do this only
for selected functions. Sadly, this is the default on clang. Therefore,
we disable this warning for quite some time in CMakeLists.txt. For
consistency also do this in the Subsurface-mobile.pro file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-01 12:26:59 -07:00
Berthold Stoeger
d7d01ab8a6 cleanup: explicitly cast to int to silence a compiler warning
In DivelogsDeWebServices::updateProgress() QProgressBar::setRange()
and QProgressBar::setValue() were passed floats even though they
expect ints. To silence a compiler warning, cast by hand. Use the
lrint() function, since we generally do it this way. However,
it is not clear whether this is necessary here.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-01 12:26:59 -07:00
Dirk Hohndel
2a802721f4 Update CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-31 20:33:11 -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