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>
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>
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>
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>
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>
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 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>
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>
No reason to keep this as a macro - a function is easier to
read, type safe and easier to debug. Moreover, give it the
more appropriate name "nearly_equal()". After all, it precisely
does NOT check floating points for equality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The FP_IS_SAME macro uses a relative precision to compare
floating points. This fails when comparing to 0. Therefore,
use an absolute precision in this case. Implement as an
inline function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Other overridden functions of this class are marked as well,
so let's do it for this function for consistency reasons.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When there is no map support, selection of dive sites is suppressed.
There is no point in calculating the selected dive sites in this case.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If the entries in the DiveLocationModel don't have their entries
set as editable, the auto-completion popup turns of composition
if such an item is highlighted (see Qt code in
/src/widgets/itemviews/qabstractitemview.cpp), thus disabling
composition of multi-key characters.
Therefore, set this flag. Seems weird, but what should we do!?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is crazy: when view() is called, the dive-site-suggestion
popup (DiveLocationListView) clears its WA_InputMethodEnabled
flag. This makes key composition not work as long as the
popup is open.
Thus, when showing the popup, explicitly set the flag.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Adds a preference setting in the "Default" settings tab to toggle whether
to display shortened names in the Map.
TODO: instead of using the generic "settingsChanged" signal, it would be much
more efficient to only update items based on the actual setting which was
changed.
Signed-off-by: Michael WERLE <micha@michaelwerle.com>
Attn: horrible hack!
For some reason the completion-popup does not have the
Qt::WA_InputMethodEnabled flag set. Thus, if the popup is open
composition of characters breaks.
Therefore, when starting completion, explicitly set the flag
on the popup.
This is 100% not how this was intended, but seems to work for
now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The TagWidgets hook into the textChanged() signal to invoke
the word-completer. However, that signal is also emitted for
composition-keys, making composition impossible if the completer
decides that it should show some entries.
Instead, hook into the inputMethodEvent() function, where one
can test whether a real character was input.
Also, don't hook into cursorPositionChanged(), since that led
to an uncanny cascade of reparse() calls when editing text.
The UI experience is still rough as sometimes the completer
popup steals the focus and hinders further entry.
Also, this doesn't fix the location field, which is its own class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
State requirements for email address and
password format within cloud preferences UI
If email address or password entered in cloud
preferences, raise a warning within a
QMessageBox instead of the less-visible
report_error method
Signed-off-by: Jon Massey <jon.massey@thedatalab.org>
This allows having 3m depth grid for metric users.
* All original properties ( named diferently ) were renamed to three_m_based_grid everywhere to be consistent.
* Plus other small changes requested during review.
Signed-off-by: Vlad A. <elf128@gmail.com>
Signed-off-by: Vlad A <elf128@gmail.com>
Because of the old connect syntax used the incorrect signal names weren't
caught at compile time. To switch to the new syntax we had to make two
functions pure virtual in the WebServices class - let's hope I got that right.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Making this simply depend on Qt5 or Qt6 was short-sighted as work on QtLocation
upstream continues. Instead break this out as its own option.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The undo stack is only relevant to the dives that were loaded at the
time the command was executed. If a file is closed, by specifically
closing it or opening another file, then the undo commands will
reference dives that aren't available anymore. Clearing the undo stack
ensures that we don't crash or accidentally do some undefined
modifications to the currently open file.
Signed-off-by: Michael Andreen <michael@andreen.dev>
To import media files from the web, increas the size of the
dialog box and allow several URLs separated by newlines.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Way back in time, in HwOS 1.86 a CCR mode was added which automatically
switched between setpoints based on depth.
This entry was never added in our system to configure the dc, and caused
the issue seen in #3304
This adds the Auto SP mode, to the dropdown, thus fixing #3304.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
The only things in display.h were profile related, so the
split between these two files is not comprehensible.
In fact profile.h includes display.h, because it needs the
struct defined therein. Let's just merge these two files.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only caller misused this function to get access to the
current divecomputer. Remove it, since selection of the
current divecomputer is handled by the MainWindow.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were only three users of that. For now do it inline, but
we may think about a separate function, which is only available
on desktop.
Moreover, add nullptr-checks, even if they are not strictly
necessary.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
CID 376698 was a false positive, but understandable.
It is very hard for Coverity to realize that current_dive
cannot be null if editedDive is not-null.
By replacing current_dive by originalDive, the alert
should go away, since the latter is not checked for null.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a column to the equipment table that shows if a sensor is attached to a
tank, or which sensors would be available to attach to a tank that currently
doesn't have a pressure sensor associated with it.
Changing the sensor assignement can be undone.
This column is hidden by default as this is a somewhat unusual activity.
Signed-off-by: Michael Andreen <michael@andreen.dev>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This file was so confusing: A tabwidget containing a layout
containing a tabwidget. This strange situation is probably
due to moving the multi-dive warning message.
Remove the file, there seems to be nothing of importance
in there. All the UI was moved to the individual tabs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, when the profile is in edit mode, the user can't
save, exit, plan a new dive and is requested to save the
current dive. However, this makes no sense anymore, since
the profile always switches to edit mode when showing a
manually added dive.
If the user has any unsaved profile changes, the usual
dirty checks of the undo-system apply.
Only show above behavior when in the planner. There it is
useful because, these are not included in the undo system.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The edit mode was hidden in a context-menu. With fine-grained
undo there seems to be no need to explicitly exit edit mode.
Therefore, always switch to edit mode when displaying a
manually added dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was always this weird asymmetry that the "maintab" widget
is one of the tabs itself, whereas the additional tabs were
treated as extra-widgets. Turn the first tab into explicit
source files to make the distinction between container and
content clear.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This only calls MainWindow::showProfile(), so simply call
that directly.
Moreover make two "public slots" private member functions,
since these were only called locally.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When the user undos/redos the profile should update even
when in edit mode. This is a bit more complicated than
anticipated:
1) We should not do the update when emitting an undo command
from the profile. But we *should* update if it is an undo
command from the maintab (change depth/time).
2) The divepointsplannermodel has to be reset. Side note:
the code is truly abysmal as it sends numerous changed-signals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Place undo commands for every change of the profile, not
only on "saving". Move the edit-mode from the mainwindow
and the maintab to the profile widget.
This is still very rough. For example, the only way to exit
the edit mode is changing the current dive.
The undo-commands are placed by the desktop-profile widget.
We might think about moving that down to the profile-view so
that this will be useable on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These two actions were using the same command with a flag
controlling the name of the command, which is shown in
the undo menu.
However, the replanDive does much more (such as changing
the notes) and in the future we may want to be more
fine-grained with respect to profile editing. Therefore,
split these commands into two separate ones.
Moreover, make the editProfile command more flexible.
Pass an enum describing the action instead and also
a counter indicating how many points have been
moved or removed.
Finally, don't consume the input dive in the editProfile
command, because we will want to keep the original dive
while editing the profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It appears that the QML object that is created when assigning the source
to the StatsView in the ui can be garbage collected and therefore
destroyed and re-instantiated without our knowledge. So instead of
trying to keep a pointer around, we end up looking up the object address
when needed.
We still ask the JS code to not garbage collect the object - but that
clearly isn't enough to prevent it from being destroyed when the parent
widget changes.
Without this fix opening the statistics will crash with Qt6.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The QVectorIterator is only available in Qt6 when you explicitly add the
include files.
Suggested-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This no longer compiles when defined in the .ui file. But functionally this
should be the same and it should work on Qt5 and Qt6.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This worked without that include in Qt5, but having it there doesn't hurt,
either, so instead of yet another conditional compile, let's just include it
everywhere.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the explicit QBluetoothUuid instead of just QUuid and deal with new
constants and signal names.
At least with Qt6 we no longer need the ugly QOverload hack.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QStringRef is gone in Qt6 and mostly replaced by QStringView. The one major
difference is that direct comparisons with string literals are no longer
possible.
Thanks to Thiago Macieira for helping me avoid more conditional compilation
here.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We do want the -Wfloat-conversion warnings where they point out
potential bugs. But they are very distracting when they are triggered by
floating point literals (which the standard defines as double) passed to
a function expecting float arguments.
The fact that Qt6 changes the arguments to all these functions from
double to float is... hard to explain, but it is what it is. With these
changes, for the majority of cases we create inlined helpers that
conditionally compile to do the right thing. And in a handful of other
cases we simply cast to float (and accept that on Qt5 this then gets
cast back to double... for none of these cases the potential loss in
precision makes any difference, anyway - which likely is why the Qt
community made the decision to change the type of the arguments in the
first place).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>