Much, much smarter way of finding the Tags

The old way manually implemented a parser, where it could simply call a
regexp (or, in my case, a QChar) that will split the QString into many, to
find the beginning and end of the strings on the tags.

This patch also fixes a Qt5 off-by-one bug on the tag Visualization.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive add: fix crash when canceling

We need to reset the editMode right away, otherwise all the changes to the
input field (when resetting the data after the user cancels) will cause
Subsurface to crash as current_dive will temporarily be NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive add: remove duplicate code

This is already done when we create the fake dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive planner: remember the selection before new dives get handled

On an empty dive list we would remember the new dive (which gets
auto-selected since it's the only dive) and then crash when we try to
restore that selection after cancel (in which case that new dive is gone).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive planner: remove the fake dive earlier on cancel

This way it's already gone from the dive list before it gets reprocessed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Try to clear out the profile when dive list is empty

This only partially works. If I start from an empty dive list, plan a
dive, then abort, there are still leftovers in the profile widget.
Hitting Ctrl-W clears that out. But it just runs the same cleanUpEmpty()
again...

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

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fixes showing the Empty Profile when Add / Plan dive is cancelled.

for some reason the next selected dive is NULL after cancelling the
plan. I'm investigating.

This patch fixes the show of the empty profile and it also untangles
some parts of the code, keeping the mainwindow where it should belong
: the mainwindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
[GSoC] Start DownloadFromDiveComputerClass

Right now this class is an empty shell, but I will build up
on it as I go along.

Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>