Commit graph

249 commits

Author SHA1 Message Date
Dirk Hohndel
f4f42a0b97 Don't crash trying to record zero dives
If the user clicks "Accept" when no dives were downloaded we would otherwise
dereference unitialized memory.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-29 15:10:42 -07:00
Dirk Hohndel
29741f0ed2 Avoid Q_ASSERT with debug build of Qt
I don't know why we are setting lastIndex to -1. That seems odd.
But for now this workaround will have to do.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-24 12:06:19 -07:00
Dirk Hohndel
77a3e6ac70 QML UI: clear the previous list when downloading
When you start a new session with Download from DC, clear out the table
from the last attempt before adding the page.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-16 01:22:44 -07:00
Lubomir I. Ivanov
27deb317b0 tankinfomodel.cpp: clamp row index to [0 - MAX_TANK_INFO]
MAX_TANK_INFO is a new macro in dive.h to define the
maximum number of tank_info_t objects.

TankInfoModel's data() and setData() now check for valid
row indexes before accessing the tank_info[] array directly.

Without this patch TankInfoMode::data() can cause a SIGSEGV.

Reported-by: Pedro Neves <nevesdiver@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-15 14:48:49 -07:00
Miika Turkia
22e40063f1 Download dialog showed time incorrectly
The used time format was h:mh: i.e. 1:16h:
This patch gets rid of the colon after the hour indicator.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-06-12 07:09:11 -07:00
Dirk Hohndel
5bc91f00c5 Fix a few warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 15:46:26 -07:00
Dirk Hohndel
2d8489158d Make message handler write to console as well
This way we can see the debug output even if the app is hung or crashes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 13:55:41 -07:00
Tomaz Canabrava
0ea6f13891 Add a messageHandler to take care of qDebug & friends on QML
all qDebug / qCDebug and friends now will be properly
logged into developer -> log, on QML.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 13:55:41 -07:00
Tomaz Canabrava
03e771066b QML UI: show selection box on the Download from DC list
QML and C++ model don't interact too much, a new Rule
should be created and used on the QML

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-04 07:11:01 -07:00
Tomaz Canabrava
52e07a6306 QML UI: select / unselect dive by clicking on it
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 12:01:02 -07:00
Dirk Hohndel
9bea9fcdb7 Fix typo
Don't manually edit diffs and then commit without compile test...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 10:49:23 -07:00
Dirk Hohndel
dd3edb0dcd QML UI: process freshly downloaded dives
This way they get correctly prepared and derived data fields
get populated. For example, the dive number gets updated if
these are indeed the newest dives.

Fixes #408

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 10:35:21 -07:00
Dirk Hohndel
57d01701aa Don't leak memory on downloaded dives not picked
I noticed this in the mobile download code when fixing an unrelated
issue - and then realized that the same was true in the desktop app
as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 10:35:21 -07:00
Jan Mulder
8d42d33f93 mobile: Prevent tripping assert on empty BT download
When (with mobile on desktop) loading from DC is called and the dive computer
to connect to is not in download mode, the repopulate() function is called
with an empty dive table. This trips the assert (obviously, debug compile only) in
DiveImportedModel::setImportedDivesIndexes(). This simple fix makes things just
more robust.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-29 08:57:04 -07:00
Dirk Hohndel
3f0d21046e QML UI: add downloaded dives to dive list
This already takes into account which of those dives were selected.
Right now all we have is select all or none - this needs actual support
in the UI, but once that's there, it will just work (famous last words).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-28 11:54:33 -07:00
Tomaz Canabrava
38e24512b7 QML UI: add the Downloaded Dive Model
Still to do:
 - select the dives to save
 - record the downloaded dives

but download is already working. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:20 -07:00
Tomaz Canabrava
dec47e11cd Separate the download thread from the widget logic
This is important to not duplicate code for the Qml
view. Now the DownloadFromDiveComputer widget is mostly
free from important code (that has been upgraded to the
core folder), and I can start coding the QML interface.

There are still a few functions on the desktop widget
that will die so I can call them via the QML code later.

I also touched the location of a few globals (please, let's
stop using those) - because it was declared on the
desktop code and being used in the core.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:53:14 -07:00
Tomaz Canabrava
3c3f91dcb2 Move model code to models
This makes it easery to use it on Qml.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:46:01 -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
Robert C. Helling
7b18be2a50 Adopt planner state caching to new struct
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07: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
Dirk Hohndel
5372f12d8b Add SPDX header to Qt models
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Jan Mulder
12a59ef313 Correct divesite geocoding translation
See https://github.com/Subsurface-divelog/subsurface/issues/345. The
menues where not translated. The basis of this error is a simple
typo in core/taxonomy.c where the classname was mis-spelled in the
QT_TRANSLATE_NOOP. In addition, to pull and translate the strings
from C code, the normal tr() does not work, and the functionality
from the gettextfromc class is used.

Fixes: #345

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-26 05:34:40 -07:00
Stefan Fuchs
1e6f0231e6 Deal with additional line break in dive notes from planner
With current code when re-planning a dive the planner output in the
dive notes is always moved down by one line.
This fix avoids that this additional line break is added.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-24 08:35:49 -07:00
Robert C. Helling
dfe5092222 Identify user provided notes in plain text in replan
This is another attept at the problem if identifying a potentially
user supplied text in the dive notes upon replannig a dive.

It gets rid of the user visable position markers (*!* and ***) and
cirumvents problems with mark-up by first converting the old notes
to plan text (assuming that user only enters plain text in the notes
field as we do in other places as well). Then the automatically added
part is identified by locating the disclaimer in the text (if the user
edited/delted the disclaimer or changed langue in between it is her
problem to manually delete the old plan).

Everything from the disclaimer on is deleted and replaced by the new plan.

If the disclaimer is not found, the new plan is appended to the old notes.
This way we make sure no information gets automatically deleted.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-04-20 10:57:47 -07:00
Jan Mulder
abbb0a244d Handle CCR setpoint when replanning a dive
When replanning a dive, the setpoint information from the profile waypoints
were reset to 0, resulting in a dive that has a dive mode of CCR, but only with
OC legs in the profile. This is just wrong, and is corrected here. Notice
that there is no averaging involved (in the reduction of a replanned real
dive that has more than 100 waypoints) as is done for depth. This is just
fine for setpoint data.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-20 10:57:11 -07:00
Stefan Fuchs
a5d54b04a7 Handle notes from planner
New strategy to identify old planner output in notes when
replanning a dive: Text anchors ("*!*" and "***") added for planner output

For backwards compatibility: If there is no anchor but an old table
delete everything.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-16 07:42:32 -07:00
Stefan Fuchs
a19f9c22ce Last added dive planner point for correct lenght not always added
Don't add the last stop with addstop for correcting the lenght
of the dive if planner generated points can be removed when replanning.
Otherwise this will not be deleted when replanning a dive.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-16 07:40:45 -07:00
Robert C. Helling
1b744c7639 Always show notes when replanning
... as per popular request. Plus adding const keyword to constant
strings.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-28 13:31:45 -07:00
Robert C. Helling
eefa390e5f Handle notes in replan
Upon replanning a dive, we want to delete the old
dive plan in the notes and replace it with the actual.

This fixes a problem when we failed to detect the old plan due
to the deco model name appearing in the disclaimer that was used
as a marker for the notes.

This patch also adds translation markers for the deco model name strings..

Fixes #285

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-28 13:31:45 -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
Stefan Fuchs
d83449f3b5 Don't erroneously mark the cylinder pressure red - second try
Second attempt to do the thing with the red background color for cylinder
start and end pressure correctly. This now should cover all scenarios.

This rewrites and partitially reverts commit b8e044d

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-24 09:35:51 -07:00
Stefan Fuchs
8834fc0443 Correctly trigger update of cylinder table trash icons in planner
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-13 10:26:18 -07:00
Stefan Fuchs
ac52034778 Correct trash or trashforbidden icon and tooltip in cylinder table
Display the correct trash or trashforbidden icon and tooltip in the cylinder table.
This should fit together with if it is really possible to remove a cylinder.

Search for "same gas" based on used cylinders only. Otherwise one could remove
a used cylinder because there is an unused cylinder with same gas.

ToDo:
In planner update trash icon on change of planner points.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 16:01:53 -08:00
Stefan Fuchs
b11af5a1ce Add units (m or ft) for MOD and MND in cylinder table in planner
We do display the unit for "Gas change at" today so we should also display it for MOD and MND.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 16:01:53 -08:00
Dirk Hohndel
08284275e7 Merge branch 'master' of https://github.com/dje29/subsurface 2017-03-11 08:41:41 -08:00
Martin Měřinský
dcf2542215 Use abbreviations with dots. 2017-03-11 08:09:07 -08:00
Martin Měřinský
bdb83fd9b5 Use 'Temp.' for abbreviations. 2017-03-11 08:09:07 -08:00
Martin Měřinský
af219af9ba Cyl > Cylinder 2017-03-11 08:09:07 -08:00
Robert C. Helling
eae4bd82a5 Change type of divedatepoint.depth to depth_t
... for consistency, while we are at it.

There are still some internal depth variables which are ints
somebody might take a go at those.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-11 08:03:25 -08:00
Robert C. Helling
295b1b78d8 Make depth conversion work for negative depths
This is needed in the altitude pressure conversion as there
negative altitudes are possible (for diving in the netherlands
or the Dead Sea).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-11 08:03:25 -08:00
Stefan Fuchs
7f8c3592ce Minimum gas calculation - Calculations and UI parameters
Add minimum gas calculation to planner output.
Add the two UI parameters prefs.sacfactor and prefs.problemsolvingtime.
Connect UI signals and slots for recalculation of diveplan.

Disable minimum gas calculation if there was already a warning before.
If minimum gas result is larger then cylinder start pressure give warning message instead of result.

Add line break before pO2 warnings but only if warnings exist.

Signed-off-by: Joachim Ritter <jritter@bitsenke.de>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 08:01:35 -08:00
Stefan Fuchs
b8e044dee3 Don't erroneously mark the cylinder pressure red and set font italic
In the cylinder table today the cylinder start and end pressure fields
are marked red and the end pressure font is set to italic if cyl->end is 0.
But sometimes with planned dives there is no cyl->end but only cyl->sample_end.
This is taken into account now.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 07:27:18 -08:00
Stefan Fuchs
ab887e4438 Fix cyclinder table issue "workingpressure" in planner
Fixes the issue that the cylinder table in the planner is messed up after
changing the table header.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 07:27:18 -08: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
527c622c94 Don't clear plan when (re-) planning
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-05 12:12:49 -08:00
Dirk Hohndel
798965c10d Initialize cylinder index
Otherwise it's possible for an uninitialized value to be used
in addStop which can cause crashes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04 17:14:22 -08:00
Dirk Hohndel
f1c46927ef Ensure correct length of the created dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04 12:16:49 -08:00
Dirk Hohndel
3afc4528b3 Only honor drop stone mode when planning a dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04 12:16:49 -08:00
Dirk Hohndel
03eef5b0c2 Implement manual setting of depth
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-04 12:16:49 -08:00