These no longer compile with Qt6 - but they are already duplicated in C++ code,
anyway. So we can simply remove them.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add additional exported values gasO2, gasHe and gasN2 to be available to the
print template.
Also add these to the user manual as well as document some other missing
variables like surge and chill.
Finally, remove references to Grantlee. While the print template still uses the
syntax that we inherited from Grantlee, we aren't actually using Grantlee
anymore.
Reported-by: Rahul Swaminathan <rahul.swaminathan@gmail.com>
Signed-off-by: Jason Bramwell <jb2cool@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adding additional exported value meandepth to be available in the print
template language.
A possible use of this would be
<td class="fieldTitle">
<h1> Max / mean depth </h1>
</td>
<td class="fieldData">
<p> {{ dive.depth }} / {{ dive.meandepth }} </p>
</td>
Reported-by: Rahul Swaminathan <rahul.swaminathan@gmail.com>
Signed-off-by: Jason Bramwell <jb2cool@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In general, replace "dive master" by "dive guide".
However, do not change written dive logs for now. On reading,
accept both versions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
User report: when switching focus between windows, the
cursor position gets lost. This is due to a note-edit
command being fired, which then overwrites the notes tab.
To prevent this, don't update the notes field when placing
a command. Moreover, generally don't update the dive
selection when placing a command as that also rewrites all
the values.
Should this be extended to other fields?
Fixes#3365
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Two pointers were checked against NULL and then both were
dereferenced if at least one was not NULL. Of course, this
should have been an and, not an or expression.
That said, this is a semi-false positive, since both pointers
are set in the constructor and therefore never can be NULL.
In principle, one could remove the whole check. Of course,
realizing that would require a global analysis by Coverity,
which I reckon it doesn't do.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This removes a block of redundant code that was already broken
out into a helper function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was a user request: Sort bar charts by height of the bars.
Obviously, this can only work for categorical charts, not for
histograms.
The UI is a break from the old concept: the sorting is chosen
based on the chart, whereas for the rest of the features, the
viable charts are presented based on the binning, etc.
I found it confusing to have the possible charts be selected
based on sorting. I.e. if a non-bin sort mode is selected,
the histogram charts disappear. On the flip side, this would
be more consistent. We can change it later.
For value-based bar charts, there are three sort modes: by
bin, by count (i.e. number of dives in that bar) and by
value (i.e. length of the bar). This hopefully satisfies all
needs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
With -Wextra, gcc/g++ complains that compound initialization
of weightsystem_t misses the auto_filled parameter. Add it.
For C++ code we might think about writing a constructor. However,
we use two versions: with and without copied string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, the zoomLevel is reset for every plotDive() call,
because the zooming is done via the QGraphicsScene. However,
this does not work well (e.g. axes are likewise zoomed) and
in the future a change of the zoom level will cause a replot.
Thus, remove the zoom-reset in plotDive() and do it explicitly
when switching dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Dive data are stored internally using integral types using
appropriately fine units (mm, mbar, mkelvin, etc.). These
are converted with functions defined in units.h for display
(m, bar, C, etc.). Usually floating points are returned by
these functions, to retain the necessary precision. There
is one exception: the to_PSI() and mbar_to_PSI() functions.
For consistency, make these functions likewise return floats.
This will be needed for the rework of the profile-axes.
The plan is to use the conversion functions to make the
axes aware of the displayed values. This in turn will be
necessary to place the ticks at sensible distances. However,
the conversions need to be precise, which is not the
case for the current to_PSI() functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Rendering resets the size, which now recalculates the axes.
Therefore, plotDive() must be called. The callers were doing
the opposite: call plotDive() first, then draw().
To make it easier for the callers, present a single interface
that handles these subtleties.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The printFontScale is used to scale up fonts (and icons) when
rendering to high-DPI devices. With absolute scaling, this
will also be used to scale the size of different chart
regions, line thickness, etc. Therefore, give it an more
appropriate name. "Device pixel ratio", which is a well
established term, seems to appropriately describe the
concept.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of using the interactive ProfileWidget2, just
use the ProfileScene to render the profile for printing,
export and mobile. One layer (QWidget) less.
This removes all the kludges for handling DPR on mobile.
Thus, the rendering will now be off and have to be fixed
by redoing the scaling code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This finalizes the split between interactive (ProfileWidget2)
and non-interactive (ProfileScene) parts of the profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The mode of the profile (profile, edit, plan) was set in
MainWindow and ProfileWidget. For consistency move the one
setProfileState() call from MainWindow to ProfileWidget.
This removes a direct access to the profile-view and
therefore improves encapsulation.
Also, clear the profile, when no dive is shown to remove
any potentially dangling references.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was moved to the desktop version. Enter the profile in
the constructor. Somewhat surprisingly, this seems to work.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The profile has an "empty state" showing the subsurface logo,
which is active when no dive is selected.
Switching to/from this mode is quite complex, because all the
chart features have to be hidden/shown, etc. Moreover, this mode
is not needed on mobile, where multiple ProfileWidgets can
be active at the same time and every dive has at least a
"faked" profile.
Therefore, implement this mode directly in the desktop
version of the widget. This makes the rescaling distinctly
less cumbersome. It is implemented using a QStackedWidget,
which switches between the profile and the logo.
This commit does not remove the empty state from the profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since using separate profile-instances for print/export,
we never exit print mode. Therefore, the mode parameter
can be removed. This is a preparatory commit for passing
the printMode at construction time.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Not having to readjust the scale on-demand will make the
code distinctly simpler. Let's just pass it once.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Very annoyingly, to render the profile for printing / export,
the profile still had to be show()n, thus requiring a parent
window.
Analysis of qmlprofile.c showed that this was due to the
transformation matrix not being properly set up on non-show()n
scenes.
Instead, we can simply render via the QGraphicsScene
(circumventing the QGraphicsView).
The code was factored out into the ProfileWidget2::draw()
function. This will hopefully make it easier to change
the size-code of the profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a new class that encapsulates the profile-widget UI.
This is called ProfileWidget, which might be confusing since
the actual display is called ProfileWidget2. However, the
plan is to rename the latter to ProfileView. After all, it
is also used to print and to show the profile on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The MainWindow::configureToolBar() function is called every
time plotCurrentDive() is called. Moreover, this is the only
time that it is called. We might just fold the former into
the latter.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The exportProfile function uses the UI and therefore was
supposed to be declared in backend-shared/* but defined
separately for desktop and mobile. Currently, only the
desktop version exists.
The goal however should be that there is no need of the
UI for this function. In a first step, move the function
to the common backend-shared/* code and conditionally
compile for desktop. In upcoming commits, the function
will be made independent of the UI.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In analogy to normal printing, don't misuse the mainwindow's
profile widget to do the printing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When printing the dives were rendered into the visible profile.
This meant setting a number of flags and reverting after printing.
That's obviously quite brittle.
Instead, use a separate profile instance, since we can have
different profiles showing different dives now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To enable grouping by trip in the statistics module, split
the get_trip_title() function in a version that appends
a "(n dive(s)" string an one that doesn't. The statistics
module doesn't want that added string, since it displays
the number of dives in a different way.
Also, move the functions to string-format.h, where these
are collected. And rename them to camelCase. Yes, it's
ugly, but consistent with most other C++ code in the code
base.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Let the compiler figure out the correct type...
Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On the equipment tab, unused cylinders (automatically added,
no pressure data) could be hidden. This was implemented using
a QSortFilterProxyModel.
Apparently, it causes confusion if cylinders in the middle of
the list are hidden. Therefore, only hide cylinders at the end
of the list.
QSortFilterProxyModel seems the wrong tool for that job, so
remove it and add a flag "hideUnused" to the base model. Calculate
the number of cylinders when changing the dive.
This is rather complex, because the same model is used for
the planner (which doesn't hide cylinders) and the equipment
tab (which does). Of course, syncing core and model now becomes
harder. For instance, the caching of the number of rows was removed
in a37939889b and now has to be
readded.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In cb80ff746b internal columns
were added to the cylinder model. These were not hidden in
the planner. Nobody complained?
Remove this clutter from the UI by hiding the columns.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The logic did not consider the WORKINGPRESS_INT and SIZE_INT
columns added in cb80ff746b.
By some unknown magic this worked by routing everything
through the CylindersModelFiltered model.
Let's fix it and explicitly ignore these columns. Put
the test whether a column should be ignored in a function
to avoid inconsistencies should new columns be added.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
CCRs are different. It does not make sense to compute
a depth dependent SAC. You could compute the rate of O2
consumption but even that is likely wrong (as O2 in the
diluent would enter that as well), so simply don't attempt
it.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
And while doing that, have all the cases where we already include
qthelper.h simply use a define in that header file - but keep the two
other instances of the define where the C++ source don't need qthelper.h
otherwise.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Qt 6 will drop support for QRegExp.
Use QRegularExpression instead.
The syntax for matches and captures has changed and needed to be
adjusted.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Qt 6 will drop support for QRegExp.
Use QRegularExpression instead.
The syntax for matches has changed and needed to be adjusted.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Qt 6 will drop support for QRegExp.
Use QRegularExpression instead.
The syntax for matches and captures has changed and needed to be
adjusted.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The camera sync feature has been moved above the Ok and Cancel buttons
and given its own descriptive header. The checkbox to ignore unaligned
image timestamps has been moved closer to the buttons.
Signed-off-by: Tim Segers <tsegers@pm.me>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The QTimeEdit field is severely limited when it comes to the supported
time range. By coding our own input / validation we can allow far larger
time shifts. For simplicity, this always assumes hours:minutes format.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When using the camera sync feature to sync media to the dive timeline,
the calculated time difference was considered invalid if it was more
than 24 hours.
To prevent this, this commit disables the manual time offset input
fields when the camera sync button is clicked. It then uses the epoch
difference in the final offset calculation, enabling arbitrary time
differences between camera and divecomputer.
Signed-off-by: Tim Segers <tsegers@pm.me>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This tries to make our fingerprinting code work better, by avoiding
using the "deviceid" field that has always been unreliable because we've
calculated it multiple different ways, and even for the same version of
subsurface, it ends up changing in the middle (ie we calculate one value
initially, then re-calculate it when we have a proper serial number
string).
So instead, the fingerprinting code will look up and save the
fingerprint file using purely "stable" information that is available
early during the download:
- the device model name (which is a string with vendor and product name
separated by a space)
- the DC_EVENT_DEVINFO 32-bit 'serial' number (which is not necessarily
a real serial number at all, but hopefully at least a unique number
for the particular product)
but because the model name is not necessarily a good filename (think
slashes and other possibly invalid characters), we hash that model name
and use the resulting hex number in the fingerprint file name.
This way the fingerprint file is unambiguous at load and save time, and
depends purely on libdivecomputer data.
But because we also need to verify that we have the actual _dive_
associated with that fingerprint, we also need to save the final
deviceid and diveid when saving the fingerprint file, so that when we
load it again we can look up the dive and verify that we have it before
we use the fingerprint data.
To do that, the fingerprint file itself contains not just the
fingerprint data from libdivecomputer, but the last 8 bytes of the file
are the (subsurface) deviceid and the diveid of the dive that is
associated with the fingerprint.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The TabDiveComputer model won't work in the new world order, where you
can't even insert a new device entry without a nickname to be edited.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Commit e42fc1a1e9 introduced a
crash condition. Apparently the code attempts to test whether
the clicked-on item is a top-level dive. The "Collapse others"
menu item should not be shown in that case. It does this by
testing "d->divetrip". However, "d" might quite logically be
null if clicking on an unexpanded trip header.
Therefore, check explicitly for the trip header case (which
should show the menu item) and for good measure prevent
the nullpointer access (that should be caught by testing
for trip, but who knows).
Fixes#3301.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Thus, the membuffer data is automatically freed when going
out of scope - one thing less to worry about.
This fixes one use-after-free bug in uploadDiveLogsDE.cpp
and one extremely questionable practice in divetooltipitem.cpp:
The membuffer was a shared instance across all instances
of the DiveToolTipItem.
Remves unnecessary #include directives in files that didn't
even use membuffer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>