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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Render a warning sign in front of the event string
in the infobox. This is done in rich text.
Note: This shows the warning sign for all events,
not just warnings.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
When zoomed in, the profile position was moved by hovering with
the mouse. What a horrible user experience. This is especially
useless if we want to implement an interactive profile on mobile.
Instead, let the user start the panning with a mouse click. The
code is somewhat nasty, because the position is given as a
real in the [0,1] range, which represents all possible positions
from completely to the left to completely to the right.
This commit also removes the restriction that the planner handles
can only be moved when fully zoomed out. It is not completely
clear what the implications are. Let's see.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A QVariant was initialized but never used.
While doing so, remove construct/assign pairs of a number of
QStrings. Directly construct the QStrings with the desired
values.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The get_minutes() function formats a time as m:ss
and returns a static C-string. Since all callers are
C++ anyway and transform directly into QString, let us
move this to the other string formatting function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Also allow editing sensor on a cylinder with already attached sensor.
This will swap the sensor data with the cylinder that it is taking the
sensor data from, removing the need for adding an extra temporary
cylinder when swapping two sensors.
Signed-off-by: Michael Andreen <michael@andreen.dev>
The SSRF_INFO() macro is widely used, and there's a lot of confusion
about whether the newline at the end should be done by the SSRF_INFO or
be in the format string passed to it. End result: we end up doing both,
and there are empty lines in the output as a result.
Clean this up by just using our existing 'strip_mb()' to strip any
whitespace at the end of the generated string, and then adding one final
newline when logging it.
Also, make sure to log our 'report_error()' messages, which apparently
only used to be showin in the red error bar on the display.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of using the save file dialog (which creates a horrendous user
experience - and isn't even supported on Android), simply allow the user
to email the file in question to a recipient of their choice, e.g.,
themselves.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>