Dive list: move trip selection / deselection logic to divelist.c

This is core logic, not UI code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive list: work around odd problem with selections

According to the documentation clearSelection() should emit
selectionChanged() - but I can verify in the debugger that sometimes this
doesn't appear to happen - consequently our notion of what's selected gets
confused.

To work around this, after calling clearSelection() we simply manuall
deselect all dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive list: move trip merging logic into divelist.c

This also fixes a couple of issues with the existing code:
- removes a memory leak
- treats null and "" the same

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Rename the export dialog

Give the export dialog a better name than just dialog.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correctly implement multi dive selection

The old code had several issues. It broke the synchronization between
dive->select and Qt selected status and worse, it would partially unselect
previously selected dives when called.

This patch, however, causes the selection via the map to be glacially slow
because it forces a redraw of every single selected profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Speed up the multi dive selection

Dirk's code in commit a3d300ca919d ("Correctly implement multi dive
selection") had a major flaw - it kept redrawing the selected dives
one after another. Not what we need. So this fixes this up so that it
doesn't take more than a sec to select all the dives that are on the same
part of the click on the globe. I've achieved this by creating a boolean '
dontEmitDiveChanged and sending the signal only if this flag is false.

The reason that we can't simply remove the emit from the selectionChanged
is because the selectionChanged is what we have when we click on the
diveList, if we removed this from there, nothing will happen upon
selection.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add location and max depth to world map export

From fdf157bb4db042e63f215607b284663f606bd98c Mon Sep 17 00:00:00 2001
From: Rick Walsh <rickmwalsh@gmail.com>
Date: Sun, 25 May 2014 14:57:36 +1200
Subject: [PATCH] Add location and max depth to world map export

Adds location name and maximum depth to the exported world map html file.
Minor formatting changes to exported text for consistency and clarity.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>

From fdf157bb4db042e63f215607b284663f606bd98c Mon Sep 17 00:00:00 2001
From: Rick Walsh <rickmwalsh@gmail.com>
Date: Sun, 25 May 2014 14:57:36 +1200
Subject: [PATCH] Add location and max depth to world map export

Adds location name and maximum depth to the exported world map html file.
Minor formatting changes to exported text for consistency and clarity.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reenamble 'Delete Dive Point' on the planer / add

Just removed an #if 0

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reenables the air edition and deletion of handlers on the planner/add

Only a tiny bit of poke around the contextMenuEvent - the events
of the planner are dealt by the QGraphicsItem, and this makes the
logic pretty easy to follow. :)

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

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Location must be quoted on worldmap export

User supplied text fields must be quoted on worldmap export. Without
quoting the HTML is broken e.g. with location "Angel's Window"

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use user preferred units on worldmap export

We should use the temperature units preferred by the user when exporting
dive info on Worldmap.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Localize worldmap export

Call the translation functions for text strings when exporting the
worldmap to allow localized exports.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive list: remember the current sort colum

Silly bug. We never actually remembered our current sort column when
changing the sort order.

See #518

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Move mod calculations to a separate helper

We use mod calculations on multiple places, so make a separate helper
from it with proper types.

The "clumsiness" of defining a local variable to pass into the function
and out from it comes from the discrepancies in how c and c++ handles
initializations of variables in a struct.

Thanks goes to Tiago and Linus for pointing me in the right direction.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive list: don't reset column width when reloading

We set the column width in the dive list widget when we create that
widget, based on what is in the settings. And we save the current column
width back to the settings when we destroy that widget (so if Subsurface
is shut down correctly and Qt actually gets to run the destructor but not
when someone kills the program).

That means that if we recreate the dive list at any point while Subsurface
is running (and we do that a lot when you manipulate your dive list in any
way shape or form), any changes to the column widths are lost.
DiveListView::reload() explicitly calls setupUi() which reads the column
widths back from the settings - but changes made to the columns aren't
saved to the settings until we destroy the widget...

I see no reason why reload() should call setupUi(), so I'm removing that
call. Let's hope this doesn't break anything else.

Fixes #518

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive list: make saving / restoring column widths actually work

It's a testament to how much I mess around with things that I hadn't
noticed that saving the column width doesn't actually work. Or actually,
saving them worked, loading them back failed as it was done too early and
the setColumnWidth() calls had no effect - and so the next time we quit
subsurface, the default width of 100 was written over all the saved
values.

This seems like an incredible hack but it has the advantage of actually
working. I look forward to someone with better insides into the inner
workings of Qt to properly fix this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use gas_mod and fix fpe

When removing o2 from a gas, eg setting it to "", air, this code would
raise a nice fpe. Fix that by using gas_mod instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Rework slot to quiet down Qt5 warning

Qt5 got confused about this slot. This does the same as previously but
gets Qt5 happy.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use get_o2() and get_he() instead of accessing permilles directly

This gets rid of problems with air.

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