Commit graph

2010 commits

Author SHA1 Message Date
Robert C. Helling
81f35c1ecf Properly handle the planner state
This does two independent things:

It sets the planner state early enough so the appropriate
default profile for the planner is created (without
safety stop).

Upon cancelling the planner, it resets the profile widget
to profile more (rather than planner) as otherwise upon
the next change into the planner the planner model is
not properly initialized.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2023-09-12 06:48:33 +02:00
Michael Keller
5fae7ce7a0 Equipment: Include Unused Tanks in Merge if Preference is Enabled.
Include unused tanks in merges of multiple logs into a single dive if
the 'Show unused cylinders' preference is enabled.
Also rename the preference (in code) to `include_unused_tanks` to
reflect the fact that it is already used in more places than just the
display (exporting, cloning dives).
Simplified the cylinder model to make forced inclusion of unused tanks
dependent on use of the model in planner.
Leaving the persisted name of the preference as `display_unused_tanks`
to avoid resetting this for all users - is there a good way to migrate
preference names?

Signed-off-by: Michael Keller <github@ike.ch>
2023-07-25 11:19:03 +12:00
Rafael M. Salvioni
8f8f901aa8 Check "hasDCSalinity" is null in updateWaterTypeWidget()
Signed-off-by: Rafael M. Salvioni <rafael.salvioni@gmail.com>
2023-07-14 19:47:34 +12:00
Michael Keller
5511cd13d7 Add forcedFirmwareUpgradeSupported to supportedDivecomputers.
Signed-off-by: Michael Keller <github@ike.ch>
2023-07-11 07:30:49 -07:00
Michael Keller
4ac27e3c71 Desktop: Load the Dive Computer List in 'Configure Dive Computer' Dynamically.
Load the dive computer list in the 'Change Settings on Dive Computer'
dialog dynamically.
Also incorporate suggestions from
https://github.com/subsurface/subsurface/pull/3925#issuecomment-1595784076.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Michael Keller <github@ike.ch>
2023-07-11 07:30:49 -07:00
Rafael M. Salvioni
1e082affdd Fix salinity combo/icon when DC doesnt have salinity info
Today salinity combo is editable if one of these rules matches: The dive was manually entered or if salinity edition is allowed in preferences.
However we can have cases that dives were downloaded but its doesn't have salinity info.

This fix considers if there's a DC salinity info to decides combo edition and if salinity change indicator will be showed or not.
If DC doesn't have salinity, the UI behavior is the same of a manual dive

Signed-off-by: Rafael M. Salvioni <rafael.salvioni@gmail.com>
2023-07-09 20:36:46 +12:00
Michael Keller
ce67c8b902 Desktop: Add a Button to Hide the Infobox in the Dive Profile.
Add a button that allows the user to hide the infobox with statistics
about the point in the dive under the mouse cursor in order to be able
to see the full dive profile unobstructed.

Signed-off-by: Michael Keller <github@ike.ch>
2023-06-25 14:40:23 +02:00
Michael Keller
b5007bde67 Desktop: Regroup File Menu Entries.
Regroup the file menu entries to give the dynamically generated
'recently opened files' their own section.

Signed-off-by: Michael Keller <github@ike.ch>
2023-06-17 20:19:35 +02:00
Michael Keller
bceb367dc3 Cleanup: Use Correct Naming for Private Members.
Rename inconsistently named private members introduced in #3923.

Signed-off-by: Michael Keller <github@ike.ch>
2023-06-17 17:18:35 +02:00
Michael Keller
700bba7e30 Desktop: Use Persisted Device Information for Dive Computer Configuration.
Use the dive computer / device information that was persisted when
previously downloading dives or configuring the dive computer in the
dive computer configuration dialog.
Also rename 'Connect with bluetooth' and 'Cancel' buttons in the dialog
to make them more consistent with what they do.

Signed-off-by: Michael Keller <github@ike.ch>
2023-06-12 12:40:44 -07:00
Michael Keller
5d7f294407 Desktop: Rework Setting of Custom Date / Time Formats.
Rework the setting of custom date / time format preferences:
- fix bug causing case changes if custom format case insensitively
  matches a drop down entry;
- fix invalid format examples in tooltip;
- update URL for the format documentation;
- add support for quoted literals to the format validity warning.
From discussion in
https://github.com/subsurface/subsurface/issues/3849#issuecomment-1481239270.

Signed-off-by: Michael Keller <github@ike.ch>
2023-05-30 11:24:37 +02:00
Michael Keller
2aa13ea9d7 Desktop: Add mergeing into the selected dive site.
When editing a dive site in the 'Dive sites' view, add a context menu
entry to allow mergeing of the displayed dive site into the dive site
seleted in the 'Near dive sites' list.
This merge has the opposite direction of the existing 'Merge into
current site' function, which can simplify the workflow when maintaining
a large number of dive sites, as the facilities to sort dive sites in
the 'Dive sites' view does not have a way to sort by location or
proximity.

Signed-off-by: Michael Keller <github@ike.ch>
2023-05-20 07:24:39 +02:00
Michael Keller
1bd7806dcf Desktop: Change 'CSV summary dive details' output from TSV to CSV.
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>
2023-05-18 10:31:31 +03:00
Michael Keller
e60baff940 Desktop: Fix bug when synching to the cloud
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>
2023-04-21 15:18:49 +02:00
Michael Keller
a38ea971a0 Import: Add option to sync time on dive computer download
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>
2023-04-17 07:56:02 -07:00
Berthold Stoeger
cb410fe1ba cleanup: don't define empty inline constructor
Just use the constructor of the parent class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
e70e3082c9 planner: remove getRebreatherMode() from planner-model
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
1fb9d6236b planner: initialize dive selection mode in constructor
There is no point in repopulating this regularly, as the
content does not change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
4c02d1c279 planner: get rid of global displayed_dive variable
Allocate the dive in the planner. This is all a bit convoluted
and needs more cleanup.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
b5682369f8 planner: remove global model instances
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
3dd09b31e3 planner: move repopulation of models to planner
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
d51589b9a7 printing: don't access displayed_dive in printing code
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
80df790efc desktop: remove EditPlannedDive application state
The last user of that state was removed in 9bbd8b8169.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
d65f2f422c planner: access divemode (a.k.a. rebreathermode) from model
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
c5d6e0f44f core: make owning pointers a top-level features
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
cad80e5a53 selection: move current dc logic to profile widget
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
19baae449d tab-widgets: pass current dive computer to delegates
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
32de8a1387 tab-widgets: make delegates subobject
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
6f03fc9689 selection: remove current_dive and dc_number access from tabwidgets
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
8cd191c271 desktop: store pointer to parent in tab-widgets
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
cded7ef5fe selection: pass down selection to tab widgets
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
908da77863 selection: rename selectionChanged() to divesSelected()
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
de2c4d93e0 map: fold selectionChanged() into setSelection()
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
72a15c46d9 selection: move dive selection, current dive and dc through signals
To reduce access of global variables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
616dbd9671 selection: send selection signal from selectionChanged()
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
018be753c3 selection: avoid recursion in divelist selection code
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
8581e213ed selection: trickle down trip selection
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
9ccb940a1b list models: include current dive in selection signal
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
832398180c planner: remove dc_number access from models
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
d057af43b4 undo: pass divecomputer number to EditProfile command
Don't access the global variable dc_number, which might
not make sense on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
487974ea91 selection: avoid select_dive() and deselect_dive calls in dive list
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
9f455b1457 selection: move current dive and divecomputer to selection.cpp
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>
2023-04-16 20:23:59 +02:00
Berthold Stoeger
b56b7abcf5 core: use divelog struct in downloader code
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
b61732da42 core: remove autogroup global
Use the flag in the divelog structure, since this will be saved
in the dive log.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
8cd451fc33 core: use divelog in importDives() and process_imported_dives()
Instead of a long argument list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-14 21:20:23 +02:00
Berthold Stoeger
9c253ee6c5 core: introduce divelog structure
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>
2023-04-14 21:20:23 +02:00
Dirk Hohndel
ad8aa988f0 Merge branch 'add_ostc4_force_firmware_update' of https://github.com/mikeller/subsurface
together with the libdc change this should now work

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2023-03-29 10:36:29 -07:00
Robert C. Helling
e27653374d Add printing option for page orientation
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>
2023-03-28 21:08:37 -07:00
Michael Keller
9da7ec4828 Desktop: Fix use of bluetooth address for remembered dive computer.
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>
2023-03-28 20:51:07 -07:00
Michael Keller
468c1d8d61 Desktop: Fix time format in dive planner.
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>
2023-03-28 20:37:21 -07:00