Remove unused structure member

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: don't do unnecessary work on empty dive plans

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: remove check for empty diveplan

This was introduced in commit fc1336107930 ("Don't crash if we try to save
a empty plan") - but it doesn't seem to make any sense. It is perfectly
reasonable for the diveplan to have no datapoints at this spot - we are
just about to call createTemporaryPlan() which will fill those datapoints
from the mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: don't recreate the dive while cleaning up the widgets

Otherwise the change to the Cylinder widget would trigger a recreation of
the dive in an inconsistent state.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Allow editing segment duration. This shifts all following waypoints.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'latest'
Planner: look harder to find the right gas

Silly bug - while we normally fill the cylinders in a tight group with no
"null" cylinders in the middle, since we copy from an existing dive and
since that may end up with an odd sequence of cylinders, we need to
continue looking at ALL cylinders and not stop with the first one that's
empty.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: wild guess attempt to fix a crash on Mac

Staring at the stack trace it seems that it gets into an infinite
recursion when trying to recalculate after being alerted to a change on
the ruler. I cannot recreate this here (not on Linux, not on Mac), but
here's a random attempt to prevent the issue: simply refuse to recalculate
the ruler while in Add or Plan mode.

Crude, but might show us if this really is the issue. Otherwise it's easy
enough to revert this change. The qDebug() in there should tell us if
people on a Mac do indeed see this even without moving the ruler around in
Add or Plan mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: add dive plan output area that replaces dive list

When switching to / from plan mode, we switch to show either the dive plan
detail widget, or the dive list widget.

So far this widget does nothing. This just makes sure it's there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: show the plan notes in the new widget

That was easy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: don't include the disclaimer in the dive plan detail widget

We want the disclaimer in the final dive that can be printed, but it's
distracting when shown while planning the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Revert "Show the calculated deco stops in the planner table"

This reverts commit 7d42b53bba235894668ed1f2da3f5d17cd97b9c5.

With the addition of the dive plan details widget we no longer want to
show the deco points in the dive planner points table.

Conflicts:
	qt-ui/diveplanner.cpp
Planner: add warning if the plan consumes more gas than provided

If we have size information including working pressure for a cylinder, we
already track the expected pressure at each way point - this way we can
also alert the user if more gas is consumed than is available in the
cylinder.

This does not include sound planning strategies like "rule of thirds". It
simply assumes that you won't be able to breathe down the cylinder past
about 10bar (using 0 as cutoff seemed silly).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: more fixes for gas tracking

Gas switches are now for the current segment, not for the next.

We can only track gas for cylinders for which we have size / working
pressure information. Print a warning for others.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: track gas used even if we don't have a real cylinder

We tracked gas used by simulating a dive with a cylinder - but for that we
need a cylinder size and working pressure. If the user just enters a gas
but no cylinder data (likely in order to figure out how much gas is used
so that she then can pick a big enough cylinder), we didn't show any gas
consumption.

It kinda sucks to add another member to the cylinder structure, but this
seemed far more reasonable then some other, global structure that
independently tracks gas usage. This just seemed to make sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: correctly track gas used

This part of the algorithm was off as part of it (but not all of it -
crazy, I know) assumed the old semantic for gas changes where the new gas
was introduced at the end of the segment and not at the beginning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Encapsulate the horrid gas encoding in gas change events

We should never pass permille values around as integers. And we shouldn't
have to decode the stupid value in more than one place.

This doesn't tackle all the places where we access O2 and He "too early"
and should instead keep passing around a gaxmix. But it's a first step.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove the .used member of the cylinder structure

Instead calculate this information on the fly, taking into account all
dive computers on the dive in questions.

There is one wrinkle to this - previously we abused the '.used' member to
make sure that a manually added cylinder didn't disappear the moment it
was added (think of the workflow: you add a cylinder, then you add a gas
change to that cylinder -> right after you add it it is unused and would
not be shown).

I am thinking that we might have to add the "manually_added" property to
the properties that we store in XML / git.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use proper types

This is step one of many to use gasmix instead of int o2/he.
Right now some of these changes look ridiculous because after changing a
few lines we immediately go back to o2 = get_o2(gas). The reason is that I
wanted to convert a hand full of functions at a time. So in this commit I
only change validate_gas(), get_gas_from_events() and get_gasidx() to use
a struct gasmix instead of int o2, int he.

This state builds and survived some mild testing. Let's continue on top of
that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Next step to using gasmix instead of o2/he

This changes the divedatapoints and functions that deal with them.

It changes plan_add_segment(), create_dp(), gasToStr(), and tankInUse() to
consume gasmix instead of o2/he.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>