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>
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>
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>
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>
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>
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>
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>
Per Michael's suggestion, use isBluetoothAddress as check before skipping Bluetooth scan.
Signed-off-by: jme <32236882+notrege@users.noreply.github.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
There is no subclass of ConfigureDiveComputerDialog, so there
seems no reason for protected members.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a build for subsurface-downloader to the CI pipeline. The artifact
is currently not used, but this will ensure pull requests breaking the
downloader are spotted before they are merged.
Signed-off-by: Michael Keller <mikeller@042.ch>
Downloder builds pull in show_computer_list() from
downloadfromdcthread.cpp, but it's declared as extern "C". With 76c2069f
having converted subsurfacestartup.c to .cpp, we can remove the extern
"C"
Signed-off-by: Richard Fuchs <dfx@dfx.at>
Add 'Country' to the fields that are indexed for fulltext search - this
seems to be a quite intuitive choice as 'Country' is also a field that
is available in the dive list view.
Fixes#4134.
Signed-off-by: Michael Keller <mikeller@042.ch>