Commit graph

19578 commits

Author SHA1 Message Date
Berthold Stoeger
5bd5ff2c2d statistics: fix zero-range on value axis
The code that calculates the bounds of the value axis was broken
when all items had the same value. In that case, increase the shown
range explicitly. It doesn't really matter how much the range
is increased, because all items will be at the center of the graph.

Also, don't overwrite the "decimal" value of the class. That was
just weird.

Fixes #3544.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-19 15:06:22 -08:00
Berthold Stoeger
cf70a25be4 statistics: remove old unused statistics code
This never came to be - no point in carrying it around.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-19 15:03:30 -08:00
Berthold Stoeger
5525344594 git: don't access global dive site table
When loading a git repository, dive sites where loaded into the
global dive site table, not the local table. Apparently, nobody
ever tried to import a git repository into an existing divelog
(as opposed to opening it in the application). Because that would
have probably given funky results.

Remove this access of a global variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-15 14:15:11 -08:00
Berthold Stoeger
2112bd8e08 build-system: make -build-with-qt6 work
-build-with-qt6 did not work for me, because the flag is
ignored when selecting the qmake executable. It would find
the system-wide qmake executable, which is Qt5 and then
decide to build with Qt5.

When the flag is set, try to search for a Qt6 version of
qmake first. On Ubuntu based distros this seems to be
qmake6

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-15 14:08:37 -08:00
Robert C. Helling
741099bdbb Show correct gas density in CCR mode
When collecting the data for the infobox, we have
already computed the current partial pressures of the
breathing gas taking into accoutn the divemode. Use
those rather than fractions (which for CCR mode are
those of diluent) to compute the gas density.

Reported-by: Pietro Tranquillini <p.tranquillini@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2022-11-08 10:43:47 -08:00
Dirk Hohndel
46365b3199 Merge remote-tracking branch 'origin/bstoeger-range'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-11-08 08:13:27 -08:00
Dirk Hohndel
01a25edf82 Update to latest libdc
- uwatec smart: allow bigger BLE packets
- Garmin: attempt to parse big endian FIT files from the Garmin website

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-11-08 08:11:07 -08:00
Berthold Stoeger
4bbe5646a5 cleanup: remove unused declarations in planner.h
Most of these declared non existing functions or pointers.
One [get_gas_idx()] was only used in one source file and
doesn't have to be globally accessible

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-01 12:12:19 +01:00
Berthold Stoeger
691d9e86de cleanup: implement index_of() and index_of_if() generics
Search the index of an item in a container. Compare by
equality or a lambda. The lack of these have annoyed me for a
long time. Return the index of the first found element or
-1 if no element found.

Currently, only supports random-access operators. Might be
trivially changed for forward iterators.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-31 19:35:15 +01:00
Berthold Stoeger
d3867af1b9 profile: clear dive pointer when clearing profile
Try to avoid stale pointers when resetting the dive data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 15:02:36 -07:00
Berthold Stoeger
e0e21cab3d profile: reverse plotting and showing of profile
When switching from "empty mode" (i.e. the subsurface logo is shown,
because no dive is selected), the profile is first shown by switching
to the appropriate tab and then plotted. However, the showing might
lead to a resize event and then to a crash with owing to stale dive
data. Therefore, reverse that.

Note that I never could reproduce that.

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 15:02:36 -07:00
Berthold Stoeger
9bca38afcf profile: recalculate profile info when switching from empty state
When the profile was to small, it would switch into empty state
and clear the plot info.

On resize events, the plot info is not recalculated.

This means that when making the profile extremely small and
then bigger, nothing is shown.

This may also happen on startup. The profile is rendered into
a 0x0 widget and then gets a resize event.

Therefore, remember when the profile is empty and force a
recalculation of the plot info.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 15:02:36 -07:00
Berthold Stoeger
df5bf728f9 cleanup: remove thumbnail conversion function
The chances that their are still users of the old thumbnail
format (i.e. all thumbnails saved in the hash file) are basically
0. If there are they will just get their thumbnails rebuilt
when opening the individual dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 22:06:17 +01:00
Berthold Stoeger
b63073e203 cleanup: use range based loops in model
There were a number of classical "for (i = 0; i < size; ++i)"
loops. Replace them either by plain range based loops if the index
is not used or by enumerated_range() loops.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 22:06:17 +01:00
Berthold Stoeger
727d519046 cleanup: use singleton pattern for getPrintingTemplatePath*()
Function-local statics are initialized on first invocation.
No point in extra logic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 21:57:44 +01:00
Berthold Stoeger
f407f5269a cleanup: use std::size() instead of arithmetics
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 21:57:44 +01:00
Berthold Stoeger
e2338fe7e9 core: use range-based for loops in filterconstraints
This source file was looping over descriptors in a classical
"for (int i = 0; i < size; ++i)" loop.

However, the index is not really used, except for fetching the
actual elements.

Replace by range-based for loops. This prevents the potential
error of using the wrong size.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 21:57:44 +01:00
Berthold Stoeger
cea171ffd4 core: implement an enumerating iterator
In the printing-template code, we loop through a vector and
then determine the index of the current element by searching
the vector. This irks me.

Since looping over a collection with an index is a rather
common theme, implement an enumerating iterator that can
be used as in:
	for (auto [idx, item]: enumerated_range(v)) {
		...
	}

For now, use it for the above vexing case. Convert other
iterations of this theme later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 21:57:39 +01:00
Berthold Stoeger
94641c510f core: create range.h header for range manupulation functions
The moveInVector() function was defined in qthelper.h, even
though it has nothing to do with Qt. Therefore, move it into
its own header.

Morover, since it is a very low-level function, use snake_case.
And rename it to move_in_range(), because it does not only
work on vectors, but any range with random-access iterators.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 21:16:00 +01:00
Berthold Stoeger
261f07dfa4 core: add make_manually_added_dc() function
For reasons of symmetry (there is a is_manually_added_dc()
function), create a make_manually_added_dc() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
f687e51d4b core: don't consider dives with many samples as manually added
This causes UI confusion. Notably we go into edit mode and
reduce the number of samples, leading to loss of information.

If someone really manually adds a dive with more than 50
samples, they should still be able to explicitly open the
dive in the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-21 16:51:57 -07:00
Berthold Stoeger
9ced3a3a4d statistics: fix date ranges smaller than two days
The calculation of the range was broken, it resulted in
a to-value smaller than the from-value, owing to a
sign-mismatch.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-20 20:06:38 -07:00
Berthold Stoeger
56c91a46b6 statistics: add enough entries for date axis
We must add one more entries than there are days, because the
entries describe the values between histograms.

The root cause of the problem here is that a histogram axis
is misused for a continuous day-axis.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-19 14:35:15 -07:00
Berthold Stoeger
48659c3f7d statistics: fix display of month on continuous axis
tm::tm_mon is 0..11, not 1..12, so we have to add one for
display.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-19 14:35:15 -07:00
Berthold Stoeger
7d366b9afe statistics: properly initialized selected scatter items
Scatter items of selected dives were shown in blue when
changing to scatter mode. They should be yellow from the
start, not only when hovering over them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-19 14:35:15 -07:00
Dirk Hohndel
7b5381b6de desktop: make time shift dialog show correct times
This got broken in commit 7417f865cd ("cleanup: un-singletonize
ShiftTimesDialog") and no one ever noticed.

We need to intitialize the when variable and set up the initial texts in
order for the time shift dialog to show the correct information. Doing
this in the ButtonClicked member (right before the dialog is destroyed)
makes absolutely no sense.

Fixes #3535

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-19 13:29:29 -07:00
Dirk Hohndel
c88d22462d core: better change message in git save
This rarely gets seen / looked at, but it can help make it easier
to understand what a user was doing when trying to restore dives
that were inadvertantly deleted.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-17 16:01:00 -07:00
Dirk Hohndel
cca21cf07f update latest translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-03 13:49:09 -07:00
Dirk Hohndel
6c9c59a2e0 Revert back to latest libdc
Embarrassingly, commit 8c644547fb ("mobile: fix reading of cache dir")
dropped updates to libdivecomputer which went unnoticed for quite a
while. This brings us back to the correct SHA.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 13:36:40 -07:00
Dirk Hohndel
98f1f670c4 Update README and ReleaseNotes for 5.0.10
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 13:28:49 -07:00
Dirk Hohndel
f2a96db687 Merge remote-tracking branch 'origin/bstoeger-mobile-dc' 2022-10-01 13:24:26 -07:00
Dirk Hohndel
bcbbda401e Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 09:56:34 -07:00
Berthold Stoeger
7c8dc016b5 mobile: flip through dive computers on mobile
UI fixed by Dirk.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 18:47:16 +02:00
Dirk Hohndel
d66376a8f3 build-system/windows: don't build the libmtp examples
We had that fail in the GitHub Action - but really, why would we build those in
the first place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-10-01 18:44:37 +02:00
Dirk Hohndel
eb101aab1f build-system: run iOS GitHub action on macOS 11
macOS 10.15 is deprecated on GitHub.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-09-23 12:13:06 -07:00
Dirk Hohndel
884dbc9d5e Merge remote-tracking branch 'origin/bstoeger-divesites' 2022-09-23 08:02:54 -07:00
Dirk Hohndel
eb59d426d1 Merge remote-tracking branch 'origin/bstoeger-gnome' 2022-09-23 07:58:06 -07:00
Dirk Hohndel
99e6e11c8c Merge branch 'sensor-index-fixup' of https://github.com/torvalds/subsurface-for-dirk 2022-09-23 07:57:05 -07:00
Berthold Stoeger
621a0a4e3a desktop: remember previous state when switching to dive site mode
The dive-site editing can be reached from two states: from the
dive view and the dive list view. It always jumped back to
the dive view.

Therefore, remember the state. Use a stack-like structure, so
that the feature can be used for the dive-site view as well.

This is a bit inconsistent, because for example the statistics
view does not remember the previous state and allows a direct
jump to a different state. That should be fixed at some point.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-09-23 15:50:50 +02:00
Berthold Stoeger
17033d0d83 desktop: make dive site list an independent widget
This used to be one of the tab-widgets, which was illogical
and caused confusion. Notably, erroneously clicking on the
tab header led to a reset of the dive selection.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-09-23 15:50:49 +02:00
Berthold Stoeger
86e3ceb0e9 cleanup: remove isGnome3Session function
This is only used for archaic distros.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-09-23 15:40:09 +02:00
Linus Torvalds
02f158b0c2 Fix the dc sensor index fixup
fixup_dc_sample_sensors() would make sure that any pressure sensor
indexes were in range of the cylinders by just clearing the pressure
data if the sensor index was larger than the number of cylinders in the
dive.

That certainly makes the sensor index data consistent, but at the cost
of just dropping the sensor data entirely.

Dirk had some cases of odd sensor data (probably because of an older
version of subsurface, but possibly due to removing cylinders manually
or because of oddities with the downloader for the Atomic Aquatics
Cobalt dive computer he used), and when re-saving the dive, the pressure
data would magically just get removed due to this.

So rewrite the sensor data fixup to strive very hard to avoid throwing
pressure sensor data away.  The simplest way to do that is to just add
the required number of cylinders, and then people can fix up their dives
manually by remapping the sensor data.

This whole "we clear the pressure data" was at least partly hidden by
two things:

 (1) in the git save format, we don't rewrite dives unless you've
     changed the dive some way, so old dives stay around with old data
     in the save until explicitly changed.

 (2) if you had multiple dive computers, and one dive computer does not
     have any pressure data but another one does, our profile will use
     that "other" dive computer pressure data (because often times you
     might have only one dive computer that is air integrated, but you
     still want to see the tank pressure when you look at other dive
     computers - or you have one dive computer give pressure data for
     your deco bottle, and another for your travel gas etc).

So those two facts hid the reality that we had actually cleared the tank
sensor data for Dirk's dive with the Atomic Aquatics dive computer,
because we'd still see pressure data in the profile, and the git data
would still be the old one.

Until Dirk renumbered his dives, and the data was rewritten.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-09-20 09:49:57 -07:00
Linus Torvalds
aa50be9cd5 Use the right type for sanitize_sensor_id()
It returned a 'uint8_t', which clashes pretty badly with NO_SENSOR being
-1, and turned it into 255.  That then ended up historically working,
because before commit 0c84f369c3 ("core: use int16_t for sensor-id")
we actually did that everywhere:

 #define NO_SENSOR ((uint8_t)-1)
 ...
    uint8_t sensor[MAX_SENSORS];

but that was changed to

 #define NO_SENSOR -1
 ...
    int16_t sensor[MAX_SENSORS];

and this helper type became wrong.

Just make it return 'int', avoiding any type narrowing issues.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-09-20 09:41:35 -07:00
Dirk Hohndel
b5889f0f3c Merge remote-tracking branch 'origin/bstoeger-profile' 2022-09-19 09:29:52 -07:00
Dirk Hohndel
13482a961d Merge remote-tracking branch 'origin/bstoeger-tabwidget' 2022-09-19 09:23:47 -07:00
Dirk Hohndel
bb3ddf521b mobile: update version to 3.4.8
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-09-19 09:18:34 -07:00
Berthold Stoeger
724af75722 desktop: disable extradata tab if no site selected
Owing to bit-rot, the extradata tab was not disabled if no dive
is selected. The reason was that there was an additional tab
(dive-computers) that should not be disabled. However that
tab was removed and now the extradata tab was not disabled.

Fix this, but note that there is another of these 'parasitic'
tabs, that should be removed, namely the dive-site tab.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-09-18 13:49:29 +02:00
Berthold Stoeger
24926f6031 profile: don't use displayed_dive to check whether dive changed
The profile replots if the mode of the currently displayed
dive changed. To do so, it compares the changed dive to
the displayed_dive. However, that is only used for planned
dives since quite some time.

Fix the check and make the replotting work again.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-09-17 19:51:53 +02:00
Berthold Stoeger
3abb82bfd5 map: don't explicitly reload the map from the mainwindow
The map listens to the reset signal by itself.

This avoids double reload of the map on open/close.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-09-15 12:16:32 -07:00
Captain Junk
fbb737e85b Update INSTALL
Add some additional info on getting the
FTDI drvier to recognize dive computers on
Raspberry Pi OS.

Signed-off-by: Captain Junk <captainjunk@gmail.com>
2022-09-15 12:16:07 -07:00