Commit graph

1145 commits

Author SHA1 Message Date
Dirk Hohndel
63297562e6 iOS: find translations again
commit ec0511e824 ("ios: concentrate build dirs") moved the translations around
without updating the way they are accessed, causing our release 2.1.0 on iOS to
not be localized.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-03 14:58:00 -07:00
Robert C. Helling
072e404af5 Allow to split dives with more than one dive computer
Only the first computer is taken into account to find
surface intervals. All further dive computers are split
according to time.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-07-03 14:47:15 -07:00
Robert C. Helling
00f4fa0d1d Profile context menu entry to split a dive
Allow the user to manually split a dive in two.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-07-03 14:47:15 -07:00
Robert C. Helling
8697f7a84d Include cylinder pressures upon force_fixup()
Try to recompute cylinder start and end pressures from sample
data.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-07-03 14:47:15 -07:00
Berthold Stoeger
57c01f7a66 Translations: unify gettextFromC::tr() and QObject::tr()
There were two catch-all classes for translations outside of class
context. gettextFromC was used exclusively from C, but C++ used
both, gettextFromC and QObject. Some of the string were even present
in both. Therefore, unify to gettextFromC throughout the code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 05:33:31 +08:00
jan Iversen
2f95141330 core: remove double definition of enum cloud_storage_status
Remove cloud_storage_status from qmlprefs.h.
usage to qPref::

enum cloud_storage_status is not used from C, but only from C++, and
having the same structure defined multiple times is a maintenance
challenge.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
jan Iversen
d02a03983d core: add qPref.h_and qPrefprivate.h
add 2 header files and 1 cpp file (qPrefPrivate does not have an implementation)

The rewrite/consoliadation of SettingsObjectWrapper, qmlmanager, qmlpref and planner
needs a place to put common private parts (qPrefPrivate) and 1 common class (qPref).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
jan Iversen
6c9c2168e1 core: sort CMakeLists.txt
sort .c and .cpp files in CMakeLists.txt

The .c and .cpp files in CMakeLists.txt had no obvious sequence,
sorting it at least gives one understandable sequence

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
jan Iversen
889a0bb67a core/profile: move PP_GRAPHS_ENABLED from pref.h
PP_GRAPHS_ENABLED is only used in profilewidget2.cpp
make local to profilewidget.cpp

Signed-off-by: Jan Iversen <jani@apache.org>core/profile: move PP_GRAPHS_ENABLED from pref.h
2018-07-04 05:32:30 +08:00
jan Iversen
36d7f6eafb core: sort struct preferences
sort prefs, making it possible to find variables
add a few missing variables

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
Berthold Stoeger
09fd5c40d1 Dive pictures: implement FindMovedImagesDialog
Move the find-moved-images functions into a new translation unit
and present the user with the identified matches before applying
them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
f3ef38ca0d Dive pictures: remove hashes
In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).

Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
0646b41275 Dive pictures: find moved pictures based on filename
Users might have edited their pictures. Therefore, instead of identifying
pictures by the hash of the file-content, use the file path. The match
between original and new filename is graded by a score. Currently, this
is the number of path components that match, starting from the filename.
Camparison is case-insensitive.

After having identified the matching images, write the caches so that they
are saved even if the user doesn't cleanly quit the application.

Since the new code uses significantly less resources, it can be run in a
single background thread. Thus, the multi-threading can be simplified.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
08962cb38d Dive pictures: index local file name by canonical filname
The connection canonical filename to local filename was done via
two maps:
  1) canonical filename -> hash
  2) hash -> local filename
But the local filename was always queried from the canonical filename.
Therefore, directly index the former with the latter.

On startup, convert the old map to the new one.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Dirk Hohndel
988d6682f2 Correctly recognize more OSTC variants as BLE
Some OSTC 2 and OSTC Plus variants show 'OSTC+ xxxxx' as BLE name and we
recognized this as OSTC 3 (but that one doesn't support BLE). With this
we recognize these models as OSTC 2 (which is identical from a download
perspective to the OSTC Plus) and both of those support BLE.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 09:24:30 -07:00
Linus Torvalds
90569e0ee6 Use (and update) dive computer times when merging and splitting dives
When we split a dive in two, we keep the dive computer ID for the dive,
but we should update the actual _time_ of the split dive to match the
split.

And when we look for "are these the exact same dives", we should check
not only that the dive computer dive ID matches, but also that the dive
computer time matches, so that we don't consider two parts of a dive
that has been split to be obviously the same dive.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 08:38:31 -07:00
Linus Torvalds
3209b490dd Use proper sample pointer when deciding to split dives
The dive splitting was completely wrong, because we checked the time of
the previous sample by doing

	sample[i - 1].time.seconds

which is entirely wrong.  The 'sample' variable is the *current* sample,
so the time of the previous sample is simply

	sample[-1].time.seconds

Alternatively, we could have started from the first sample, and done

	dc->sample[i - 1].time.seconds

but mixing the two concepts up just gets you a random sample pointer
that is likely not a valid sample at all, and obviously does not have
the right time at all.

As a result, dive splitting was pretty much random.  Sometimes it worked
purely by mistake, because the rest of the logic was right (ie we _had_
found the right point where we reached the surface in the dive etc, the
"previous sample time" was simply used to decide if the surface interval
was sufficient to split the dive up).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 08:36:53 -07:00
jan Iversen
f86dd889bf core: remove prefs-macros.h where unused
move #include prefs-macros from SettingsObjectWrapper.h to SettingsObjectWrapper.cpp
include dive.h directly (only part of prefs-macros.h used) in preference classes

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-01 22:06:28 +02:00
Berthold Stoeger
1a5e54e5eb Dive pictures: render icons with white instead of transparent background
The SVG icons for failed / still-loading pictures were rendered with an
alpha channel. This lead to strange behavior when hovering over the
icon in the profile plot: When hitting a "hole" the icon would be
minimized again.

Therefore, render the SVGs onto a white background.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-28 21:58:29 +08:00
Stephen Goodall
b492df6ffc Add Cressi Giotto, Newton and Drake to list of devices
Adding Cressi Giotto, Newton and Drake to the list of devices
that can be selected on Android devices.

Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
2018-06-28 11:52:24 +08:00
Dirk Hohndel
314b08c78f QML UI: go back to always saving libdivecomputer logfile
This got disabled as unintended (I hope) side effect of commit
807571a588 ("core: update deviceData default from qml").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-27 16:01:12 -07:00
Stephen Goodall
26871df84d Add Cressi Leonardo to list of devices
Adding Cressi Leonardo to the list of devices that can be selected
on Android devices.

Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
2018-06-28 01:43:26 +08:00
Berthold Stoeger
db0dd54c37 Localization: make cache thread safe and robust against use-after-free
The old trGettext() was not thread-safe and the returned C-strings
could be freed in the case of empty translations strings. Therefore:

1) Introduce a mutex protecting access to the cache.

2) Never change existing entries, even if the translation string is empty.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Berthold Stoeger
879cb73b8b Localization: remove gettextFromC::instance()
There were a handfull instances of the kind
1) gettextFromC::instance()->tr(...)
2) gettextFromC::instance()->trGettext(...)

1) is pointless, as tr is a static function.

All instances of 2) were likewise pointless, because trGettext()
returns a C-string, which was then immediately converted to a
QString.

Thus, replace both constructs by gettextFromC::tr(...).

After this change there was only one user of gettextFromC::instance()
left, viz. the C-interface funtion trGettext(). Therefore, remove
gettextFromC::instance() and do all the caching / translating
directly in the global trGettext().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Berthold Stoeger
61b8add590 Localization: don't go via C-string in qthelper.cpp
The purpose of the gettextFromC class is twofold:
1) It provides a static storage of C strings if the C part needs
a translation and doesn't want to deal with memory-management.
2) It severs as a catch-all class for translations that do not come
from a proper class (i.e. from helper functions).

The second case was used a few times in qthelper.cpp. By using the
trGettext() function, a cached C-string was obtained. But in every
single instance, this C-string was then back-converted into a QString.
Therefore, use the gettextFromC::tr() function directly, which
returns a QString. Not only is the resulting code simpler - this also
avoids superfluous caching of translation strings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Robert C. Helling
8406cbf187 Fix interpretation of dive mode changes upon replan
... by taking into acount that dive planner points refer
to the sement before the waypoint (while change mode
events are concerned with the future of a waypoint).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-24 09:35:55 +02:00
Robert C. Helling
4157365c96 Make planner notes divemode aware...
... and fix a problem with setpoint changes shown in the wrong line

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-24 09:35:55 +02:00
Berthold Stoeger
c65617661a Dive pictures: fix loading of remote images without local version
Owing to the recent churn in imagedownloader.cpp, some of the
code was bogus.

Notably, in f60343eebb the code
was changed such that always the local filename was used to access
the images. Yet, the old code remained, which after failure tried
again to access the local picture. This second access can obviously
be removed completely.

More seriously, after failing to load the local version, no
attempt was made to fetch the image via canonical filename. This
could produce the following sequence of events:
  - Import remote image
  - Delete thumbnail and local cache of image
  - Image loading would fail

Therefore, first try to load using local file-location. If
that fails, load using the canonical file-location. To do
so, split the file-access code in two functions. The code
should now be distinctly easier to follow.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-22 00:26:02 +03:00
Dirk Hohndel
5377706aca FTDI support: try ftdi_open first if the device name is 'ftdi'
It makes no sense to have the OS try (and fail) to open that device name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-21 16:16:29 +09:00
Dirk Hohndel
b7619553fd core: print the correct message code for download failures
We filled in the missing information and then printed the wrong string.
This fixes that and also makes the strings slightly easier to understand.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-21 16:15:48 +09:00
Dirk Hohndel
05a00f31e9 mobile: better message regarding logfiles
On mobile those area always created and available for simple cut and paste.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-21 15:49:23 +09:00
Anton Lundin
dcb663e407 Revert "cleanup: remove empty function"
This broke our hook to plumb in our usb open function into libusb, so
this broke ftdi based downloads.

This reverts commit e4530cd5ef.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-06-21 06:28:39 +09:00
Linus Torvalds
98bd303d93 qt-ble: purge pending read data when writing
This should never happen, since our interface is bassically synchronous,
but it could happen with delayed replies that came in just after we
decided to re-transmit a command.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-06-20 16:38:04 +09:00
Linus Torvalds
21d6531e45 qt-ble: improve responsiveness of waiting for bluetooth data
Our model of waiting for 100ms before re-checking if we got a packet
over BLE resulted in potentially horrendously bad latency for received
packets.

That isn't just a possible performance issue, it actually seems to cause
IO errors with my Suunto EON Core.  I'm not entirely sure why, but it
might simply be some timing interaction, particularly since the IO
errors seemed to primarily happen when the dive computer itself was also
busy updating the screen (ie if you pressed buttons on the dive computer
to switch to compass mode, for example).

So replace the silly hardcoded 100ms "waitFor()" function with a
WAITFOR() macro that checks the provided expression every time through
the loop, which gets us a much lower latency (we basically check every
ten milliseconds).

The macro is not beautiful, but it WorksForMe(tm).

This makes a huge difference to the reliability of the download for me,
and might matter for some other dive computers too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-06-20 16:38:04 +09:00
Lubomir I. Ivanov
9e58e6f0e6 equipment: use MAX_TANK_INFO in equipment.c
MAX_TANK_INFO is defined in dive.h but is not
used in add_cylinder_description() or when
allocating 'tank_info'.

Use MAX_TANK_INFO instead of the literal 100.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-20 09:30:58 +09:00
Lubomir I. Ivanov
06a870c232 equipment: sanitize 'ws_info' loop limits
Instead of a constant or a macro for the maximum
number of 'ws_info' elements the 100 literal was used.

Define MAX_WS_INFO in dive.h and use it everywhere.

Also clamp loops that iterate `ws_info' to MAX_WS_INFO.
Prevents potential out-of-bounds reading, similarly to
the previous commit about 'tank_info'.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-20 09:30:58 +09:00
Lubomir I. Ivanov
769aca9e95 equipment: sanitize 'tank_info' loop limits
In a number of places the global 'tank_info' array
is being iterated based on a 'tank_info[idx].name != NULL'
condition.

This is dangerous because if the user has added a lot of tanks,
such loops can reach 'tank_info[MAX_TANK_INFO]'. This is an
out of bounds read and if the 'name' pointer there happens to be
non-NULL, passing that address to a peace of code that tries
to read it (like strlen()) would either SIGSEGV or have undefined
behavior.

Clamp all loops that iterate 'tank_info' to MAX_TANK_INFO.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-20 09:30:58 +09:00
Dirk Hohndel
a5380bb741 core: add free_samples helper
And use it in the UI and planner code.

See #1411

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-20 09:27:11 +09:00
jan Iversen
cabc5859fd core: use num in alloc_samples
When num > dc->alloc_samples we whould allocate space for num

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-20 07:59:07 +09:00
Berthold Stoeger
3932c97af7 libdc interface: remove debug messages
Don't spill supported transports as error message to the user.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-18 06:25:40 +09:00
Berthold Stoeger
1f654050fa Dive computers: turn QMultiMap into sorted vector
The list of known dive computers was stored in a multi-map indexed
by the device name. Turn this into a sorted QVector. Thus, no
map-to-list conversion is needed in the device editing dialog,
which distinctly simplifies the code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17 06:53:13 +09:00
Berthold Stoeger
8e8cd7a8d9 Cleanup: remove eplicit constructors and unused member variable
Remove the explicit constructor in DiveComputerNode: Just use
classical C-style struct initialization. Moreover, remove the
empty constructor and destructor of DiveComputerList.

The variable DiveComputerList::dcWorkingMap was unused. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17 06:53:13 +09:00
Stefan Fuchs
0bc9edf855 Fix an error around translation of dive modes in the UI
This fixes an mistake introduced in
3d1072f886

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17 06:36:20 +09:00
Miika Turkia
076419d757 DM5 import: support for larger sample size
Suunto has updated SampleBlob to use 30 byte blobs. This adds support
for the increased size. Note that this only parses the same fields we
have parsed before. (Currently I have no idea what the increased size is
used for.)

Note also that I do not currently have data with the new format so I
only tested this still works with old data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-06-15 17:45:33 -07:00
jan Iversen
54db1309a0 core: make prefs-macros compile safe.
add {} in each macro to secure it works as a single statement,
to avoid problems like
  if (1)
      GET_TEXT();

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-15 14:11:57 -07:00
Berthold Stoeger
4c19d3da1d Dive pictures: Make failure of loading images less noisy
For debug reasons, failure to load the original image was spilled
to the console, even if the local file was then found.

Only print a message, when also the local image failed loading.
This needed a bit of code reshuffling. To know when to print a
failed-loading message, the URL is now checked at the Thumbnailer
level, not the ImageDownloader level. The ImageDownloader is
passed the URL and the original filename (if different). The
image is loaded from the URL, but the signals send the original
filename, so that the thumbnail can be associated to the proper
image.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-13 08:35:23 -07:00
jan Iversen
470c218b79 core: remove qml properties from downloadfromcthread
Remove Q_OBJECT and qml properties from DCDeviceData class
Remove DCDeviceData register from mobile-helper.cpp
Change DCDeviceData constructor to be without parameters

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09 21:19:46 +02:00
jan Iversen
807571a588 core: update deviceData default from qml
remove setting default in qml to C++

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09 21:19:46 +02:00
jan Iversen
682e1b63f5 mobile: add DCDeviceData properties to qmlmanager
add DCDeviceData qml properties etc. to qmlmanager

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09 21:19:46 +02:00
jan Iversen
acc9784fd9 core: remove qml properties from desktop compile
add #ifdef SUBSURFACE_MOBILE to secure qml macros are not
compiled with desktop

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09 21:19:46 +02:00
Willem Ferguson
42895606b1 Provide correct cylinder pressures for bailout dives
Calculate the correct cylinder pressures for rebreather dives with
bailout. Currently the cylinder pressures for a dive are calculated
assuming a single dive mode for that dive. Bailout indroduces more
than one dive mode for a single dive, i.e. transitions from
CCR or PSCR to OC and back. Currently the start and end pressures
for each cylinder are used to interpolate cylinder pressures while that
cylinder is used. However, the different gas consumption rates for
OC, PSCR and CCR are not taken into account in this interpolation
and the cylinder pressure is indicated by an averaged interpolation
accross the rebreather and OC legs of the dive. Consequently the
increased drop in cylinder pressure during OC is not shown. This
PR allows differentiation between CCR/PSCR legs of the dive and
the OC bailout segments, showing realistic interpolation that
indicate the increased rate of gas use during OC.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-06-08 17:07:20 +03:00
Berthold Stoeger
2e8f506635 Dive pictures: remove cache_picture() call in dive_add_picture()
When adding a picture to a dive, cache_picture() was called, which
calculated the hash of the picture in a background-thread.

This made tests occasionally fail, because the tests depended on
the filename-to-localfilename being overwritten in a call running
in a different thread. Depending on which thread finished first,
the test succeeded or failed.

The easiest way to circumvent this problem is to remove the cache_picture()
call. The hash will be calculated anyway with the thumbnails. And
the only function of the hash is the "find moved images" function. Which
is not an issue here, because the user just loaded the images from
disk.

Reported-by: Jan Iversen <jani@apache.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-07 18:41:32 +02:00
Willem Ferguson
780530f32e Bugfix: Load PSC dive logs
The code changes to standardise the named of divemodes and to
separate internal divemode names and UI divemode names introduced
a bug that caused non-backward compatability with existing
dive logs. The reason for this is the definition of the
divemode_text strings in dive.c

This change reverses that definition and brings about correct
loading of PSCR dive logs as well as correct parsing of bailout
events involving PSCR.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-06-06 21:48:06 +02:00
jan Iversen
1c2ed7f49f core: remove "static void copyPath" unused
Remove copyPath since it is static and not called
to avoid clang warning

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-05 16:45:15 +03:00
jan Iversen
efab7e3357 core: remove unused function getDetectedDeviceAddress()
getDetectedDeviceAddress is not used in mobile or desktop version

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-04 10:27:13 -07:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
helpers.h included qthelper.h and all functions declared in helpers.h
were defined in qthelper.h. Therefore fold the former into the latter,
since the split seems completely arbitrary.

While doing so, change the return-type of get_dc_nichname from
"const QString" to "QString".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04 08:50:10 -07:00
Berthold Stoeger
9f349a4efc Cleanup: make copyPath() function of static linkage
The function was only used in core/qthelper.cpp

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04 08:50:10 -07:00
jan Iversen
76f61468e6 mobile: add timer to measure startup.
Subsurface-mobile has a long startup time; in order to isolate the problem(s) a
timer is added to see where time is "lost".

The collected startup times are added to the clipboard together with the other
logs, allowing test users to report back.

All this is only enabled when compiling with -DENABLE_STARTUP_TIMING

Closes #1340

[Dirk Hohndel: collapsed multiple commits and minor white space cleanups, added
               missing QMutex variable]

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-30 21:47:07 -07:00
Robert C. Helling
2c53eef50e Planner: Don't store a setpoint unless we are in CCR mode
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
Robert C. Helling
fb09784060 Don't compute SAC if total gas use is unknown
If we breathe from a cylinder with invalid start or
end pressures, we cannot reliably compute the total gas
use and thus the SAC. So we should not pretend to do so.

A better fix would compute the total SAC for only those
segements that have valid start and end pressures.

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
Robert C. Helling
eb52f36cb6 Rename confusing variable name
This is a struct dive pointer not a divepoint.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
Robert C. Helling
7c6e5ed5db Distinguish between user and internal divemode names
The former should be translated but not those that
go to xml/git.

... and fix capitalization of pSCR.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
Miika Turkia
7d2c08aed0 Remove unnecessary {}
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-27 23:18:01 +03:00
Miika Turkia
a929c86584 Shearwater import: avoid running atoi multiple times
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-27 23:18:01 +03:00
Miika Turkia
295c63211c Shearwater import: support for DC reported ceiling
This adds support for DC reported ceiling when importing the Shearwater
Desktop database. Both AI and non-AI versions are tested, but not all
possible paths. For non-AI the DC reported ceiling was from
firstStopDepth and for the AI version it was from the decoCeiling field.

I do not currently know when each of these fields are used, but at least
this works on my test data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-27 23:18:01 +03:00
Berthold Stoeger
308e079ad6 Dive pictures: automatically recalculate thumbnails
If a thumbnail and the original picture can be accessed and the
modification date of the thumbnail is before the modification date
of the picture, recalculate the thumbnail.

This causes more disk access and might give strange effects for
picture files with messed up file timestamps (i.e. lying in the
future) or messed up computer clocks (i.e. running in the past).
Therefore, add a preference option to disable the new behavior.
Default is set to enabled.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27 23:08:12 +03:00
Berthold Stoeger
23d38a982d Dive pictures: give user option to recalculate thumbnails
Even though hashes of image contents are calculated, the hashes are
not compared to actual file contents in routine-operation. Therefore
give the user the option to recalculate thumbnails, should they have
edited the picture.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27 23:08:12 +03:00
jan Iversen
2d1e5d7a99 core: qt-ble.cpp remove postEvent for all platforms
the postEvent is only called when downloading from a dc
with bluetooth, so in most it does not have an effect
on the deleteLater() in the code.

there are no reason to do special cleanup while waiting
for bluetooth

QEvent::DeferredDelete is not supported on iOS.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-26 09:26:43 -07:00
Berthold Stoeger
80224a98b1 Dive pictures: Derive thumbnail file from picture filename
Since commit 6618c9ebfc, thumbnails
are saved in individual files. The filename was simply the picture-hash.
In a mailing-list discussion it turned out that in the future we might
not hash images or change the hash. Therefore, derive the thumbnail
filename from the image filename, using the SHA1 algorithm.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26 09:24:28 -07:00
Berthold Stoeger
b34eeeaba2 Cleanup: remove code related to pictures in the cloud-repository
Storing pictures in the cloud never came to be, so remove the code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26 09:23:49 -07:00
jan Iversen
061be82e31 core: replace (void) with UNUSED(x) and include ssrf.h
Unused parameters in C are "silenced" by adding UNUSED(x)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 08:34:14 -07:00
jan Iversen
6e253fa04f core/ssrf.h: add #pragma to avoid clang warning "-Wmissing-field-initializers"
Add a #pragma to avoid getting warning when a struct is only initialized
with one 0 and not one pr struct member

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 08:34:14 -07:00
jan Iversen
a243977026 core: add ssrf.h as global product header
ssrf contains macros/includes etc. used in ssrf, but
not related to dives (mainly in dive.h)

currently the header is created to add the macro UNUSED
later it will be used to remove non-dive related items
from dive.h

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 08:34:14 -07:00
jan Iversen
12b4f2235b core: replace (void) with no parameter name
Unused parameters in C++ are "silenced" by removing the name.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 08:34:14 -07:00
Berthold Stoeger
21ee440e5f Cleanup: remove code related to picture-storage in git repositories
Saving of pictures to git repositories was disabled. Finally remove
this code and the corresponding load code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-24 08:27:10 -07:00
jan Iversen
52031f0aba core/subsurface-qt: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
jan Iversen
a312e53f0c core: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
jan Iversen
67838de5bc iOS: qt-ble.cpp remove unsupported event.
QEvent::DeferredDelete is not supported in iOS

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 07:46:41 -07:00
jan Iversen
d8227c4a70 core: marked unused parameter
Add Q_UNUSED to unused parameter

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-20 08:11:29 -07:00
Dirk Hohndel
1faa5d7ae1 build-system: don't always build qtserialbluetooth.cpp
This should only be built if we have BT support enabled.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-19 16:49:05 -07:00
jan Iversen
2a0ee09cb2 core: solved PictureEntry defined as class and struct.
PictureEntry was defined as class in imagedownloader.h and
as struct in divepicturemodel.h

A class has a vptr in front, so the difference is real at least
for the clang compiler.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-18 12:42:48 -07:00
jan Iversen
6034b25cb2 core: removed clang warnings from dive.h
interpolate, rel_mbar_to_depth, gas_mod and
gas_mnd returns int but uses
a function that returns long, causing clang to
warn about conversion loss due to implicit conversion.

Adding a cast, shows that it is correct.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-18 21:27:37 +03:00
jan Iversen
262e994bbc core: removed clang warnings from units.h
lbs_to_grams and to_feet returns int but uses
a function that returns long, causing clang to
warn about conversion loss due to implicit conversion.

Adding a cast, shows that it is correct.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-18 21:27:37 +03:00
Berthold Stoeger
10cabcdb69 Plannernotes: '\0'-terminate ICD-buffer
When creating the ICD-notes the membuffer was not '\0'-terminated,
leading to output of stale data.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-18 15:11:04 +03:00
jan Iversen
21bf811a57 core: corrected wrong default email
Typo in email.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-17 11:32:54 -07:00
Willem Ferguson
346bb9f31f Bugfix: Saving divemode to xml and to git
There is a space character missing in the xml generated by the
present code. Insert a space character.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-17 07:35:58 -07:00
Berthold Stoeger
afe8843509 Dive pictures: don't attempt reading the same image twice
If loading of an image failed, we tried to see if we find a
canonical filename in the cache. There's no point in rereading
the picture if the canonical and the original filename are
the same.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-16 15:20:30 +03:00
Berthold Stoeger
c3c2c2f606 Dive pictures: Don't enter infinity loop on invalid pictures
The recently committed refactoring of the dive-picture code introduced
a severe bug:

If an image couldn't be loaded from disk owing to an invalid file, the
filename was interpreted as an url and loaded in the background. This
succeeded, because the file actually exists. After download, the file
would then still be invalid and the whole thing restarted, leading to
an infinity loop.

To fix this, do two things:

1) Don't even try to download local files.
2) If interpreting a downloaded file fails, don't try the downloading
business again.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-16 02:01:26 +03:00
Robert C. Helling
969dfee9ec Rename enum dive_comp_type to divemode_t
...as the usuage is not anymore about a computer but
a momentary dive mode. Rename the end indicator as well.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Robert C. Helling
0b836f12fc Planner: Make use divemode for consumed gas calculation
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Robert C. Helling
d018ceb852 Planner: Honor last manual divemode
Start the decompression schedule in the divemode
of the last manual section.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Robert C. Helling
09da42f819 Fix divemode detection in planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Willem Ferguson
5bac32a1b5 Fix a bug where the bailout events are not saved correctly.
The bailout events in the planner are not saved correctly.
My oversight. This commits corrects the bug

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
4c73ada121 Adapt the dive planner to do bailout
Ensure that calls to add_segment() all have a appropriate divemode
for that part of the dive plan. In the case of plan(), the existing
variable 'divemode' was directly passed to add_segment. For the
functions interpolate_transition() and trial_ascent(), the divemode
was obtained by including it in the parameter list of the function
and divemode supplied by the calling function.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Robert C. Helling
69de9d8f98 Add planner infra structure for bailout
Add a divemode column to the planner model and a
corresponding field to struct divepoint and fill it
in the corresponding functions.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Willem Ferguson
9c24d6bef8 Fix bug for CCR dive bailout
Under some conditions get_current_divemode() (in dive.c) returns an
erroneous divemode. This happens when there are several events at
the very beginning of the dive, as can happen in some CCR dive logs.
This commit fixes that bug.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
2a2098bab2 Implement get_divemode() to find the divemode at a particular time
Replaced a rather cumbersome function that that did the above. Upon
the suggestion of Robert Helling who proposed a much shorter way,
this new function replaced the previous ones. This necessitated
changes to divelist.c, profile.c and plannernotes.c, as well as
dive.c/h.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
cad4eb39c4 Implement get_divemode() to find the divemode at a particular time
Replaced a rather cumbersome function that that did the above. Upon
the suggestion of Robert Helling who proposed a much shorter way,
this new function replaced the previous ones. This necessitated
changes to divelist.c, profile.c and plannernotes.c, as well as
dive.c/h.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
b9174332d5 Read and write divemode changes (xml and git)
This provides for reading of divemode change events from dive logs
and for writing them to dive logs. This applies to xml and git
divelogs. Divemode change events have the following structure:
event->name = "modechange"
event->value = integer corresponding to enum dive_comp_type (dive.c),
reflecting the type of divemode change (OC, CCR, PSCR, etc).

In the dive log file, the event value is written as a string that
corresponds to each of the enum values, e.g.
<event name='modechange' divemode='OC' />
This xml is also read from the dive log file and translated to an
appropriate value of event->value.

The file diveeventitem.cpp was udated to reflect this new way of
dealing with divemode change events.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
0e08c0870a Simplify the bailout detection functions.
Function peek_next_divemodechange() is redundant if get_next_divemodechange()
has one additional parameter. Calls to get_next_divemodechange() were
updated in divelist.c, plannernotes.c and profile.c.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00