Commit graph

41 commits

Author SHA1 Message Date
Stefan Fuchs
b109b51f7f Translate "more than n days" for surface interval
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-06-23 22:43:39 +09:00
Lubomir I. Ivanov
e7a7bd4de2 qthelper.cpp: leave lbs rounding to QString().arg() with 'f'
The following call in weight_string():
str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);

will make values in lbs larger or equal to 40 to have no fractional
part and be rounded to nearest, while values less than 40 will have one
decimal place.

fixes #412

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 16:03:38 -07:00
Stefan Fuchs
e6d884cf26 Creation of dive duration string and surface interval string
Update the function to create the dive duration string in a way that
it can be used also in info and stats tab and added some more flexibility.

Changed layout for <1h freedives to "0:05:35" (w/o units) or "5:35min"
(with units and :) or "5min 35sec" (with units with space).

Add a new function to create the surface interval string.

Completely remove old function get_time_string() and get_time_string_s().

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-26 15:50:52 -07:00
Miika Turkia
ccf916344b Include some extradata info on Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 21:36:50 -07:00
Dirk Hohndel
d7cf3408e5 Merge branch 'seabear-refactor'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-07 07:52:55 -07:00
Miika Turkia
d851549d9c Remove debug output
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 16:00:52 +03:00
Miika Turkia
221f67206b Make parsing of Seabear header more robust
This should work even if some header line is missing from some DC.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 15:53:35 +03:00
Miika Turkia
6e1c00078d Add dive mode support for Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 15:34:27 +03:00
Miika Turkia
cef56c6290 Import dive number from Seabear CSV file
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 14:19:58 +03:00
Miika Turkia
0dfa448d8c Refactor Seabear import
Moving the GUI independent Seabear import functionality to Subsurface
core. This will allow Robert to call it directly from download from DC.

Tested with H3 against released and daily versions of Subsurface. The
result differs somewhat, but it is actually fixing 2 bugs:
- Temperature was mis-interpreted previously
- Sample interval for a dive with 1 second interval was parsed
  incorrectly

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 13:53:52 +03:00
Miika Turkia
ab1813a445 Move intdup to qthelper
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 09:41:27 +03:00
Dirk Hohndel
92d24a2912 Consistently show dive duration based on preferences
We now respect the settings in the preferences and also only show
the duration as minutes and seconds if the dive is a free dive.

Fixes #361
Fixes #362

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-06 17:43:32 -07:00
Robert C. Helling
462797396b File selector should filter images we can actually handle.
So better ask Qt about image formats known to it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-06 08:07:16 -07:00
Dirk Hohndel
b368ecd5aa Add SPDX header to remaining core files
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Stefan Fuchs
c9c9b1b399 Add creation date and Subsurface version to planner output
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-06 18:29:11 -07:00
Jeremie Guichard
597539ce39 Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint

Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.

Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-24 09:39:25 -07:00
Jeremie Guichard
406e4287eb Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-08 14:04:17 +07:00
Dirk Hohndel
e9debdf281 Add helper to parse duration text
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04 12:16:49 -08:00
Robert C. Helling
dbd99f706e Many filenames are const strings
So we can use string constants for those

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-21 13:14:56 -08:00
Robert C. Helling
dc55ee4a23 Update exif.cpp from upstream
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-19 15:29:40 -08:00
Dirk Hohndel
1ab6e7fc8a Prevent crash on Mac when typing comma in GPS coordinates field
Our attempt to skip any white space after the comma causes an ASSERT (strangely
only on Macs).

This closes #158

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-14 09:09:58 -08:00
Robert C. Helling
935734100f Rename prefs.deco_mode to prefs.planner_deco_mode
This is to avoid confusion with planner.display_deco_mode.
When accessing the "current deco mode" use the decoMode()
helper function.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
bb4bf639c3 Fix deco_mode confusion
We have two prefernces determining the deco_mode (BUEHLMANN vs VPMB
vs RECREATIONAL): One for the planner (deco_mode) and one for
displaying dives (display_deco_mode). The former is set in the planner
settings while the latter is set in the preferences.

This patch clears up a confusion which of the two to use by introducing
a helper function that selects the correct variable.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
10b8bda662 Fix picture hashing logic for pictures on the web.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2016-12-30 19:43:00 +01:00
Tomaz Canabrava
27b4ef321a Correctly open the resource file
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-27 08:27:21 -08:00
Robert C. Helling
3e4ea9e084 Get rid of debug messages
...that managed to sneak in in a previous commit.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-26 13:09:05 -08:00
Robert C. Helling
1ab5db3726 Empty image hashes are not valid
I don't know how those arose in the first place, but an
empty QByteArray is never a valid hash value for an image. So
we should not store those in our translation tables and also
get rid of them when loading the tables from disk.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-04 05:37:16 +09:00
Dirk Hohndel
f4ca863a91 Correctly pick up the UI language from settings
While Linux can set the locale from the language text, Windows needs the
correct locale value (which makes more sense to use, anyway - that's why
we save it).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-22 22:07:42 -07:00
Dirk Hohndel
5fdbc1ffc3 Language preference: once we figure out the locale, remember it
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 12:40:30 -07:00
Dirk Hohndel
743f73e4a3 Don't look up the setting again
This caused us to do the wrong thing if the setting wasn't set at all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-20 12:38:23 -07:00
Tomaz Canabrava
0a6f6b4382 Settings update: Fix missing groups and Language initialization
There's one function named uiLanguage() that should return
the current uiLanguage() that subsurface is running, but
it actually sets a whole lot of preferences, I think
that the general idea of that function is okay, but it seems
broken for me.

still, I used it to load the correct language from the preferences
since it's what this function is currently doing right now.

Also, a lot of missing groups where added.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 22:37:15 -07:00
Tomaz Canabrava
9b2404fcb4 Settings update: Move loadPreferences out of qt-helper.cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Tomaz Canabrava
9299e3c42b Settings update: Correct comment
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:44 -07:00
Tomaz Canabrava
ee91002fdb Settings update: Remove unused include and add FIXME comment
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:44 -07:00
Miika Turkia
38a2db05c0 Include full year for trip on divelist
Having only the last 2 digits of the year is somewhat confusing as one
can easily think that to be the day. Thus it is more clear to use full
year for the trip header.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10 15:08:04 -07:00
Rick Walsh
b1ed04a7f4 Have divedatapoint store cylinder id instead of gasmix
Determining the correct cylinder index from a known gas mix can be
complicated, but it is trivial to look up the gasmix from the cylinder_t
structure.

It makes sense to remember which cylinder is being used. This simplifies
handling changing a cylinder's gas mix, either directly by the user, or
indirectly in the planner. It also permits tracking of multiple cylinders of
the same mix, e.g. independent twins / sidemount.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:07:25 -07:00
Rick Walsh
8acbeed555 Add some gas mix validation to the planner
A few basic rules for gas validation:
	We can't have <0%, or >100% of either O2 or He
	O2 + He must not be >100%
	Switch depth can't be <0%

This places limits on user-input values

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28 14:24:10 -07:00
Robert C. Helling
2e6588dc0e Protect access to image hash dictionaries with lock
Otherwise we step on our own feet when downloading several images,
like after import from divelogs.de with many linked images.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:08:20 -07:00
Linus Torvalds
56ed3f1c61 Fix Qt date interfaces for times before 1970
This seems to work around the crazy QDateTime::fromTime_t() problem in Qt.

It is *very* lightly tested. In fact, the only test is that "test0.xml"
change that is part of this patch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:07:41 -07:00
Linus Torvalds
ff8392da54 Remove unused and buggy get_cylinder_used_gas_string() function
It's good that this is unused, because it does the calculations wrong.

Due to the gas compressibility the gas use calculations should subtract
the gas_volume() values at the differing pressures, not the pressures
themselves.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 16:52:58 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.

And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.

This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:33:58 -07:00
Renamed from subsurface-core/qthelper.cpp (Browse further)