Rewrite show_location to use membuffer primitives

This simplifies the logic and doesn't rely on show_utf8 to print empty
blocks.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: Change when we recalculate deco

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: Implement ascend rate according to GUE standard procedures

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: Add waipoints when changing ascend rate in planner

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: show gas for the NEXT segment

For deco stops show the gas of the next segment in the table. In
recalculation remove old deco stops earlier.

In struct diveplan, the items are "segments" with a beginning, a duration,
and a gas. In contrast, the UI of the planner uses "waypoints" which are
the boundaries between segments. It is conventional at least for deco
stops to display the gas of the _next_ segment in the runtime table (i.e.
the gas possibly to be switched to).

Furthermore, in addStop, the old deco stops have to be removed earlier as
otherwise a new waypoint later than a previous generated gas switch
inherits the gas of the old switch.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: Offer to discard the plan when Quit is triggered in planner.

Upon pressing Ctrl-Q or the window close button a modal dialog was shown
to remind the user that the planned dive is not saved.  This patch
triggers the "cancel plan" action before trying to quit.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix building with NO_MARBLE after prototype change

4243fcb915 ("Dont set coordinates when two or more dives are selected")
Changed how the prototypes in GlobeGPS looks. This aligns NO_MARBLE
version of GlobeGPS with that.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove unnecessary include from dive.c

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use enum name instead of its int value.

SAMPLE_EVENT_GASCHANGE2 is the libdivecomputer name of the event.
Compare with that instead of its int value.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the used flag on cylinders in get_dive_gas

Now when we have a used flag on every cylinder that are set in
mark_used_tanks we can use it here.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When starting the planner, copy cylinders from currently selected dive.

This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
CodingStyle "to" "too" typo

Small typo in CodingStyle.
".. in this file to." should be "... in this file too."

Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Move unit related code to units.h

The units are used everywhere in the application, we don't really
need to include "dive.h" to be able to use unit conversion, so I
changed them to a new file. There is still a lot of non-dive stuff
in dive.h / c, I'll try to move more later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove old defines.

Those were from the ancient Gtk times where we hardcoded the white stars
and black stars as font glyphs instead of drawing them. get rid of it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correct the usage of std::string and QString

QStrings shouldn't be == "" to check for empty string, use .isEmpty()
QStrings shouldn't be != "" to check for non empty, use .size()
std::string shouldn't be cleared with = "", use .clear()

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Simplify code.

this is not necessary when you don't have a variable
that has the exact same name as the 'this->variable' name,

also, there's no need to check if a QString is empty
before trying to use the == on them.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
'Class' string is unecessary when using a Container.

pretty self explanatory, the 'class' keyword is unecessary
when defining things inside a Container, be it a QList,
QVector, QMap, QHahs or anything else.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When creating methods that pass QString, use const QString&

This removes unecessary creation and destruction of the object
making the code shine a bit more and be more fluffy. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
use for_each_dive instead of hand-written loop.

It's easyer to make a mistake in the loop insteaf of
using the currently correct one that's already written

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Prefix a method with 'dive_' because it should work only with dives

I'll probably add prefixes to functions to make it easier to find method
via autocomplete from the grep or interface helpers, do you wanna know all
the functions that works with a dive?  ask for the completion for dive_,
do you wanna know all the functions that works with a divelist? ask for
the completions on divelist_ or run grep -rIs divelist_ on the header
files.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>