Commit graph

19940 commits

Author SHA1 Message Date
Berthold Stoeger
157b52aa6e tests: make git-storage test more robust
The code was crashing if it couldn't reach the cloud, because then
info.repo is NULL. Skip the test if that happens.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
322c3b55e6 core: add compile time format check to format_string_std
Had to rewrite the thing, because gcc's warnings don't work
with templatized var-args. Since there is no string-format.cpp
and I didn't want to inline it, moved it to format.cpp.

String formatting is distributed around at least four
headers: membuffer.h, subsurface-string.h, format.h
and format-string.h. This really should be unified!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
a123589efb core: convert git_info to std::string
Quite a bit of fallout in users of this structure.

Conveniently, since git-access.cpp is now C++ we can move
some helpers from the monstrous qthelper.cpp to git-access.cpp.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
ae299d5e66 profile: use C++ string functions to format plot data
This may appear a bit ominous, as it doesn't generate a string,
but a vector of strings (one for each line). However, that is
in preparation for the QtQuickification of the profile, where
the text-items take such a list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
422f693f5b core: port tag.c to C++
Let taglist_get_tagstring() return an std::string, since all callers
are C++ anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
84b7ffafd2 core: use C++ versions of membuffer in add_to_string
Avoid explicit calls to free().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
e65ba50c1a core: use C++ constructs in save-html.cpp
Since this is the only caller, onvert the get_file_name() function
to return an std::string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
82ba236859 core: port save-html.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
177b03958c core: port worldmap-save.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
bd3f9b107e planner: turn TIMESTEP macro into integer constant
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
15b17a0aca planner: turn error argument of add_plan_to_notes() into a boolean flag
This used to have multiple values, but is currently only checked for
true/false. Reflect that in the type.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
b542a39a00 planner: turn UNIT_FACTOR macro into function
No apparent reason why this is a hard-to-read macro.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
9a052cd089 planner: move decotimestap to diveplannermodel.cpp
The deco timestep is a parameter to the plan() function. There
seems no need to define this as a global macro. Probably some
code reshuffeling artifact.

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
Berthold Stoeger
8b51ff7ded core: add locale aware formatting function to std::string
We had locale aware formatting functions that generated QStrings.
Create an alternative that creates std::string, since we want that
in the core.

This commit is unfortunate for two reasons:
- The function is called "casprintf()" for analogy with the QString
  version. However, the non locale aware function is called
  "format_string_std()" for analogy with "format_string()".
  Ultimately these names should be unified. Probably, once there
  are no membuffer users left.
- This does UTF-16->UTF-8->UTF-16 roundtrips. The core formatting
  functions should render UTF-8 and only convert to UTF-16, in
  the UI layer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
fe68870079 planner: use std::vector instead of malloc() in planner.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
f69686d429 planner: encapsulate deco state cache in a struct
Removes memory management pain: the struct cleans up when it
goes out of scope.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-23 07:47:11 +07:00
Berthold Stoeger
77e8c3655e core: compile planner source files with C++
Another relatively easily converted part of the code.

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
Michael Keller
d49092ac70 CICD: Add Script to Find the Changeset ID for a CICD Release Number.
Add a script that finds the changeset ID in the subsurface repository
that a given CICD release was built from.
The option '-c' can be used to check out the changeset, if one is found.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-04-20 10:46:28 +07:00
Michael Keller
ee8b37cc6e Import: Fix Info Logging.
Avoid logging the expected outcome (success) at info level.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-04-19 15:31:34 +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
f4b35f67f6 Don't "untranslate" cylinder names
As far as I can see there are no translation strings for the
cylinder names, so there is no point in translating them back.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-16 08:56:49 +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
de313bd01a mobile: save changes from main event loop
When autosync to cloud was enabled, the old code would crash,
because it synced to cloud from a signal handler, which executed
the main loop when checking the cloud connection, which deleted
the object which was causing the original signal. Or something
like that. See discussion in #4119.

To avoid such problems, send a signal via a 'QueuedConnection'
from QMLManager to itself. The slot will be called once the
signal handler terminates and the main event loop retakes
control.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
2172e18298 mobile: pull undo/redo notification text up
When changes need saving, the notification text was set quite
deep in the calltree in "saveChangesLocal()". I don't know why
this was put so deep in the call tree. In any case, it prevents
asynchronous saving of the data. Therefore, pull it up to
chnagesNeedSaving().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-04 13:57:00 +02:00
Berthold Stoeger
dd466d2d48 statistics: improve formatting of date axis in day-mode
In January it would just show the year for every day. That's
silly. Show the year only for Jan 1st.

Moreover, it would never show the month, because day-of-month
is counted from 1 (whereas month-of-year is counted from 0).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-31 14:20:14 +02:00
Berthold Stoeger
916c88ded9 mobile: fix undo/redo
The signals of the undo-stack can only be connected after it
was initialized. One of those cases where I would have preferred
a crash over a warning message. The mobile version is extremely
noisy!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-31 14:19:44 +02:00
Berthold Stoeger
83fa38b3b4 cleanup: remove unused function parse_display_units()
This was added in d9b39efeb7,
but never used as far as I can see...

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-26 17:00:38 +01:00
Berthold Stoeger
2bf7432a94 cleanup: remove unused macros in qmlmanager.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-25 21:41:57 +01:00
Berthold Stoeger
c53cdf039b cleanup: remove unused global variable filesOnCommandLine
Last user was removed in 0a92823af6.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-25 07:09:05 -07:00
Berthold Stoeger
29d71eb85e cleanup: remove picturedir_string()
This seems to be dead code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-25 06:49:35 +01: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
Michael Keller
6aca76c342 Import / Export: Remove Unsafe XML Handling Options.
Remove the options to expand entities and so continue when encountering invalid /
malformed XML, as both of these can be exploited by supplying
maliciously crafted XML.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-03-24 19:01:05 +01:00
Berthold Stoeger
92c3837f6e cleanup: remove unused taglist functions
No users of taglist_added() and taglist_contains().

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