Commit graph

18248 commits

Author SHA1 Message Date
Berthold Stoeger
c4bfecce1b core: add C struct device and struct device_table accessors
Up to now, "struct device" and "struct device_table" were C++
only, because they used C++ strings for convenience. Since we
switched from QString to std::string, we can create accessors
for these structs. For the C code, we simply declare them as
opaque structs and give the full definition only for C++.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16 14:26:37 -07:00
Berthold Stoeger
4a50badb57 cleanup: use std::vector in struct device_table
Since we converted from QString to std::string, let's also use
std::vector instead of QVector. We don't need COW semantics
and all the rigmarole. Let's try to keep Qt data structures
out of the core.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16 14:26:37 -07:00
Berthold Stoeger
fd8bd9d5c7 cleanup: use std::string in struct device
struct device is a core data structure and therefore shouldn't use QString.
QString stores as UTF-16 (which is a very questionable choice in itself).
However, the real problem is that this puts us in lifetime-management
hell when interfacing with C code: The UTF-16 has to be converted to
UTF-8, but when returning such a string, this puts burden on the caller
who has to free it. In fact, instead of looping over devices from C-code
we had a callback that sent down temporary C-strings with qPrintable.

In contrast, std::string is guaranteed to store its data as
contiguous null-terminated and C-compatible strings. Therefore,
replace the QString by std::string. Keep the QString just in
one place that formats a hexadecimal number to avoid any
potential change.

The disadvantage of using std::string is that it will crash
when constructed with a NULL argument, consistent with C-style
functions such as strcmp, etc. Arguably, NULL is different
from the empty string even though we treat both as the same.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16 14:26:37 -07:00
Berthold Stoeger
4e479677a0 cleanup: fix tiny memory hole in device.cpp
empty_string() returns true for "". Thus, we can't simply overwrite
the pointer if empyt_string() returns true, but must free the string
regardless. The joys of C memory management!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16 14:26:37 -07:00
Dirk Hohndel
485ac4b58f build-system/macOS: remove Qt SQL plugins and suppress some errors
Technically with this the app might be ready for AppStore inclusion. I don't see myself
spending the energy on that, TBH.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16 14:19:59 -07:00
Miika Turkia
1a646a2e5c Duration is in seconds
The dive duration is given in seconds in the Shearwater cloud database.
(At least nowadays.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-10-16 14:15:50 -07:00
Dirk Hohndel
0aaa654433 build-system: switch to current libhidapi
A few years ago the upstream for libhidapi changed - it became part of the
libusb GitHub org. Switching to the latest version appears to fix some odd
problems with talking to the Suunto Eon Steele/Core dive computers on macOS (at
least I can no longer reproduce the problem after switching to the current
version).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16 14:14:50 -07:00
Dirk Hohndel
967473a1cd build-system: add GitHub scanning
Enable the newly re-imagined Semmel based CodeQL scanning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16 14:14:05 -07:00
Berthold Stoeger
23dc56e9cc parser: fix parsing of DAN files
The last two parameters of the parse_dan_format() function were
mixed up: sites should come before filter_presets.

This should have caused crashes, for DAN files with dive sites.
I don't understand why this didn't cause compiler warnings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16 13:57:00 -07:00
Berthold Stoeger
2e5913d2ba core: fix detection of duplicate device names
Recently (c9b8584bd2) the sort criteria of the device-table
was changed from  (model/id) to (id/model). However, that
messed with the detection of duplicate device names: there,
the code searched for the first element greater or equal
to (model / 0).

With the reversal of the sort criteria, this would now
always give the first element.

Therefore, do a simple non-binary search, which is much
more robust. The binary search was a silly and pointless
premature optimization anyway - don't do such things
if not necessary!

Since only one place in the code search for existence
for a model-name, fold the corresponding function into
that place.

Moreover, change the code to do a case-insensitive compare.
This is consistent with the dc_match_serial() code in
core/libdivecomputer.c, where matching models is
case-insensitive!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-13 16:26:42 -07:00
Berthold Stoeger
ff6c1a34ad cleanup: remove unused function is_default_dive_computer()
The last actual user was apparently removed back in 2013(!):
34db6dc2be

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-13 20:15:41 +02:00
Dirk Hohndel
39ab754406 Update translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-13 09:15:13 -07:00
Dirk Hohndel
19eb63d6ef documentation: update build instructions for various Debian/Ubuntu flavors
This was missing the Qt Quick Controls.2 needed for the mobile on desktop build
and all the modules for actually running subsurface-mobile.

Also, there was a white space inconsistency that I fixed while I was at it.
And an outdated reference to ancient Fedora changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-11 14:06:22 -07:00
Robert C. Helling
48adaf5297 Set the NO_PRINTING variable properly
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-10-11 08:40:38 -07:00
Berthold Stoeger
c9b8584bd2 core: sort device-table by id/model instead of model/id
The device table is accessed by core via a callback using
call_for_each_dc(). This sorts the table by device-id. It
is unclear whether this is needed - since currently all it
does is make sure that the devices have a fixed order in XML
and git log files.

In any case, this means that the table had to be copied and
sorted in call_for_each_dc(). Since the frontend now does
its own sorting, we can just keep the core table sorted
as it needs it. This in turn will ultimately make it possible
to replace the callback by a simple loop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-11 08:35:20 -07:00
Berthold Stoeger
215e5a4544 desktop: make divecomputer table sortable
Add a small proxy-model on top of DiveComputerModel so that clicking
on table headers makes the table sortable.

The UI feature here is not as important as the fact that the UI does
its own sorting and we can keep the device-table in the core sorted
differently.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-11 08:35:20 -07:00
Lubomir I. Ivanov
5931be4c88 CHANGELOG.md: add note about fixing missing Vista theme
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2020-10-09 07:31:54 -07:00
Lubomir I. Ivanov
2006513169 packaging/windows: add the /styles folder
For Windows, the Subsurface installers do not include
the file "qwindowsvistastyle.dll" required to make the
applications that are published to have a native look.

Modify the MXE *build.sh scripts to include the
file as "plugins/styles/qwindowsvistastyle.dll".

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2020-10-09 07:31:54 -07:00
Dirk Hohndel
b40c8de35b build-system: remove Grantlee references from legacy scripts
I debated about this commit... we don't use these scripts any more, but it
seems like it would be worse to leave the Grantlee references in them. Yet of
course this is all no longer tested. Maybe it is time to delete the scripts
from the tree.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
ec7422feb5 build-system: remove Grantlee from the packaging scripts
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
21f1cf09f7 build-system: remove Grantlee from the container setup scripts
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
b29140f6e8 build-system: remove Grantlee from the get-dep-lib script
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
d837b01303 build-system: remove building Grantlee from Snap build
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
3371086d2b build-system: remove building Grantlee from AppImage build
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
7f896ee8d5 build-system: remove building Grantlee cmake
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
2dd28e3c8d build-system: remove building Grantlee from build script
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Robert C. Helling
51c84b3c44 Remove code references to Grantlee
These are no longer needed. What is still missing is removing Grantlee from the
various build systems.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Robert C. Helling
c9106b9dbe Interpret divelist printing templates
This is a first step of an efford to get rid of the Grantlee dependency. This
implements template processing for those constructs used in our divelist and
statistics printing templates.

It implements a template parser for loops over dives, cylinders and year and
variable replacement. As the previous Grantlee code, it does not really use
Qt's QObject introspection capabilities but reuses the old long chain of
if-else-statements.

The grantlee code is not yet removed.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Dirk Hohndel
b3e28eed5d Update translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-06 14:58:21 -07:00
Dirk Hohndel
35e1da2684 Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-06 10:52:26 -07:00
Dirk Hohndel
1f65d9df62 build-sytem: hide archived Subsurface version from translation scan
The release process creates full Subsurface trees under tmp. Don't pick
those up when looking for source strings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-06 10:52:26 -07:00
Berthold Stoeger
6e6705fb6e cleanup: use safe connect() in ConfigureDiveComputerDialog
The pointer-to-member-function version is compile-time checked
and therefore less risky with respect to refactoring.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-06 10:38:45 -07:00
Berthold Stoeger
8af40025b0 cleanup: use pointer-to-function connect() in ConfigureDiveComputer
This version is compile-time checked and therefore less risky with
respect to refactoring.

Since the same three signals were connect()ed for three different
threads-objects, do this in a new function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-06 10:38:45 -07:00
willemferguson
a3e990dfd5 Remove empty vertical space from filter QListWidget
In the filter the dropdown lists for selecting dive mode or day-of-week
has a lot of white space at the bottom. This PR removes that white space.
Actually the white space at the bottom of a QListWidget appears to
be a known bug (actually an omission) for the current Qt V15. The above
solution is a brute-force workaround to achieve the same end result.
The active line is actually the setFixedSize(). The other line, however,
comprises good QT layout policy to minimise widget size.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-10-05 13:36:29 -07:00
Berthold Stoeger
b3f5473b66 core: don't merge sample-derived pressures in merge_one_cylinder()
These will be recalculated from the pressures in fixup_dive()
anyway.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05 12:59:02 -07:00
Berthold Stoeger
6729428b6a core: improve merging of cylinders pressures
When merging cylinders pressures derived from samples were taken
as maximum of the start and minimum of the end pressure, which
makes sense, since we believe that this is the same cylinder.

However, for manually entered pressures, this was not done.

Moreover, when one dive had manual pressures and the other only
pressure from samples, the manual pressure was taken. However,
that could have been the wrong one, for example if the end
pressure was manually set for the cylinder of the first part of
the dive, but not the last.

Therefore, improve merging of manuall set pressures in two ways:
1) use maximum/minimum for start/end pressure
2) if the pressure of one cylinder was manually set, but not for
   the other, complete with the sample pressure (if that exists).

Fixes #2884.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05 12:59:02 -07:00
Berthold Stoeger
6f8837eca3 cleanup: remove libdc_serial field in device_data_t
This was only set but never read. Therefore, remove it. Divecomputer
serial numbers are now handled via a string-based interface.

We can't remove the integer-based firmware number, because that is
still used by the OSTC firmware check in ConfigureDiveComputerDialog.
Let's not risk breaking that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05 12:44:30 -07:00
Berthold Stoeger
426a7f5442 cleanup: remove DC_FIELD_STRING conditional compilation
This dates from 2014 - this should be obsolete: we certainly don't
support such old libdivecomputer versions. Moreover, we bundle our
own anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05 12:44:30 -07:00
Dirk Hohndel
f775ec2e69 download from dive computer: correctly list transports tried
Instead of just 'BT' or 'device name' (which is wrong in cases where we don't
use a device name in the first place, like USBHID), try to list the actual
transports that we will consider.

A big part of this patch is just moving code around so we don't need a forward
declaration of the static helper function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-05 12:42:40 -07:00
Dirk Hohndel
1065a52635 libdc/debug: provide better info regarding libdc interaction
Instead of just sending this to the user through the progress bar text, also
send things to stderr in verbose mode. That should make it easier to debug
situations where we fail to download from a dive computer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-05 12:42:40 -07:00
Berthold Stoeger
468eb7ef33 clenup: remove bogus connect statement.
In OstcFirmwareCheck::saveOstcFirmware() we find the connect() call
    connect(dialog, SIGNAL(finished(int)), config, SLOT(dc_close()));
whereby "config" is of the type "ConfigureDiveComputer".
However, the function signature of ConfigureDiveComputer::dc_close
reads as
    void dc_close(device_data_t *data);
and indeed "data" is accessed inside the function. I don't understand
how this doesn't crash, but clearly something is amiss.

Let's remove that connect statement.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05 12:39:16 -07:00
Robert C. Helling
4b4a117f96 Use get_n2 helper function
Now, that we have this helper function that should have been
introduced long ago, we can make some more expressions
more idiomatic.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-10-05 10:17:29 +02:00
Berthold Stoeger
61f8b8c002 planner: limit depth and time of segments to sane values
Using non-sensical depth and times for segments in the planner may
lead to an unresponsive UI. Therefore limit depth to 1000 m/3300 ft
and time to 100 h. Limiting of depth is done in settingsChanged()
since it has to adapt to the user changig their preferred units.

Fixes #2762.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 16:19:04 -07:00
Berthold Stoeger
5bc6f5d36c cleanup: make device code more consistent with core
We keep track of device, i.e. distinct dive computers with id in the core.
The corresponding code stuck out like a sore thumb. Firstly, because it
is C++. But more importantly, because it used inconsistent nameing conventions.

Notably it defined a "DiveComputerNode" when this is something very different
from "struct dive_computer", the latter being the dive-computer related
data of a single dive.

Since the whole thing is defined in "device.h" and the function to create
such an entry is called "create_device_node", call the structure "device".
Use snake_case for consistency with the other core structures.

Moreover, call the collection of devices "device_table" in analogy
with "dive_table", etc.

Overall, this should make the core code more consistent style-wise.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:53:26 -07:00
Berthold Stoeger
90ca635316 cleanup: use getDCExact() instead of callback in set_dc_deviceid()
core/device.c used to be a C file, which couldn't access the C++
divecomputer list directly. Therefore, instead of a simple loop,
searching for a matching DC was implemented via a callback with
void * user data parameter. Wild. Since the file is now C++, let's
just use direct access to the C++ data structures to make this
readable by mere humans.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:53:26 -07:00
Berthold Stoeger
ce7e74f62f cleanup: pass divecomputer to getDC() and getDCExact() helpers
These are used to search for device nodes and were passed model
and device id (for the exact version). However, all callers used
them to search for the node corresponding to a specific struct
divecomputer, so let's just pass that instead to make the caller
site less complex.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:53:26 -07:00
Berthold Stoeger
2b557f567a cleanup: hide DiveComputerList implementation details
Remove the declaration of helper functions needed only in
core/device.cpp. To this goal, turn the member functions
into free functions.

Cosmetics: turn the DiveComputer[Node|List] "class"es into
"struct"s, since all members were public anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:53:26 -07:00
willemferguson
d183e93bad Subsurface User manual update: Filter
This adds text to the user manual pertaining to the filter tool.
2 Figures removed, 7 figures added.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-10-03 10:39:00 -07:00
Berthold Stoeger
4ec0c6508e filter: add tank size filter constraint
This is an actual user request.

Fixes #1787.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:29:15 -07:00
Berthold Stoeger
ec431155a9 filter: implement filtering for gas mixes
This adds filter constraints for numerical filtering for gas-mixes.
Currently, this does a "match any" kind of search, which means that
a dive is filtered if any of its cylinders matches.

We should also implement "all-of" and "none-of" modes for cylinder
filtering.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:29:15 -07:00