Commit graph

18275 commits

Author SHA1 Message Date
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
Berthold Stoeger
23da23a534 core: add N2 and general gas component accessors
There were helper functions to access O2 and He component fractions.
Add another one for N2. Indeed, this can be used in three cases, where
N2 was deduced indirectly.

Moreover, add a general accessor with a gas_component argument.
This will be used by the filter code to filter for gas components.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:29:15 -07:00
Berthold Stoeger
34730b898b core: make gas type enum globally available
The deco-routines used an enum to pass around the inert gas
type. Make that globally available and make it include O2.
This will be used in a future commit to generalize access
of gas fractions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:29:15 -07:00
Berthold Stoeger
cd22b86bf8 dive list: when moving dives, delete first and add later
When moving dives between trips, the core moves the dives internally
and sends a signal to the model. The model adds and removes the dives
accordingly. However, when adding the new dive, the old trip hasn't
changed its position, so the ordering is wrong leading to an inconsistent
state.

Therefore, remove the dives first and then readd them. There could
still be pathological cases where this fails. However, in the short
term this is an improvement. Note that in similar cases, the dives were
indeed removed then added, so this case here seems to be an oversight.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
00abc04913 cleanup: use getDiveSelection() to loop over selected dives
getDiveSelection() returns a vector of the selected dives.
Use that instead of looping over the dive table and checking
manually.

This removes a few lines of code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
7b196a5ef9 desktop: allow moving dives to arbitrary trips
The UI only allowed adding dives to trips above or below the
current dive (and even that is buggy). This is a strange
restriction, since trips are designed to be non-contiguous.

Allow adding dives to any trip using the new trip selection
dialog. The undo-command is already there, so only little
code to write.

This feature was requested on the mailing list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
f5fe6839c7 desktop: add trip selection dialog
A simple dialog to select a trip. Simply fill a QListWidget without
the model/view rigmarole. So much less painful! Of course that means
that the dialog has to be regenerated everytime it is used.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
f4ee893424 cleanup: replace get_trip_date_string() by get_trip_string()
The get_trip_date_string() formatted, as the name implies, the date
of a trip. It was passed a number of parameters and had only one
caller, which would also add the location if it existed.
Therefore, move all that logic into the helper function and
name it get_trip_string().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
06c35026d6 desktop: fix paging through dive list with page-up key, etc
In the dive list we have horrible code, which intercepts all events
to save the selection before/after the event. This was necessary
because we couldn't get Qt's selection data flow under control.

This means intercepting all events that can change the selection.
The page-up, page-down, home and end keys were forgotten. Add these
cases.

Fixes #2957.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-02 11:10:28 -07:00
Linus Torvalds
d8f35711ff membuffer: be defensive about bad C library vsnprintf implementations
Dirk reports that some Windows users have had odd corruption in the
commit messages in the cloud storage.  They make no sense at all unless
there is some very weird Windows library bug.

The prime suspect is 'vsnprintf()' returning a negative error when the
target buffer is too small (rather than the proper "this is how much
space it would need").  That is a very traditional C library bug that I
thougth had been fixed everywhere, but there doesn't really seem to be a
lot of other likely causes.

So let's make our membuffer code be defensive against bad libraries that
return negative error numbers from vsnprintf.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-10-01 13:43:21 -07:00
Linus Torvalds
5f79ceef5e Update libdivecomputer to fix Garmin GPS recording
The Garmin Descent parser had a bug that would re-use possibly stale GPS
locations between dives (and in theory other data fields too, although
in practice I think only GPS data was ever leaked between dives).

This updates libdivecomputer to a fixed version.

Reported-by: @brysconsulting
Link: https://github.com/subsurface/subsurface/issues/2980
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-09-30 22:08:03 -07:00
Dirk Hohndel
4608beaee4 Android BLE discovery: use discovery agent
Android can't scan for classic BT devices, so when BT support was first
added, we simply didn't use the discovery agent at all and relied on the
list of paired BT devices provided by Android.

This still worked fine for a lot of BLE devices that allowed 'bonding'
with the Android device - similar to pairing. But some BLE devices (like
the Shearwater Peregrine) don't support bonding and so our Android code
didn't see them at all.

With this commit we start a BLE only scan on Android to add to the list
of already paired devices.

Fixes: #2974

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-30 16:40:41 -07:00
Dirk Hohndel
5b48585092 bluetooth discovery: report more information about progress
We certainly should log errors and the complete list of discovered
devices.

Also, it's good practice to set a specific search time (I picked three
minutes). This way we won't constantly scan and drain resources.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-30 16:40:41 -07:00
Dirk Hohndel
ca23147228 bluetooth discovery: differentiate discovered and paired devices
We call the same helper from two spots. Once when we report the already
paired BT devices on Android, and once from the deviceDescovered signal
for the discovery agent. Let's make sure we can tell where the info came
from.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-30 16:40:41 -07:00
Dirk Hohndel
3a9d895ccf documentation: release tasks
I think I'm the only one using this list, but it makes sense to
have it in the repo

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-30 16:40:41 -07:00
Berthold Stoeger
7337ff386b cleanup: rename FilterWidget2 to FilterWidget
The name "FilterWidget2" is historical and has no meaning anymore,
since the current version has little to nothing to do with the
"second" version of the widget.

Rename the class and source files accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:14:31 -07:00
Berthold Stoeger
068194b2e5 CHANGELOG.md update concerning new filter system
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:14:31 -07:00
Berthold Stoeger
76cf251e59 filter: avoid unnecessary filter recalculations when loading set
When loading a stored filter set, we would get numerous
constraintChanged signals, which caused filter recalculations.
Use the ignoreSignal flag to prevent these.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
cd27e36b8f filter: add modified flag
When editing the filter, the modified flag is set and shown to the
user. After saving / loading / clearing the filter, the flag is
reset. This simulates (probably badly) a usual load/save interface.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
1ed61aeabf filter: show currently selected preset in a text field
This provides some visual feedback on the currently selected preset.
Update when changing selection or clearing the filter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
e1c44a0a4d filter: save timestamps in user-readable format
So far we saved timestamps by their 64-bit value as decimal strings.
Change this to a user readable format. The parsing routine still
supports decimal numbers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
cccd242a36 filter: when clearing the filter unselect the current filter preset
It makes no sense to have the a filter preset selected after
clearing the filter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
d064f78608 filter: when a filter preset is selected, suggest its name on save
The goal here is to let the user edit already existing sets and
save them using their old name. This is a stop-gap measure until
we get a proper filter-set editing interface.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
8f898477cb core: add helper functions to format / parse timestamps
To save datetime-based filter constraints to git or XML,
it is preferrable to use human-readable representations.
Therefore, add helper functions to format / parse timestamp_t
64-bit values in the "YYYY-MM-DD hh:mm:ss" format.

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