Commit graph

17667 commits

Author SHA1 Message Date
Berthold Stoeger
ffc3e598fa core: create fake cylinder at end of cylinder table (hack!)
When we had fixed-sized cylinder arrays, the planner used the last
empty cylinder for "surface air". This was not recognized by the UI
as a separate cylinder, because "empty cylinder" was the sentinel for
the end of the table. The conversion to dynamically sized cylinder
tables broke this code: everytime the surface segment is changed,
a new dummy cylinder is added, which is visible in the UI.

As a very temporary stop-gap fix, emulate the old code by creating
a cylinder and then setting the end-of-table to before that cylinder.
This means that we have to loosen the out-of-bound checks.

That's all very scary and should be removed as soon as possible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 12:36:28 +02:00
Berthold Stoeger
b949bad026 core: always keep an empty cylinder at the end of the cylinder array
This will be temporarilly used by the planner to mark consumption of
air at the surface. Do this by creating a new function add_cylinder,
which replaces add_to_cylinder_table() and takes care of always adding
a dummy cylinder at the end of the table. Make the original
add_to_cylinder_table() local, so that it cannot be accessed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 12:36:28 +02:00
Berthold Stoeger
0c28821d28 cleanup: replace Q_ASSERT by qWarning
These two Q_ASSERTs made no sense - their expression (a string
literal) always evaluated to true. A qWarning() was intended here.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30 16:55:19 -07:00
Berthold Stoeger
3ed36b2ab5 cleanup: remove DivePlotDataModel::diveId
Nobody was using that member variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30 14:14:13 -07:00
Berthold Stoeger
60b00162a9 desktop: don't replot profile when populating dive information tab
When the dive mode is changed, the profile has to be replot. This
is by a function of the TabDiveInformation. However, that function
was also executed when populating the tab. Thus, when changing dive,
the profile was plot twice.

Move the profile plotting out of the function. Ultimately, the profile
should listen to the appropriate signals itself.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30 14:14:13 -07:00
Dirk Hohndel
ff0438a3fd Github Actions: don't bundle mac app
There's no point in doing that since the app directory this creates is broken
on older macOS versions, anyway (and we create a working DMG through a
webhook).

Additionally, lately this has started to fail on GitHub, so let's just rip this
out.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-30 14:06:48 -07:00
Lubomir I. Ivanov
8e1771cb4c README.md: fix typo in system requirements
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2020-04-27 22:50:18 +02:00
Berthold Stoeger
142dc6f96f profile: set empty state when there is no current dive to show
The profile data was not properly cleared when not showing a
dive.

Fixes #2787

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-27 22:19:31 +02:00
Berthold Stoeger
5ba7c68433 cleanup: remove unused function get_divepoint_gas_string()
The last user was removed way back in commit
9fbd11744f.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-27 22:48:15 +03:00
Dirk Hohndel
006d630142 build-system/Android: add missing install-qt.sh
This file is copied from the QBS project. It's under LGPL and therefore
compatible with our licensing. While it would be possible to retrieve
this file at build time from the original project, for now it seemed
easier to include it in our repo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-27 11:04:29 -07:00
Dirk Hohndel
0c0d65e2cb GitHub Actions: we can't have an action with no on: clause
So in order to disable an action, I'll just use an unused
repository_dispatch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-27 09:34:07 -07:00
Jan Mulder
906762027b Revert "map: remove selectedDivesChanged"
This reverts commit cd47499694.

The signal removed in the reverted commit was used in Subsurface-mobile.
So removing it, caused a not running app.

Signed-off-by: Jan Mulder <jan@jlmulder.nl>
2020-04-27 14:48:37 +02:00
Dirk Hohndel
da953fa18a move GitHub url to the Subsurface org
Instead of using the Subsurface-divelog user on GitHub, we now use an org that
was generously donated to us.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-26 16:36:30 -07:00
Berthold Stoeger
2021035cfc selection: replace selectedTrips() by singleSelectedTrip() function
To check wether the tab widgets should show the trip view, they called
the selectedTrips() function. The trip view was shown if that contained
only one trip. However, the selectedTrips() function was very slow,
because it has to query to core models.

Change the function to singleSelectedTrip(), which returns a trip
if there is exactly one trip selected. The function returns early
if there is more than one trip selected. This makes the select-all
case much faster.

There are two cases which are still very slow:
- List mode, because here all top-level items are queried.
- Dive log with many only top-level items.

Ultimately, we will have to cache the trip selection because
querying the model is too slow.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
6e83135fba desktop: select dives at once
The old code would call QItemSelectionModel::select() once for every dive.
Instead collect the selection in a QItemSelection and only call
QItemSelectionModel::select() once. This makes selecting multiple dives
significantly faster.

The loop also expanded the trips with selections. This has now to be
done in an extra loop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
4f438d1e32 dive list: don't access selected dives via indices
When determining the selected dive sites to highlight them on the
map, the DiveListView code used the local indices of the selected
dives. However, that was unreasonably slow. Even though a layering
violation, let's access the core data structures directly. In my
tests this improved from 700 ms to 0 ms!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
f43b3f56b2 cleanup: remove Command::inCommand()
This was used by the divelist to check wether a selection change is
programmatical or user-initiated. However, since there is only one
entry point for programmatical selection changes, this is not needed
anymore. Remove it - this removes an inter-module dependency.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
2ad3696230 cleanup: make DiveListView slots private
It makes reasoning about code so much easier when one knows that
functions cannot be accessed from the outside. Therefore, make
a number of DiveListView slots private. Moreover, unslotize
functions that never were used in connect calls.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
5d49da5d6b selection: move test for programmatical selection changes to widget
The DiveListView widget has to differentiate between programmatical
und user-initiated selection changes. It did so by using the
DiveListNotifier::inCommand() flag.

However,
1) There is only one point of entry for such selection changes,
   viz. the MultiFilterSortModel::selectionChanged() signal
2) This signal is not only emitted in command-context.
   Another source is for example dive-map selection changes.

Therefore, move the programmatical-selection-change status down
to the widget and set/reset it in the diveSelectionChanged() slot.
This makes "select all visible dive sites" somewhat faster. Sadly,
not as much as expected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
aaecc6e98e cleanup: make various functions in DiveListView private
Outside callers had no business calling these functions.
Especially some functions that were simply there to override
default DiveListView behavior. Mark these as overridden.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 13:20:25 -07:00
Berthold Stoeger
b8e7a600d2 cleanup: remove DiveListView::selectDives()
This was used by the map to select dives. However, the map now calls
the core function directly, so this can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 13:20:25 -07:00
Berthold Stoeger
75ef8b68a1 map: call set_selection() core function to select dives
The map widget called the dive list to select dives. This is
inconsistent and complex. The dive list has to call down to
the core anyway. Therefore, change the code to call the common
core function.

This means that we have to transform integer ids into dive-pointers.
That is a bit sad, because the dives were just transformed into
indices. Let's address that in a future commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 13:20:25 -07:00
Dirk Hohndel
eccbf01a22 GitHub Actions: disable Android container builds on GitHub
Building this locally and squashing layers creates a MUCH smaller image.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
f04bfd4a86 GitHub Actions: use the Qt 5.13.2 based Android build container
This is no longer created using GitHub actions (but all the necessary
information is still included in this repo). We need to be able to
shrink this container so our GitHub Action runs don't run out of disk
space.

Adjust the path where the resulting binaries are found with this build.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
0fe02af0e8 build-system/android: remove libusb at QTest
We no longer use libusb to access USB devices on Android, therefore
there's no point including libusb in our build. Also, we have never even
attempted to run the tests on Android, so let's not even pretend to
support building them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
d3e495efd0 build-system/Android: use PREFIX outside of NDK
If we install our support libraries into the NDK we later run into
include path order issues that result in strange errors around the
inclusion of math.h (because we find the C version of that include
file that ships with the NDK before we find the libstdc++ version
of math.h (because the include path for our support libraries is
listed before the libstdc++ include search path). By having a distinct
install-root for our libraries we can avoid this problem.

Remove the previous hack that tried to work around the symptoms of
this issue.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
f112be7a61 build-system/Android: use install-qt.sh to install Qt
The official installer now requires the user to log in which we can't
really do in a scripted manner. Let's see how long this way of
installing things will be available.

While doing this remove an ancient hack of some Qt settings that we no
longer need.

This also tries to prune some things that we don't need in the Docker
image to reduce image size.

The mapbox plugin is removed as it would add a dependency to QtSql which
we otherwise don't need. And since the plugin isn't used, no point in
installing it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
c0ecd3a597 build-system/Android: create standalone toolchain in wrapper script
This way when we build the android build container, the correct toolchain
is already in place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
9025a9b2b1 build-system/Android: update some dependency versions
Qt 5.13.2 fixes a few bugs.

We are NOT switching to Qt 5.14 as that breaks a ton of things with
Android support. At this point even with qmake it near impossible to get
working Android binaries, no one appears to have a solution for cmake.

With qt-android-cmake current master fixes the problem that held us back
at the earlier commit, so let's go back to using master.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
999cc2d642 build-system/Android: remove no longer supported Qt versions
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
b0d2e5c737 build-system/Android: don't bundle the user manual
That wouldn't work, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Dirk Hohndel
212da3d92f maps: disable link to Google maps on iOS and Android
It appears that on those two platforms you now need a paid API key in order
to have this feature work. Certainly not something I'm going to do.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-25 13:18:41 -07:00
Berthold Stoeger
cd47499694 map: remove selectedDivesChanged
The qml-widget seems to catch selectedDivesChanged signals of the
MapWidgetHelper and reemit them. However, there seems to be nobody
listening to this signal?

Let's remove this for now to make debugging of the signals easier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 23:05:31 +03:00
Berthold Stoeger
702d8c754d desktop: remove selectionChangeDone() from DiveListView::selectDive()
This was erroneous, as it should only be called at the end of
a selection change, not after every single dive. It made selection
of multiple dives extremely slow.

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Debugged-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
9fae262188 desktop: fold DiveListView::selectDive into DiveListView::selectDive
DiveListView::selectDive() is an overloaded function. The second
version was only called by the first version, so we can fold one
into the other.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
f8d3501c22 desktop: remove scrollto default parameter of DiveListView::selectDive()
No caller was using that parameter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
e26ac9e58d desktop: remove selection-code to select a new current_dive
The undo-machinery makes sure that a current_dive always exists
after an undo command. This part of the code should never be
called.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
c00737eb23 desktop: don't select current dive after collapsing trips
This appears to be an artifact. Collapsing does not unselect
the current dive, so reselecting it appears pointless.
Also it is unclear why the selection should be restricted to
a single dive after collapsing.

Probably that was originally meant to expand only the trip
with the current dive in it?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
b6aad78dab desktop: make DiveListView::selectDive() private
Thus, it is made clear that these member functions can only be
accessed from DiveListView itself. This should make debugging
easier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
d8fabd241c cleanup: move clearing of event names to clear_dive_file_data()
Move this to the core so that desktop and mobile don't have
to call this explicitly. Matter of fact, mobile didn't call
this. It is unclear, whether that was even used on mobile,
though.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
17526ded58 cleanup: move clearing of device nodes to clear_dive_file_data()
It makes no sense to keep the device nodes if all the other data
is cleared. Let's do this automatically and not explicitly.
This ensures that the function is also called on mobile.
Currently it was only called on desktop.

Weirdly, the parser-tests were expecting that the device nodes
were not reset by clear_dive_file_data() and therefore divecomputers
were accumulating in the test results. Thus, the additional
computers had to be removed from the expected test results.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
52f93ea326 cleanup: whitespace fix
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
9386eb2a0b cleanup: move get_dc_nickname from qthelper.cpp to divecomputer.cpp
1) qthelper is already huge.
2) set_dc_nickname et al. is already there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
3d4698c0a1 filter: add a week to maximum default date time
The filter sets the maximum date to now. This is so confusing when
you manually add a dive and it isn't shown, because it is slightly
in the future. Add seven days, that should help.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:05:27 -07:00
Berthold Stoeger
89784a176e filter: implement filtering for divemode
This only checks the first divecomputer as the semantics for
multiple dive computers with different dive modes are not
clear. Should we check them all?

The implementation is a bit hackish: the indexes [0...n] of the
combobox are mapped onto [-1...n-1], where -1 means don't filter
and n-1 is the last valid dive mode.

Implements #2329

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:05: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
Berthold Stoeger
a8aa897117 desktop: don't access first data element if no cylinders
TabDiveInformation::updateProfile() does some statistics via the
per_cylinder_mean_depth function. It passes down arrays with one
entry per cylinder, which are allocated by means std::vector.

To pass the array, the expression "&vector[0]" is used. It seems
like some compilers through an assertion violation if vector
has no elements. They are technically correct in that this is
undefined, but still this appears like very unfriendly behavior.
After all, std::vector should behave just like a dynamic C-array
that is automatically freed, when going out of scope.

Replace the "&vector[0]" by "vector.data()" and don't do the
call if there aren't any cylinders for good measure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21 07:50:38 -07:00
Berthold Stoeger
4aebcdc021 core: return -1 from explicit_first_cylinder() if dive has no cylinders
Arguably, returning 0 for a dive with no cylinders is wrong, since the
0 is a valid cylinder id, however that cylinder doesn't exist. Instead,
return -1. All callers of explicit_first_cylinder() return early anyway
for dives with no cylinders.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20 12:59:06 -07:00
Berthold Stoeger
d81df0dd19 profile: avoid invalid accesses in setup_gas_sensor_pressure
Since we removed MAX_CYLINDERS, we have the possibility of dives
with no cylinders. In such a case, setup_gas_sensor_pressure()
would do invalid read- and write-accesses. Therefore, return
early in such a case.

Reported-by: Chirana Gheorghita Eugeniu Theodor <office@adaptcom.ro>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20 12:59:06 -07:00
Berthold Stoeger
a3238020ee desktop: rearrange widgets on the dive site tab
Move the more commonly used filter to the left and the less
commonly used "purge unused sites" button to the right. Add
a spacer so that the filter-textbox doesn't extend over the
whole free space.

With apologies to sinistroverse users (is there an option to
make the layout direction depend on the locale?).

Suggested-by: Hartley Horwitz <hhrwtz@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20 09:46:24 -07:00