Dive list: use helper function when restoring selection

Looping over the individual dives will be very slow if there are many of
them, as the profile will try to render each of them in succession.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: prevent crash when canceling plan with existing dive list

There is still something seriously wrong here.
For now let's just not restore the selection and at least this prevents us
from crashing. But I still don't understand why it crashes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: really fix crash after aborting planner

Duh. We had to reload the list (and make sure the internal data structures
are recreated as well) before restoring the selection.

I also switched to simply accessing the widget directly, instead of via
the dive_list() call.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Planner: set up a cylinder, even if no current dive is selected

If there was no current dive we didn't set up any cylinder at all which
was a bit awkward as we use AIR but have no cylinder corresponding to it,
which breaks assumptions elsewhere.

Instead we use either the default cylinder or make one up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Move code from the Planner that doesn't belongs there.

Moved the connections between DivePlannerPointsModel and
MainWindow from inside the Planner class to the MainWindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix crash on adding / removing a dives from add menu

This patch removes some inconsistencies that were happening on the add
dive / cancel actions. a bit of legacy code from the old system was still
in, which made things quite...  EXPLOSIVE.

This fixes restoring the selection only if we have a selection and not
deleting the temporary dive twice.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix edition of manually added dives.

This patch correctly sets the state of the planner to "NOTHING"
after trying to edit a manually added dive.

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