If the user clicks "Accept" when no dives were downloaded we would otherwise
dereference unitialized memory.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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#361Fixes#362
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
... 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>
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>
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>
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>
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>