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>
The Qt model sorting for the dive date was using a unsigned number,
which doesn't work for dates before 1970.
Also, the dive date parsing got the year 1900 wrong. Not that we really
care, because other parts of date handling will screw up with any date
before the year 1904. So if you claim to be diving before 1904, you get
basically random behavior.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Use the function in every place instead of once using it and once copying the code again.
No functional change.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
It's not too clever to give 0 a special meaning (as here:
use same gas as for previous leg) when 0 is a legitimate
value.
This should solve Willem's gas disappearance problem when
reediting a dive in the planner.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
In the cylinder table, the last column ("use") always showed
OC-GAS. Editing was enabled, but the user had to guess to enter
a small integer meaning dilluent or CCR oxygen cylingder. I guess,
nobody has ever done that.
This patch makes this column clickable. A click toggles if the cylinder
is used for planning or not. This wait it is much easier to investigate
the consequences of gas loss on a plan.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Gas switches appear as special samples with zero or one second duration.
Those can be confusing when they appear as zero duration in the dive plan
when replanning, so better suppress theose.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This reverts commit adaeb506b7.
commit a8e8d56ec0 ("Tweak cylinder equipment tooltips") does a much
better job allowing the user to know the true volume of the cylinder
(given the gas entered) and clutters the UI a lot less.
While playing around with the current subsurface, I realized that while we
give the gas volume and Z factor for the beginning/end pressures in the
newly added tooltips, there is no way to actually see that same
information for the working pressure.
So if you have filled in cylinder type information, but don't have any
actual gas usage information, there will be no cylinder tooltips at all.
But you might still want to know what the actual volume for a particular
cylinder is, and what the Z value for that working pressure is.
So this tweaks the tool-tips a bit.
When mousing over the pressure fields (ie "working pressure", "start" and
"end"), it now always gives the cylinder gas volume and Z factor for that
pressure, so for example on an AL72 that has a working pressure of 3000
psi and that contains air the tooltip will say:
69 cuft, Z=1.040
when you mouse over the working pressure field (that's obviously with
imperial units, in metric you'll see liters of gas).
When mousing over the type/size field, it gives the used gas amounts, ie
something like this:
37 cuft (82 cuft -> 45 cuft)
but if the cylinder doesn't have starting/ending pressures (and thus no
used gas information), this patch will make subsurface show the working
pressure data instead, so that you at least get something.
This all seems more useful than what my first version gave.
NOTE! This makes commit adaeb506b7 ("Show both the nominal and "real"
size for an imperial cylinder") kind of pointless. You now see the real
size in the tooltip when you mouse over the size, and now it actually
works both for imperial and metric people, so the tooltip is in many ways
the better model.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds tooltips for the equipment tab for each cylinder, showing the
amount of gas used.
When you mouse over the size and working pressure fields, the tooltip will
show the amount of gas used (along with start and end gas volumes). And
when you mouse over the start and end pressures, it will show the start
and end gas volumes, and the Z factor used.
I started doing this because of the gas volume questions in the last day
or two (and a few from a few weeks ago). When even Robert Helling starts
wondering about the effects of compressibility on the SAC calculation, our
numbers are clearly too opaque.
With these tooltips, at least you can see what went into the used gas
calculations, instead of having to add debugging options to print out Z
factors.
[ This patch also adds a "rint()" to get the rounding right in the
gas_volume() function. Although rounding to the nearst milliliter
really doesn't matter, it's the right thing to do after doing FP
calculations ;^]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
By using SettingsObjectWrapper, the planner settings can be saved and restored
correctly
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Please apply this patch on top of the previous patch with the same title.
1) Provide icons with white margin to look more like photos
2) Optimise code, following Robert's suggestions.
3) Column heading for photos column is now: Photos. This takes up extra
horizontal space but makes the user interface more understandable.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
1) Add an extra column to dive list, just left of Locality field.
2) For each dive, give summary of photos as follows:
i) no photos: no icon in that column
ii) photos taken during dive: show icon of fish
iii) photos taken before/after dive: show icon of sun
iv) photos taken during as well as before/after dive: show
icon with both fish and sun
3) Provide information for the sort operation to work on
this column of the dive list.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This can happen when the user asks to replan a dive that
was imported from CSV.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Call GasSelectionModel::instance()->repopulate() when creating the initial
simple dive. Without this call, the gas selection dropdown list does not work
in the DivePLannerPointsModel table until the cylinders table has been edited.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Separate the VPM-B conservatism preference into diveplan.vpmb_conservatism for
planning dives and prefs.vpmb_conservatism for profile ceiling display of
saved dives.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Subsurface uses "local time" which in particular means we never
display time zone information to the user. The user (and our file
format) only sees times like 5pm or 17:00. A better name than
local time (which could mean "local at the dive spot) would
be "watch time", the time displayed by the diver's watch when
she entered the water.
Internally, we store times as time_t, seconds since Jan 1 1970 0:00
UTC. Our convention for conversion between 5pm and time_t as always
been to treat 5pm as if it were UTC.
Then confusion arose since Qt's QDateTime (which is tied to UI elements
like QTimeEdit and similar) is time zone aware and by default assumes
the system time zone. So when we set a QDateTime to 5pm and then later
convert it to time_t we have to take care about the difference between
UTC and the system time zone.
This patch unifies our solution to this problem: With it, we set all
QDateTime's time zone to UTC. This means we don't have to correct for
a time zone anymore when converting to time_t (note, however, the
signedness issue: Qt's idea of time_t is broken since it assumes it
to be unsigned thus not allowing for dates before 1970. Better use the
millisecont variants).
We only need to be careful about time zones when using the current time.
With this convention, when assigning the current time to a QDateTime, we
need to shift for the time zone since its value in UTC should actually be
the watch time of the user who is most likely used to the system time zone.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit b1ed04a means that DivePlannerPointsModel::rememberTanks() and related
functions and variables are no longer required
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit aa1446bed2 ("Make filters work again in master") makes filters
work again for the desktop app, but breaks building Subsurface-mobile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since 6cd711a1 filters don't work. This went unnoticed because the
commit wasn't applied on v4.5-branch.
Partially reverting it makes filters work again.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add option to calculate the best mix portion of O2 and He for the dive's max
depth if the user enters * in the MOD and MND cylinder fields. Gas portions
are automatically recalculated if the max depth of the dive changes.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The switch depth of a decompression gas is its MOD. By renaming the heading to
"Deco MOD", it is more clearly distinguished from the bottom MOD, and it is
more obvious how they relate to the Bottom pO2 and Deco pO2 preferences.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adds fields to the planner cylinder model for maximum operating depth (MOD)
for a bottom mix gas, and maximum narcotic depth (MND). Fields are read/write,
so changing MOD changes %O2 and vice-versa. Changing MND changes %He and
vice-versa.
When setting MOD directly, the %O2 is truncated (rounded down) to an integer,
which re-calculates the MOD, which is sometimes a few metres greater than the
input depth. This is desireable behaviour, as the rounding is conservative.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fix is reasonably straightforward when the divedatapoint structure stores
the cylinder rather than gasmix.
Fixes#970
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
This allows calculation and selection of best mix in the planner cylinder
entry, by entering the gas depth, followed by "b" for best (trimix) mix, or
"bn" for best nitrox mix.
The UI is not intuitive, but it is quick and easy. At the very least, it
should be documented.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the value for "use" is negative or larger than the number of
elements in "enum cylinderuse", later CylindersModel::data() can
request a string in the lines of cylinderuse_text[cyl->cylinder_use],
which can SIGSEGV.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Most of the time we are adding all the dives, so do this in a single model
operation. This makes the case when adding a single dive (in the undo delete
function) slightly more complicated, but that seems totally worth it for the
speedup in the common case.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
In the planner, for recreational mode, there is a setting indicating
the pressure at which the diver should be back at the surface. This
pressure was hardcoded to bar.
Fixes#1027
[Dirk Hohndel: small modifications, more reasonable step for psi,
more reasonable maxima]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is in the context of the iOS port and shouldn't impact any of the
other builds.
[Dirk Hohndel: refactored the iOS patches]
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Oops, I forgot to take the sort model on top of the model into account.
Now everything should stay consistent - ListView order when accessed from
QML, but internal order when accessing the underlying array.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The dive list might contain dives in the future, don't add the new dive to
then end but instead add it at the correct spot in the list
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>