Commit graph

2077 commits

Author SHA1 Message Date
stevebuie
8f4f8fe489 Fix crash on mac os during download from new BLE computer
Ensure that any bluetooth scan started (by changing the device name) in the
download-from-dive-computer dialog (desktop version) is stopped before the
download process is started up. Because the QT bluetooth discovery agent uses
a QTimer internally, it must be stopped from the same thread as it was started
from. The download process uses a different thread, so ends up crashing when
it tries to dispose of the timer from a different thread.

Reported-by: Steve Buie <sbuie321@gmail.com>
Signed-off-by: Steve Buie <sbuie321@gmail.com>
2024-06-28 14:51:07 +12:00
Michael Keller
b126fccb1b Desktop: Fix Inconsistencies in Handling of Salinity.
- add correct setting of the water type drop down for the dive shown
  initially after program start;
- change salinity to have 3 decimals in planner, to make it consistency
  with the log.

Fixes #4240.

Reported-by: @ccsieh
Signed-off-by: Michael Keller <github@ike.ch>
2024-06-10 15:54:22 +12:00
Michael Keller
10fc3bfd47 Bugfix: Fix Incorrect Volumes Displayed for Tank Types.
Fix an issue introduced in #4148.
Essentially the refactoring missed the fact that in the imperial system
tank size is tracked as the free gas volume, but in the metric system
(which is the one used in most of Subsurface's calculations) tank size
is tracked as water capacity.
So when updating a tank template tracking imperial measurements, the
given (metric) volume in l has to be multiplied by the working pressure,
and vice versa.
This also combines all the logic dealing with `tank_info` data in one
place, hopefully making it less likely that this will be broken by
inconsistencies in the future.

Fixes #4239.

Signed-off-by: Michael Keller <github@ike.ch>
2024-06-09 11:15:59 +02:00
Michael Keller
adaa52bf9b Desktop: Fix Undo for Gaschanges on Manually Added Dives.
Fix the undo functionality for gaschanges edited on manually added
dives.

Pointed-out-by: @bstoeger
Signed-off-by: Michael Keller <github@ike.ch>
2024-06-02 11:38:21 +02:00
Michael Keller
f65afaf5d2 Desktop: Fix Gas Editing for Manually Added Dives.
- show the correct gasmix in the profile;
- make gases available for gas switches in the profile after they have
  been added;
- persist gas changes;
- add air as a default gas when adding a dive.

This still has problems when undoing a gas switch - instead of
completely removing the gas switch it is just moved to the next point in the
profile.

Signed-off-by: Michael Keller <github@ike.ch>
2024-06-01 23:22:40 +12:00
Michael Keller
1aa5438b2d Cleanup: Improve the Use of 'Planned dive' and 'Manually added dive'.
- standardise the naming;
- use it consistently;
- apply the 'samples < 50' only when putting manually added dives into
  edit mode - everywhere else manually added dives should be treated as
  such;
- do not show a warning before editing a manually added dive in planner.

Signed-off-by: Michael Keller <github@ike.ch>
2024-05-25 20:13:45 +02:00
=Michael Keller
c3d807802d Desktop: Fix Finding Reported by Coverity.
Signed-off-by: Michael Keller <github@ike.ch>
2024-05-18 14:07:15 +02:00
Michael Keller
a66bdb1bf5 Planner: Improve Exit Warning.
Improve the warning shown to the user when closing the application wile
in the planner. We now allow the user to directly discard the planned
dive, save it into the dive log, or cancel the operation altogether.
If they save into the dive log, or if they modified the dive log before
starting the planner, a second warning about the unsaved dive log
changes will be shown.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-05-17 16:44:04 +12:00
Berthold Stoeger
8769b1232e planner: initialize currCombo.ignoreSelection
I am not sure what this does, but it should be initialized before
it is tested.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-12 13:23:21 +02:00
Berthold Stoeger
d061a54e3d planner: fix gas selection
The lambda that created the list of gases took a copy not a
reference of the planned dive. Of course, that never had its
gases updated. Ultimately this would crash, because this sent
an index of "-1" on change.

Fix by
1) Using a reference to the dive, not the copy
2) Catch an invalid "-1" index (by Michael Keller <github@ike.ch>)

Fixes #4188

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-05-12 13:23:21 +02:00
Michael Keller
f4e61aa5dc Import: Make Directory Selectable when Importing .fit Files.
In the 'Download from dive computer' dialogue, make it possible to
select the source directory for the import.

Signed-off-by: Michael Keller <github@ike.ch>
2024-05-11 12:52:05 +12:00
Michael Keller
528532572f Planner: Fix Editing of Plans in Multi-Divecomputer Dives.
Currently editing of planned dives that have been merged with actual
(logged) dives only works if the 'Planned dive' divecomputer is the
first divecomputer, and this divecomputer is selected when clicking
'Edit planned dive'. In other cases the profile of the first
divecomputer is overlaid with the profile of the planned dive, and the
first divecomputer's profile is overwritten when saving the dive plan.
Fix this problem.

Triggered by @SeppoTakalo's comment (https://github.com/subsurface/subsurface/issues/1913#issuecomment-2075562119): Users don't like that planned dives show up as their own entries in the dive list, so being able to merge them with the actual dive after it has been executed is a good feature - but this wasn't working well until now.

Signed-off-by: Michael Keller <github@ike.ch>
2024-05-11 12:51:45 +12:00
=Michael Keller
8627f6fc4a Desktop: Add Auto-sizing to the Extra Info Table.
Add auto-sizing to the extra info table - resize the columns so that all
rows are shown in full whenever the data is updated.

Signed-off-by: Michael Keller <github@ike.ch>
2024-05-08 08:26:56 -07:00
jme
e09a134a3f Delete desktop-widgets/preferences/preferences_dc.ui
Remove preferences "Dive Download" window.    Delete all dive computers no longer needed now that they can be deleted on the import window.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-26 08:14:16 +12:00
jme
aecb4f5005 Delete desktop-widgets/preferences/preferences_dc.h
Remove preferences "Dive Download" window.    Delete all dive computers no longer needed now that they can be deleted on the import window.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-26 08:14:16 +12:00
jme
358b9186bf Delete desktop-widgets/preferences/preferences_dc.cpp
Remove preferences "Dive Download" window.    Delete all dive computers no longer needed now that they can be deleted on the import window.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-26 08:14:16 +12:00
jme
12ae3d4e96 Update preferencesdialog.cpp
Remove preferences "Dive Download" window.    Delete all dive computers no longer needed now that they can be dleted on the import window.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-26 08:14:16 +12:00
jme
34926f1325 Update CMakeLists.txt
Remove preferences "Dive Download" window.    Delete all dive computers no longer needed now that they can be dleted on the import window.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-26 08:14:16 +12:00
Berthold Stoeger
556ecd5a9b core: use C++-primitives for g_tag_list
The old code was leaking memory. Use std::unique_ptr<> for
ownership management.

This is still very primitive and divetags are kept during
application lifetime. There should probably be some form
of reference counting. And the taglist should not be global,
but attached to the divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b320942343 Replace remaining qDebug()s by report_info()
The only case left is in android.cpp, though that is only compiled
when compiling the full desktop app on Android. I.e. never. So
don't bother for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
9febfdd084 Remove diabled debugging output in subsurfacewebservices.cpp
Why bother with commented out code?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
4af2ec88bd Use std::vector<string> instead of QStringList in main()
In an effort to convert core to C++ structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
c6cd10a43f core: make getCloudURL() return an std::string
Let's use std::string in the core. Notably, I'd like to make
the numerous main() functions mostly independent of Qt. Some
things will have to remain, such as argument parsing, of course.

This changes the API: instead of returning an error code and
taking a pointer to the actual return-value, return an
std::optional<std::string>> that is set if the function succeeds.

Returning an empty string in the error case might be simpler,
but oh well...

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
da7ea17b66 cleanup: replace fprintf to stderr by report_info()
Let's try to unify debugging output!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
4db19d6284 planner: use std::string in plannernotes.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
jme
bd31efa821 Update downloadfromdivecomputer.cpp
Remove lines setting "current" computer to computer1.  

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
80eff1d6e2 Update downloadfromdivecomputer.ui
Per suggestion, use QFrame and trashcan icon.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
74b1648fcc Update downloadfromdivecomputer.h
Change DDC<n> to DeleteDC<n>

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
7fb0e9e59e Update downloadfromdivecomputer.cpp
Changed DDC<n> to DeleteDC<n> and hide set visibility for new Qframe

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
d59bd1831a Update downloadfromdivecomputer.cpp
Added delete dive computer buttons.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
f05808fded Update downloadfromdivecomputer.h
Added delete dive computer buttons.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
jme
1692e48163 Update downloadfromdivecomputer.ui
Added delete dive computer buttons.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-22 16:52:19 +12:00
Michael Keller
375b08857c Desktop: Remove Unneeded Special Case for MacOS.
Since the removal of this special case for MacOS was confirmed to be
working in the case of building with bluetooth support in #4120, we should
probably remove it from the code used when building without bluetooth
support as well.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-04-21 13:13:18 +12:00
jme
77281f8bfe Update downloadfromdivecomputer.cpp
If Bluetooth isn't enabled, don't clear non Bluetooth address.    There was an earlier concern that USB mount point shouldn't be preserved because they may change.   This behavior is different on a Mac where the USB serial mount points tend to be persistent.   Michael tested this on Linux and suggested on saving the mount points for Linux and Windows.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
6b11457ddd Update downloadfromdivecomputer.cpp
Based on Michael's suggestion, added code to refine enableBluetoothMode. 

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
8a20509861 Update downloadfromdivecomputer.cpp
Removed blank lines - forgot that blank lines without a continuation \ would break the macro.    Embarrassing to say the least.   I need to figure out how to upload tested code into git.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
334a357c19 Update downloadfromdivecomputer.cpp
Removed the MacOs specific code and added comment explaining why ui.device.Text must be set before the ui.bluetoothMode change handler runs.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
1973d7c881 Update downloadfromdivecomputer.cpp
Preserve bluetooth address if we have it (don't rescan) and for MacOS save the mount point if we have it.     As best as I can tell, the mount points for USB devices do not change on MacOs regardless of the USB port being used.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
a5575f43a3 Update downloadfromdivecomputer.cpp
Per Michael's suggestion, use isBluetoothAddress as check before skipping Bluetooth scan. 

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
ffce4bc097 Update downloadfromdivecomputer.cpp
another space that should have been a tab.

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
5980db073a Update downloadfromdivecomputer.cpp
Replaces spaces with tabs and corrected misplaced braces (embarassing...).

Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
jme
4dcc9210a9 Avoid unnecessary bluetooth device address scanning.
When switching from a non-bluetooth computer to a bluetooh computer an unnecessary bluetooth scan may be forced.   This patch will avoid the scan if the bluetooth device address is known.



Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
2024-04-17 10:03:32 +12:00
Berthold Stoeger
0d011231e6 desktop: unglobalize ComboBox-models
The combo-boxes (cylinder type, weightsystem, etc.) were controlled
by global models. Keeping these models up-to-date was very combersome
and buggy.

Create a new model everytime a combobox is opened. Ultimately it
might even be better to create a copy of the strings and switch
to simple QStringListModel. Set data in the core directly and
don't do this via the models.

The result is much simpler and easier to handle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-16 08:56:49 +12:00
Berthold Stoeger
2c490fcbbb desktop: take an std::string in MainWindow::setCurrentFile()
This fixes a crash condition when opening the cloud from
desktop: The old code passed a NULL pointer that was then
assigned to an std::string, which is not supported.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-25 06:45:36 +01:00
Berthold Stoeger
5ac64ab2cd cleanup: replace Q_FOREACH and foreach by range base for
Q_FOREACH and foreach are anachronisms.

Range based for may cause a performance regression: it can
lead to a copy of shared containers (one reason why Qt's
COW containers are broken). However, as long as there is no
user noticeable delay, there is no point in analyzing each case.
And also no point in slapping an 'asConst' on every container
that is looped over.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
41cb916060 core: turn existing_filename into std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
37f2207f94 printing: pass current filename to dialog
Instead of accessing a global variable, pass the filename
from the MainWindow to the dialog. This is supposed to cut
down on the global variable mess.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
3a1122048b core: make logfile_name and dumpfile_name std::string
To avoid memory management woes. These shouldn't be global
variables, but let's fix that later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
64419f2b19 dive download: pass current filename to dialog
Instead of accessing a global variable, pass the filename
from the MainWindow to the dialog. This is supposed to cut
down on the global variable mess.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00
Berthold Stoeger
981352646c computer configuration: pass current filename to dialog
Instead of accessing a global variable, pass the filename
from the MainWindow to the dialog. This is supposed to cut
down on the global variable mess.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-24 17:53:19 +01:00