move process_dives to the mainthread

Avoids a race condition.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Use the right event type

11 is SAMPLE_EVENT_GASCHANGE, and thats the one that doesn't contain any
He-part. The type where He and O2 is packed togeather is 25,
SAMPLE_EVENT_GASCHANGE2.

Left to implement is to figure out the type of the event when we read
the xml, so we can create the right type there.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only calculate with he when he is present in event

Old gasswitch events only contains O2, so don't look at he part when
the event doesn't contain a He part.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Show sample time in the mouseover.

This is really nice to have when looking at specific coutures of a dive
or events.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Destroy the main window before exiting the application

This ensures all widgets inside the window get destroyed too.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Show DiveNotes when program starts.

Equipment tab was opened by default, it should be DiveNotes
as per the old GTK version. this fixes that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Good deal of Code Cleanup for the maintab

Some cleanup was needed in the MainTab code for ages,
now the Edition / Cancel / Ok of the Notes tab is
way more intuitive on the code level.

This is needed to support multidive edition on the
Cylinders and Weigths too, since it's a bit more
complicated, I didn't want to start with a Spaguetti
Code.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Add a Warning icon on the changed tabs, for edition of dives.

Adds a Warning icon on the changed tabs, this is important as
usability, for you could change something on the 'notes' tab,
change the tab and did't realized that something was changed
( by forgotting or something ), then clicking on the cancel
button. so now there's a friendly reminder that you actually
changed something.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Added the Message and the Buttons on the Equipment Tab

Added the Message and the ok/cancel buttons on the Equipment
Tab, they don't control the Equipment edition yet, but already
does the same as the Notes one, Now I need to merge the other
part - the actuall Equipment Edition.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fix the annoying tab order issue in the notes tab

This had been driving me crazy for a while, finally figured out how to fix
it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use Planner dialog to add dive

Right now this is just calling the same code and setting a flag whether we
are planning or adding a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Rename createDecostops to drawProfile

After all, that's what the function does.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only calculate deco stops in planner mode

In add dive mode simply bring the diver safely back to the surface
(currently with a fixed ascent rate of 30ft/min (or 9m/min)).

We should make that rate configurable (for the planner as well as the dive
add function). Also, the dive add function should offer to automatically
include a safety stop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't show the planner widget when adding a dive

This looks like it might work, but since we keep recreating the dive, the
info entered in the info pane is actually lost. But it's a step in the
right direction.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix updateDiveInfo to clear coordinates when called with invalid dive

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Continous update of planner

Make the planner update its display continuously upon moving points
including deco. This appears fast enough on typical PCs. If this ends up
being to slow on some systems we may have to make it configurable.

[Dirk Hohndel: cleaned up the two patches and turned into one commit]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix unbalanced braces issues in dive.h

The compiler doesn't warn about this, but this looks better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fixes for gps coordinates handling.

Reset coordinates properly when clicking undo.

When auto-completing location, only copy coordinates if they have not
been manually edited.

Set the background to red if the gps coordinates won't change, e.g.
there is a parse error, the change is too small or only whitespace
changes.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Identify below floor event type properly.

This event is on when accumulating deco time. Once you reach the floor
deco time will start decreasing and the event will stop. Going below the
floor again will re-activate the event.

Also identify event type 13 in DM4 imports as airtime.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Hook up adding a dive

This gets things mostly right.

It creates a dive and uses the planner widget to create samples which are
copied into the dive. It fills in some reasonable defaults (DC model,
timestamp), but doesn't allow editing the timestamp (or the temperatures
and air pressure).

On accept the planner gets reset and the dive appears correctly in the
dive list.

Cancel still needs to be handled.

And I bet there are many subtle bugs lurking here and there. But it's a
start.

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