Change the output formato for the Export / 'CSV summary dive details'
from TSV to CSV, to make it consistent with the menu item name, and with
the other 'CSV' export function.
This was changed to TSV by @mturkia in
6c82578540,
but I could not find any discussion as to why.
Also removed replacement of the field separator in any fields, as,
according to the CSV RFC (https://datatracker.ietf.org/doc/html/rfc4180)
this is not required as long as the fields containing separators are
enclosed in quotes, and any quotes within the fields are doubled up.
Tested with a fairly large log file, and importing into Google Sheets is
working fine for the output produced.
Also made capitalisation of the Export menu items consistent.
Signed-off-by: Michael Keller <github@ike.ch>
Fix a bug introduced in 8cd451fc33 causing
an error to be thrown every time trying to do 'Save to cloud storage'.
Signed-off-by: Michael Keller <github@ike.ch>
Add an option for users to sync the dive computer time with the PC time
every time dives are downloaded.
Obviously this will only work on dive computers that have time
synchronisation support in libdivecomputer, for other computers a notice
is logged.
The selection for this option is persisted as a preference.
Signed-off-by: Michael Keller <github@ike.ch>
There was this completely weird loop that the planner-widget would
call the planner-model to get the current rebreather mode, which
would then access the dive in the planner widget. Just keep those
things in the planner widgets.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only user of the DivePlannerPointsModel and the
GasSelectionModel is the planner. Let's keep these models
there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The gas and dive-type models were repopulated in the
diveplanner model. The former are used in the planner.
However, the latter is also used outside of the planner,
when editing non-planned dives. Thus the former shouldn't
be repopulated by the latter, but by the code that needs
it.
Side note: repopulating the dive-type model seems to
make no sense whatsoever since the values never change,
but let's keep it for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To phase out this global variable, avoid access of displayed_dive
in the printing code. This is used when printing a plan. Instead,
when in plan-mode, pass the planned dive to the printing code
as a single dive to be printed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The mode was accessed via the global `displayed_dive`. In an effort
to remove globals, access it via the DivePlannerPointsModel instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The undo-code uses owning pointers based on std::unique_ptr to
manage lifetime of C-objects. Since these are generally useful,
move them from the undo-code to the core-code. In fact, this
eliminates one instance of code duplication.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The current dc global makes no sense on mobile. Therefore,
move the logic of the currently displayed dive computer
to the profile widget and remove the dc_number global
variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Don't access the global current_dc, but pass it to the sensor and
tank-use delegates, when the current dive or dive computer changes.
The same pattern is already realized for the tank and weight models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive-equipment tab has a number of "delegates" for editing
tanks sizes, etc. Instead of allocating them, make them subobjects.
The main point here is that, in an upcoming commit, the sensor
delegate will have to be accessed to change the current dive computer.
So far it didn't have a name and therefore was hard to access.
By making it a subobject it also gets a name.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
An attempt at limitting accesses to the globals current_dive and
dc_number. These globals do not make sense on mobile.
The parent widget of the tab-widgets remembers the currently
displayer dive and dive computer and the individual widgets
access these values from there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make it possible for the individual tab-widgets to access the
parent widget. In principle this could have been done by
downcasting the pointer returned by parent(), but this makes
it explicit.
The goal here is to store information on the selection,
current dive, etc. without repeating it in every subwidget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On selection change, pass down selection (including current
dive and dc) to the tab widgets. Ultimately, this should
remove access to global variables. A number of new accesses
are marked as TODO. They shall be removed in due course.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The signals/slot names for dive selection changes were a mess.
Unify on divesSelected(). Firstly, selectionChanged() is a Qt
thing. Secondly, it is consistent with tripSelected().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was very weird: a setSelection() call was always followed
by a selectionChanged() call, though sometimes in convoluted
ways. Notably, the formed was called by the DiveListView, the
lattern then by the MainWindow.
Let's just merge these two functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In DiveListView user actions (select-all, key-press,
mouse-release) were intercepted to send the selection-changed
signal if the selection changed.
However, with the recent cleanups, this can be done
directly from selectionChanged(), since in all cases (at
least the ones I tested), the part of the function that
is responsible for manual selection changes is called
only once.
This avoids quite some complex code flow.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When manually selecting a trip, the selectionChanged()
virtual function was manually selecting the dives of the
trip and thus ultimately recurse into itself.
So far this seems to work OK, but better to avoid this
recursion by setting the programmaticalSelectionChange
flag.
I'd like to send the selection-changed signal directly
from selectionChanged() and this recursion would lead
to double signals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The trip selection code was an awkward layering violation.
Whereas dive selections due to dive undo-commands trickled
down via DiveTripModel-->MultiFilterSortModel-->DiveListView,
for trip editing, the DiveListView directly intercepted the
TripEdited signal.
Instead, mimic the dive-selection code. This is a bit longer
but more consistent and logical. The undo/redo of trip changes
is now also a "programmatical" change of the selection.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
After sending a selection-change signal, there follows a current
dive changed signal. Combine these two into a single signal, since
usually the current dive is changed when the selection is changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of accessing the global dc_number from the
DivePlannerPointsModel and the CylinderModel, pass them
in the respective initialization functions.
The dc_number global might not make sense on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Each of these calls recalculates the current dive and divecomputer.
Instead, collect the dives to be selected/deselected and (de)select
them at once.
This needs some code refactoring in the core, because we need a
function that
1) doesn't send a signal by itself.
2) doesn't clear the trip-selection.
This contains some reorganization of the selection functions
signatures: The filter code is the only caller that keeps the
selected dive and the only caller that cares about whether the
current dive changed. So let only the function that keeps the
selected dive return whether the current dive changed.
It's all very fragile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This tries to encapsulate the management of the current dive and
divecomputer in the selection code. The current dive is alreay
set by setSelection(). Add a new parameter to also set the
current divecomputer. If -1 is passed, then the current
computer number is remained. This will allow us to audit the code.
Because for now, the whole "current dive computer" thing seems
to be ill-defined.
This fixes a bug: the dive-computer number wasn't validated
when making a new dive the current dive. The new code has some
drawbacks though: when selecting a whole trip, the validation
will be called for all dives in the trip and thus the dive computer
number will depend on the dive with the lowest amount of dive
computers in the trip. This will need to be fixed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Strangely enough, half of the infrastructure was
already there, it just wasn't hooked up to a UI
element
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Fix a bug causing the bluetooth address not being used when downloading
from a 'remembered' dive computer if the device selection is populated.
This specifically excludes MacOS, as 'remembering' bluetooth connections
does not seem to be working there as per
https://github.com/subsurface/subsurface/pull/2158#issuecomment-508933672.
I am not super sure why we are _not_ trying to use the 'remembered'
device if the device selection is populated (`ui.device->currentIndex()
== -1`) - maybe this should be clarified in a comment?
Signed-off-by: Michael Keller <github@ike.ch>
Make the time edit respect the configured time format. Also make the
date and time format change when the preferences are changed.
Fixes#3849.
Signed-off-by: Michael Keller <github@ike.ch>
In order to support development of the open source firmware of the
OSTC4.
Requires changes in libdivecomputer.
Signed-off-by: Michael Keller <github@ike.ch>
Fix a bug causing the wrong units (m) to be shown on the Dive site
management view if imperial units are as the system default.
Signed-off-by: Michael Keller <github@ike.ch>
Disable the 'search dive computer' ([...]]) button in the 'Import from
dive computer' window if searching is not supported by the currently
selected vendor.
Signed-off-by: Michael Keller <github@ike.ch>
Use the drop down for editing the tank use in the gas list in both the
equipment tab and the dive planner.
The tank use column is now available in the equipment tab for all dives
and not just CCR dives, as 'not used' is a valid entry in both cases.
However, if the current dive is an OC dive, only 'OC-gas' and 'not used' are
shown.
There still seems to be a problem that in some cases, when opening the
planner after selecting an existing CCR dive the drop down in the
planner does not list CCR gas uses - for some reason `displayed_dive`
does not seem to be updated correctly on opening of the planner. But I have not been able to
reproduce this consistently, and changing 'Dive mode' fixes this.
Signed-off-by: Michael Keller <github@ike.ch>
Clarified the message that is shown when a newer dive computer firmware
version is available, informing the user that
using an older firmware version may result in problems when using
Subsurface, as discussed in #3568.
This is currently only supported for Heinrichs-Weikamp dive computers.
Signed-off-by: Michael Keller <github@ike.ch>
The Heinrichs Weikamp OSTC4 introduced an additional
'Cave' brightness level that is dimmer than all existing ones.
Signed-off-by: Michael Keller <github@ike.ch>
Users report that the ShiftTimesDialog does not work on Mac and
Windows. Apparently, get_first_selected_dive returns NULL, which
should not be possible because the dialog is only created when
dives are selected. Very omninous.
Get the selected dives in the caller and pass them down. This
bug at least should not happen anylonger. Perhaps now the
dialog does not show at all, but that will narrow down the
root cause of the problem.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This include prevented the statistics from loading for me on Qt6.
And it appears to be unnecessary.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
The changes in commit 4daf687876 ("profile: remove [disable|enable]Shortcuts()
signals") resulted in us no longer enabling the shortcuts on the desktop (at
least on macOS where I debugged this). This placement of the call feels like a
bit of overkill, but at least it shouldn't be wrong.
Fixes#3293
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This variable is not used outside a single function, where it
is reset every time the function runs. This can be realized by
a function-local variable just as well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This occurs upon importing dives for example via CSV.
Make sure the profile display is cleared when selecting
such a dive rather than showing a different dive.
Allow editing the profile for such a dive.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The ADD state is not used for adding dives since adding dives
was made undoable. Therefore, rename it to EDIT state, since
that is what it is used for.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add numerus translation lookup for the right-click context menu in the dive
list to show proper singular/plural text.
Fixes#3256
Signed-off-by: Mark Stiebel <mark@aretha.stiebel.me>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is adding the capability to select 'Dive number' and 'Date / Time'
in the 'Copy dive components' dialog, and then copy them into the
clipboard.
When using 'Paste dive components, these values will then be pasted into
the selected dive(s).
This is intended to help with workflows that import dive information
from two different sources, like general information from another
logging program, and CCR ppO2 sensor readings from a unit log, and then
stitch them together into one cohesive entry with all data per dive.
Copied data is also output into formatted text when pasting the
clipboard outside of the application:
```
Dive number: 401
Date / time: Sun 2 May 2021 12:00 AM
```
No translations have been added as of now - I could not find any
information on how strings are translated for this project.
Signed-off-by: Michael Keller <github@ike.ch>
We are matching translated header names. Thus, when composing
a header line for APD, make sure it contains translations.
This mechanism is quite brittle. Our German translations had
two different translations for "Sample time" and this already
broke it. This is why this patch also includes a fix for a
translation string (should be fixed in transiflex as well
of course).
Fixes#3246
Signed-off-by: Robert C. Helling <helling@atdotde.de>
When printing the plan, a print-dialog was created with "new",
but not freed later. Strictly speaking, this is not a leak,
because the dialog is attached to the main-window in Qt's
object hierarchy. Thus it is freed on application exit. On
the other hand, it is a leak in the sense that resources are
pointlessly hogged until application exit.
Let's just turn it into a stack-allocated object.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The TeX exports may hang the UI for a long time.
Show a progress-dialog that is updated after every exported dive
and allows the user to cancel the export.
This is pretty lame, because it is synchronous (export still runs
in UI thread) and therefore the UI still is sluggish. But it
is an improvement.
Since the TeX-exporting code is in a shared directory (desktop and
mobile), this uses a slim interface class. Mobile does not
yet use TeX export, but you never know. Better than #ifdefs
sprinkled all around, I reckon.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If QString::isEmpty() is false, QString::isNull() is likewise
false, so these tests are redundant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When printing, the animation speed was set to 0 by the
caller and later reset to the original value. Instead of
modifying global state, set it internally (in the profile-code)
to zero when in print mode.
This is another small step in making the printing independent
from the shown profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This flag is handled directly by the profile code
since 2015 (000c9cc21c).
The function therefore can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The backend infrastructure will soon be able to support more than one
cloud server which automagically stay in sync with each other.
One critical requirement for that to work is that once a session was
started with one of the servers, the complete session happens with that
server - we must not switch from server to server while doing a git
transaction. To make sure that's the case, we aren't trying to use DNS
tricks to make this load balancing scheme work, but instead try to
determine at program start which server is the best one to use.
Right now this is super simplistic. Two servers, one in the US, one in
Europe. By default we use the European server (most of our users appear
to be in Europe), but if we can figure out that the client is actually
in the Americas, use the US server. We might improve that heuristic over
time, but as a first attempt it seems not entirely bogus.
The way this is implemented is a simple combination of two free
webservices that together appear to give us a very reliable estimate
which continent the user is located on.
api.ipify.org gives us our external IP address
ip-api.com gives us the continent that IP address is on
If any of this fails or takes too long to respond, we simply ignore it
since either server will work. One oddity is that if we decide to change
servers we only change the settings that are stored on disk, not the
runtime preferences. This goes back to the comment above that we have to
avoid changing servers in mid sync.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We know the preference is never empty, so stop testing for this. But
don't maintain two different preferences with basically the same
content. Instead add the '/git' suffix where needed and keep this all in
one place.
Simplify the extraction of the branch name from the cloud URL.
Also a typo fix and a new comment.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When showing the "empty-state", the profile toolbar was
disabled. This was done via a "reverse" signal from the
profile to the MainWindow. Instead control the toolbar
in the MainWindow directly. Break out the plot-dive
functionality into a member function and there test
whether a dive is shown or not.
The signal makes no sense in the context of mobile
or printing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When switching to the "plan" or "add" (which should rather be
called "edit", by the way) mode of the profile, the "shortcuts"
for copy&paste, undo&redo, etc. are disabled. When switching
to "profile" mode, they are reenabled.
This was done in a most convoluted way:
- The MainWindow calls the set*State() function of the profile.
- The Profile emits [disable|enable]Shortcuts() signals.
- The MainWindow catches these signals and does the enabling
or disabling.
Not only is this very hard to reason about, it is also in
contradiction to the profile being part of the display layer.
Moreover, in editCurrentDive() the MainWindow disabled the
shortcuts itself, so this was all redundant.
For the sake of sanity, let's just move this logic to the
MainWindow, unslotify the [disable|enable]Shortcuts() functions
and make them private.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive handlers are only updated by signals. This means that
switching into edit-mode has to be done in steps:
1) initialize the DivePointsPlannerModel
2) switch profile mode
3) load dive into DivePointsPlannerModel
2) and 3) cannot be exchanged, or the dive handlers are not
initialized.
To avoid this sandwitching of profile- and model-initialization,
populate the dive handlers when switching the profile mode.
Thus, the profile can be switched into edit/plan mode when
the DivePointsPlannerModel is fully initialized.
This will be important in upcoming commits, when the initialization
of the dive is moved from the profile to the DivePointsPlannerModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only external user of setRecalc() was turning recalculation
on. In fact, this happened when constructing the planner-widget.
However, for example editing of the profile only works when
the recalc flag is on.
This is all very confusing, let's just turn the flag on by
default and remove the accessor. Internally, the planner can
simply use the std::exchange function to set and reset the
recalc flag.
Perhaps the setting/resetting can be replaced by simple
recalc = true;
...
recalc = false;
pairs. It is unclear whether there is need for recursion.
Something to be investigated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
MainTab::updateDiveInfo() is not executed when in the planner.
To decide whether the application is in the planner state,
it queried the profile. Instead, query the DivePlannerPointsModel.
Currently, there is no autoritative carrier of that flag.
However, the MainTab has a dependency on DivePlannerPointsModel
anyway, and therefore this removes a dependency on the
profile. This brings us closer to a state where we can have
multiple profiles.
Ultimately, it is hoped that the whole check can be removed
at this place, making the point moot.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove mainwindow-access from the planner, by setting
the profile to planner state in the owner of the profile,
viz. the MainWindow.
The MainWindow sets the application state to planner, so
it seems legit that it also sets the profile state.
This removes a further interdependency.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The accept / reject message is only shown in edit-mode, no
need to check it. This is a step in simplification / removal
of the edit mode.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
So far the profile operated on the global displayed_dive. Instead,
take the dive to be displayed as a parameter to the plotDive()
functions.
This is necessary if we want to have multiple concurrent
profile objects. Think for example for printing or for mobile
where multiple dive objects are active at the same time.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To remove global state, make the dive that DivePlannerModel
works on a member variable. Pass the dive in createSimpleDive()
and loadFromDive(). Moreover, this should pave the way to more
fine-grained undo in the planner. Ultimately, the planner
should not be modal.
Attention: for now, the dive must still be displayed_dive,
because of the convoluted way in which the profile and the
planner work on the same dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Both loadFromDive() callers were clearing the model before
calling loadFromDive(). Move the clearing into that function
since it makes no sense to load into a non-cleared model.
Apparently this changes the way that no-cylinder dives are
treated and the code in ProfileWidget2::repositionDiveHandlers()
must now explicitly check for that condition.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This model is only needed when in plan mode. To enable multiple
profilewidgets at the same time (e.g. for the mobile app or
for printing), make the pointer to DivePlannerPointsModel a
member variable that is initialized at construction time.
Moreover, allow passing null as the DivePlannerPointsModel,
in which case planning will be disabled. This will be useful
for simple printing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When clicking on "+" in the planner, a default stop point was
added using a signal/slot connection. This used the archaic
string-based connect syntax, because it was realized with
default parameters passed to "addStop()". Instead, add a
"addDefaultStop()" slot, which passes the default parameters.
Since all other callers do not use callbacks, unslotify
"addStop()". The slot was the only user of the default parameters,
so they can be removed alltogether.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The font-size in printed profiles is based on the size of the profile
in the main window. This makes no sense. Why should changing the
window size change the font-size on printouts?
Matter of fact, when making shrinking the height of the window to
its minimum, comical printouts are obtained (font way too big).
Therefore use an arbitrary rule: Say that profiles 600 pixels high
look reasonable and then scale up to the actual size on the printout.
This may need some tweaking for high-DPI mode. But that seems not
to be supported on desktop anyway?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Apparently, the visibility flag of the view is not inherited
from the statistics widget. Therefore, the statistics is
redrawn on every action even if not visible.
Set the visibility explicitly in the show- and hide-events.
This is crazy.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>