Commit graph

17338 commits

Author SHA1 Message Date
Berthold Stoeger
42b423f02c cleanup: don't center map on rejecting edit
The editing of the dive site is controlled via an undo command.
No point in centering the map when cancelling a profile-edit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
150bd9763e cleanup: remove lastMode variable in MainTab::rejectChanges()
This stored the old editMode. However, it was not read after
editMode was changed, so there is no point to it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
5f858e137d edit: remove multi-dive version of edit information
The "dive is currently" edited is only shown when the profile is
edited. This affects only the current dive and therefore a
message saying that multiple dives are edited makes no sense.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
6288b2a619 cleanup: remove strange recursive code in MainTab::enableEdition
When enableEdition() was called with mode == NONE and the dive
was a manually added dive, it would call into MainWindow::
editCurrentDive(), which would in turn call enableEdition(),
however with another mode. Since the only caller of
enableEdition() is now editCurrentDive() anyway, we can
remove that weird code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
ee64a85d2e cleanup: remove cylinders_equal check in MainTab::rejectChanges()
This check make no more sense since cylinder editing is now
treated by undo commands.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
d597b6dca5 cleanup: remove unused CylindersModelFiltered functions
add() and remove() are not used anymore since this is done using
undo commands. The planner uses CylindersModel instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
ff38c03e00 undo: add cylinders via undo
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
66fc9fcfec CylindersModel: fold CHANGED() macro into setData()
The CHANGED macro was defined in the cleanerTableModel header.
Since it had only one user, expand it there. The macro was very
questionably anyway, as it would set the local "vString" variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
a75360f58f CylindersModel: test for CHANGED() outside of switch statement
A small code consolidation:

With one exception, all targets of the switch statement would
test for CHANGED(). Instead do the test once and exit early.
This changes the behavior of the function: if not changed, there
will be no more dataChanged-signal. However, this appears to be
the correct thing to do anyway. And it is easily changed if
it matters after all.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
a4a06c48bf CylindersModel: remove mark_dive_list_changed
Cylinder-editing is controlled by undo (either by saving a planned
dive or by using the equipment tab). There is no point in setting
the dive_list_changed flag.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
d02489f888 cylinders: remove CylindersModel::changed
Nobody is testing that flag anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
0732bb2302 undo: remove TabDiveWidget::acceptChanges and rejectChanges
Since cylinders are now edited using the undo system, these
functions are not needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
04ce908e8e CylindersModel: listen and react to signals
React to signals from the undo-commands and update the
model accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
75f37a7d10 CylindersModel: don't test for planner-state in remove()
This is only called from the planner. Therefore, the test is
redundant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
1f8a45db44 undo: call removeCylinder undo command in equipment tab
Instead of connecting to the remove() function of the model,
call the removeCylinder undo command. Take care to translate
the index into the source index, should cylinders be hidden!

Apart from the map-to-source call, this copies the weightsystem
code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
c4bf1ce891 undo: remove only "non-protected" cylinders
The undo-code must take care not to remove used cylinders.
To do so, extend the constructor of EditCylinderBase,
which collects the cylinders and dives to edit, by the
"nonProtectedOnly" boolean argument. If true, only those
cylinders for wich "is_cylinder_prot" returns false
will be added.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
5b7a316593 undo: reorder cylinders on remove-cylinder undo/redo
The cylinders in the events must be reordered if we remove
a cylinder. To avoid duplication of code, move the reordering
function into qthelper.cpp, though it might not be ideal
there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
a37939889b cleanup: remove CylindersModels::rows
Access the number of cylinders in the dive directly instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
30d289e4a8 CylinderModel: make dive dynamic
The CylinderModel always accessed the global "displayed_dive" and in
some special cases also "current_dive". To implement cylinder undo,
the model should work on an arbitrary dive. Therefore, in analogy
to the weight model, make the dive dynamic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
Berthold Stoeger
aa7b0cadb2 undo: add cylinder undo commands by copy & paste
Do a simple copy & paste followed by a simple search & replace
to generate cylinder undo commands from weight undo commands.
Obviously, this is still missing the necessary code to keep
the dive-data consistent after cylinder editing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:34 +02:00
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