Commit graph

3972 commits

Author SHA1 Message Date
Sergey Starosek
e5ae3fca7f Make Ctrl-F window shortcut
The shortcut may be used elsewhere, e.g. in user manual

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-10 16:07:25 +07:00
Linus Torvalds
7ba167e1b3 Remove now stale arguments to "CHANGED()" macro
We now never remove units or percentage signs, and always just compare
the string data, so we should remove the hacky arguments that are no
longer used.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09 15:51:21 +08:00
Linus Torvalds
1d2238b110 Add and use 'string_to_fraction()' helper converter function
This matches the pattern of unit conversion, and will allow us to remove
all the code that uses the old complex "CHANGED()" macro that tries to
remove units or percent signs.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09 15:51:18 +08:00
Linus Torvalds
4f982c1758 Add unit-aware cylinder size string parserc
Whittling down on the string parsing that doesn't check user-specified
units.  Still need to handle temperatures (and will do percentages to
match the pattern too), but this is getting us closer to always honoring
user-specified units.

With this you can say that you have a "10l" cylinder at "3000psi", and
it will do the right thing (it's basically a 72 cuft cylinder in
imperial measurements).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09 15:51:03 +08:00
Linus Torvalds
9c06938adc Add unit-aware conversion of pressure data
This just adds (and uses) a string_to_pressure() to parse pressure units
correctly when filling in cylinder pressures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09 09:10:29 +08:00
Rodrigo Severo
c32c28d40b Interpolated pressure should always be set
Interpolated pressure should always be set, even it we didn't
calculate a new one. In this case we should just use the last one.

Signed-off-by:Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09 07:08:57 +08:00
Dirk Hohndel
f12f9ae8c3 Change fake profile behavior
If no average depth is known the current fake profile behavior is rather
unintuitive (we make up an average depth).

Instead we should assume that this is a PADI style dive log and give the
user a "rectangular" profile (actually, it's a trapecoid as we at least
try to enforce a sane ascent / descent speed). If the dive is somewhat
longer or deeper (10 min / 10 m) we even add a 3m safety stop at 5m.

Added a new dives/test0b that tries to capture the typical cases to test
this.

Fixes #398

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 21:54:29 +08:00
Dirk Hohndel
fef4d15965 When interpolating tank pressures, don't devide by zero
When an interpolated segment is on the surface we get no pressure time -
and try to divide by zero.

(plus a small whitespace issue that slipped throught the cracks earlier)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 21:05:16 +08:00
Rodrigo Severo
eec5dba1c2 Reinstating SURFACE_THRESHOLD test in pressure_time function
The small straight parts at the end of tank pressure lines are more of a
aesthetic issue, not causing real harm so it is no reason to remove the
SURFACE_THRESHOLD test from pressure_time function only because of this.

Also improved interpolate data debuging, rearranged
get_pr_interpolate_data and removed an unused variable from
get_pr_interpolate_data. No real change here, just trying to make the code
clearer.

[Dirk Hohndel: clean up whitespace damage from this and the previous
               commit]

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 20:38:17 +08:00
Rodrigo Severo
8f0c8be245 Discontinuity and stall on tank pressure interpolated lines
Interpolated lines for tank pressures were presenting discontinuities
(sudden drops) and stalls (horizontal lines) with certain dive profiles.

The main reason seems to be that the discrete interpolation of tank
pressure was adding small pressure increments that could be rounded down
or up repeatedly generating cumulative rounding errors that would mean
either a delay on pressure drop that would be drawn as a sudden drop or as
a premature pressure drop that would result in a flat line.

This patch changes the way the discrete interpolation is done, so that we
don't have cumulative rounding errors distorting tank pressure lines.

To calculate accumulated pressure_time values the get_pr_interpolate_data
function was created. The fact that get_pr_interpolate_data transverses
the beginning of the plot_info entry list for each entry that needs
interpolated tank pressure isn't optimal at all. There might be a way to
properly track the data necessary to interpolate tank pressures from
inside the main pi->entry loop in fill_missing_tank_pressures.
Unfortunately I didn't manage to do it inside fill_missing_tank_pressures
so we have get_pr_interpolate_data.

The SURFACE_THRESHOLD test from pressure_time function was also removed as
no matter how shallow the diver is, if he is using the cylinder to breathe
the cylinders tank pressure should be affected.

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 20:35:07 +08:00
Linus Torvalds
cc33ff2fe2 Add a string_to_depth() helper function to match our string_to_weight one
It's currently only used for the setting of the cylinder switching
depth, but now that one should work with user-specified units (so you
can set a max depth in feet even if you use metric, and vice versa).

In the future, if we also make the unit preferences something you can
pass in (with user preferences as a default argument value), we might
want to use this for parsing the XML too, so that we'd honor explicit
units in the XML strings.  But the XML input unit preferences are not
necessarily at all the same as the user preferences, so that does
require us to extend the conversion functions to do possibly explicit
unit preference selection.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 16:38:52 +08:00
Linus Torvalds
2d1d78ebfe const'ify our strtod() helper functions
The C library doesn't use const char pointers for legacy reasons (and
because you *can* modify the string the end pointer points to), but
let's do it in our internal implementation just because it's a nice
guarantee to have.

We actually used to have a non-const end pointer and replace a decimal
comma with a decimal dot, but that was because we didn't have the fancy
"allow commas" flags.  So by using our own strtod_flags() function, we
can now keep all the strings we parse read-only rather than modify them
as we parse them.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 16:38:47 +08:00
Linus Torvalds
19b982d3df Make 'string_to_grams()' use proper type safe types
Make it use 'weight_t' and hide the "grams" part inside the type.  That
was the whole point of the weight_t type, after all.  Returning a
"double" was always bogus, since we internally always do integer grams
(and the function actually used "rint()" to get all the rounding right
anyway).

As a result, it's now called "string_to_weight()".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 16:38:43 +08:00
Miika Turkia
88fdf1b138 Show import dialog only when needed for CSV config
We do not need any import dialog when importing normal XML based
divelogs. With this they are imported directly after file selection
dialog. However, when CSV files are detected in the import list, the
configuration dialog is displayed and applied for them. (CSV files are
detected by file extension.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:54:20 +08:00
Jef Driesen
58f6a01a22 Write the event data to the libdivecomputer log.
For some devices, the event data contains important data that is
required for parsing the dives, but which is not present in the full
memory dump.

Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:53:42 +08:00
Lubomir I. Ivanov
a32462c26b DownloadFromDCWidget: prevent possible leaks for log/dump files
If the 'logfile_name' and 'dumpfile_name' were NULL we can simply
strdup() them with a new value, but if there was a previous value
we need to free() first.

C99 6.7.8 allows us to keep said variables without the
explicit NULL initialiazation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:53:26 +08:00
Lubomir I. Ivanov
4d8168cc57 libdivecomputer.c: Try not to pass NULL to fopen()
C99 7.1.4, says nothing about passing NULL to fopen(),
which means that it isn't portable and there are no guaranties
that the return will be a NULL pointer or that that a library
implementation will not assert or SYSSEGV in the middle of the
fopen() branch.

libdivecomputer.c's 'dumpfile_name' and 'logfile_name' could
cause problems in that regard.

A possible fix for #411

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:53:05 +08:00
Lubomir I. Ivanov
3c794d0275 windows.c: Fix possible assert when passing NULL to *open()
On Win32 subsurface_fopen() can reach an assert in windows.c:
utf8_to_utf16(), if NULL is passed for 'path'.

Let's return NULL/-1 for some of the *open() functions in there.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:52:10 +08:00
Dirk Hohndel
409c2e9bcf Not everything can be done with the diveId
In commit c3fe1a9e9f ("Get rid of pointers to dive structures in the
UI") I was a bit too aggressive moving away from pointers to dives.

This is only needed for pointers that are held across operations that
could change the dive_table. I figured that it wouldn't hurt to get rid of
some more pointers as well, but it turns out I was wrong. The current dive
that we store in the Cylinder and Weight models can be a dive that isn't
in the dive_table at all: the multiEditEquipmentPlaceholder. And when
using the diveId we end up finding the original dive in the dive_table and
therefore modify the wrong structure.

This undoes two thirds of the above mentioned commit.

Reported-and-analyzed-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 22:10:41 +08:00
Dirk Hohndel
a8db19f548 Restructure overly agressive Q_ASSERT
Turns out this function can be called when there is no valid dive - so
only protect those parts that dereference the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 12:22:22 +08:00
Dirk Hohndel
c3fe1a9e9f Get rid of pointers to dive structures in the UI
The assumption that the pointer will keep pointing to a valid structure is
fundamentally flawed. And even if that is true today, it might change in
the future - just don't do it. Use the diveId instead.

The exception is when you own the structure and use it within one UI
interaction during which any way to change the dive_table is disabled
(e.g., while adding / editing a dive).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 12:10:19 +08:00
Dirk Hohndel
9c617534a0 When merging dives, keep dive ids in mind
We try to do the most reasonable thing. If you have an existing dive and
merge a just downloaded dive with it - the you want the existing id.
If you merge two consecutive dives, then the start of the merged dive is
the earlier of those two dives so we keep that id.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 12:03:49 +08:00
Dirk Hohndel
65e9fecd80 Add a unique id to every dive
This id is just held in memory. It's not supposed to be used for anything
but having a unique handle that represents a dive. Whenever you need to
remember a dive across an operation that might change the dive_table, this
is what you should hold on to, not a dive number, a dive pointer, or
anything like that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 12:02:42 +08:00
Tomaz Canabrava
ca391035f3 Setting dive as 'current' when restoring selection
Restoring the selection was not setting the selected dive as current, and
thus, breaking keyboard navigation.

Fixes #402

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 06:19:23 +08:00
Tomaz Canabrava
ddecc3b56a Add CaseInsensitivity to all of the completers.
Just one of the completers had Qt::CaseInsentitive set,
setting for all of them.

Fixes #400

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 06:19:04 +08:00
Dirk Hohndel
e783493f8a Use helper function to display mean depth with correct unit
In commit 528d0ea0e7 ("Print numerical value of mean depth") Miika once
again forgot the three non-metric countries on this planet... :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-06 21:02:19 +08:00
Miika Turkia
528d0ea0e7 Print numerical value of mean depth
This will print the numerical value of mean depth to the profile graph.

Fixes #405

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-06 20:50:58 +08:00
Miika Turkia
ffe53224a2 Fix typo
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-06 20:48:24 +08:00
Dirk Hohndel
04aa563cca Fix Uemis temperature conversion
In commit 3fd39a7a87 ("Remove some constants and use helpers instead")
Anton missed the fact that the Uemis gives temperatures in the handy unit
of "centi degree C". Now things work again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 16:00:28 -08:00
Dirk Hohndel
32d26b751a Parse localized weight units
We have the wonderful Qt string functions. Let's use them to make the code
simpler and easier to read.

Suggested-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 11:22:37 -08:00
Lubomir I. Ivanov
a30a0910b4 Maintab: prevent a segfault in the 'Equipment' tab
When a dive contains no cylinders, clicking the '+'
button could SIGSEGV if current_dive->dc.model is NULL.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 10:56:29 -08:00
Miika Turkia
a62f68e905 Rename menu entry for log import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 10:30:09 -08:00
Miika Turkia
b052b790df Refactoring import to DiveLogImportDialog
Changing the import stuff to DiveLogImport. Now we should have one
import function/dialog for importing divelogs instead of multiple menu
entries.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 10:30:08 -08:00
Miika Turkia
646c6ba58b Merging Import dialog
This patch merges import dialog with CSV import dialog. The aim is to
have only one import menu entry for log files. This menu entry pops up
an import dialog that has tabs for different types of imports (supported
dive logs and CSV configuration currently).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 10:30:06 -08:00
Tim Wootton
65eb86f854 MainTab location coordinates displayed in ISO6709 format
changes the location coordinates display in the main tab
 to use ISO6709(2008) Annex D suggested format.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 09:18:45 -08:00
Tim Wootton
41876f974e Allow location coordinates in ISO6709 format
Allows location coordinates to be entered in ISO6709(2008)
Annex D format. e.g. 50°40'46,461"N 95°48'26,533"W
see http://en.wikipedia.org/wiki/ISO_6709#Representation_at_the_human_interface_.28Annex_D.29
for suggested format.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 09:18:27 -08:00
Dirk Hohndel
7771158c82 Prepare for 4.0.1 release
Small updates to README, ReleaseNotes, user manual.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 03:18:59 -08:00
Dirk Hohndel
e06f9c4e88 Translation updates
As always, I am not the author, these are from Transifex.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03 02:52:42 -08:00
Dirk Hohndel
bc9b9287a4 Allow us to build for older versions of Mac OSX than we are running
This requires some serious hacking around with brew to get the libraries and
frameworks that we use to also be able to run on 10.5, but this is the part
that's needed in the Subsurface configuration.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02 22:45:25 -08:00
Linus Torvalds
4cce5df7e2 Fix imperial cylinder sizes in equipment tab
The imperial cylinder sizes are not just in cubic feet: they are in
cubic feet of gas at STP. So the imperial/metric difference is not
just about converting blindly from liters to cubic feet, you also have
to take the working pressure of the cylinder into account.

This was broken by commit f9b7c5dfe9 ("Make units in cells
consistant in CylindersModel"), because those poor sheltered Swedish
people have never had to work with the wondrous imperial cylinder
sizing, and think that units should make _sense_. Hah.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02 22:40:50 -08:00
Linus Torvalds
c49d3885f5 Allow the user to specify weight units explicitly
Instead of always assuming that all numbers are in the users locale
weight units, allow the user to say "kg" or "lbs" explicitly.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02 21:17:51 -08:00
Linus Torvalds
cb53a78674 Make our 'ascii_strtod()' helper more generic
We'll want to do sane parsing of strings, but the C library makes it
hard to handle user input sanely and the Qt toDouble() function
interface was designed by a retarded chipmunk.

So just extend our existing hacky "ascii_strtod()" to allow a more
generic interface.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02 21:17:41 -08:00
Dirk Hohndel
5511a0e14e Ignore units when entering values for equipment
Note that this is IMHO the wrong fix. Because we shouldn't just ignore the
units, we should do correct conversions.

Before this patch, if the user is in metric mode and then types in 4.5kg
or 10lbs for a weight, Subsurface ignores the entry and throws it away.
Very much not the expected behavior.

With this patch Subsurface will take the value, but ignore the unit and
assume that the user meant kg (since it's in metric mode). Still not
really the expected behavior for 10lbs (which is now 10kg), but if the
user typed 4.5kg (which admittedly is much more likely), then with this
change Subsurface will do the right thing.

Fixes #395

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02 09:12:32 -08:00
Rodrigo Severo
2abd06e5fd Test dive for odd pressure profile
When near the surface the pressure doesn't change - and then there is a
sudden drop at the end.

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-01 09:48:15 -08:00
Rodrigo Severo
763c64d0da Typos on comments
Fixing 2 typos on comments.

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-01 09:44:51 -08:00
Dirk Hohndel
dcc143ae4f More translation updates
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-29 10:57:03 -08:00
Dirk Hohndel
33d6cc711f Fixed typo
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-29 10:55:48 -08:00
Dirk Hohndel
db73177936 Add simple glossary
This is mostly for translators

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-29 10:34:12 -08:00
Dirk Hohndel
f79cc7bd91 Fix typo
Reported-by: Peter Konings <peter.l.e.konings@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-29 09:20:26 -08:00
Dirk Hohndel
6082ddb1d5 Translation updates
As usual, I am not the author, just pulling them from Transifex.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-29 09:19:35 -08:00