Adds the code to make the dive list behave like tree or list

This code adds the possibility to make the DiveList behave
like a Tree or a List, depending on what layout is set.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Switch between Tree / list on column - click.

This patch adds support for switching Tree / List
while clicking on a column header. This triggers
a sad-painting bug on the list - I guess I'll have
to fix it too. I'd apreciate some help on it, tougth.
next: keep the selection.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Saves the selection to select it later.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Connect preferences to the rest of the code

The biggest problem here was that bool has different sizes in C and C++
code. So using this in a structure shared between the two sides wasn't a
smart idea.

Instead I went with 'short', but that caused problems with Qt being to
smart for its own good and not doing the right thing when dealing with
'boolean' settings and a short value. This may be something in the way I
implemented things (as I doubt that something this fundamental would be
broken) but the workaround implemented here (explicitly using 0 or 1
depending on the value of the boolean) seems to work.

I also decided to get rid of the confusion of where gflow/gfhigh are
floating point (0..1) and when they are integers (0..100). We now use
integers anywhere outside of deco.c.

I also applied some serious spelling corrections to the preferences
dialog's ui file.

Finally, this enables the code that selects which partial pressure graph
to show.

Still to do: font size, metric/imperial logic

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correctly enable partial pressure threshold entry in preferences

The initial state needs to reflect the value of the checkbox. Once the
dialog is run, there is a signal/slot connection in the .ui file that
keeps things in sync.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correct the ceiling preference handling

Added the red dc ceiling as preference option.
Hooked them all up together so the sub-preferences are enabled when the
master preference is set (for 3m and red ceiling).
Use the options in the profile plotting functions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add --version to command line options

Displays Subsurface and libdivecomputer versions.

Suggested-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix a mistake naming for the da_dk alias localisation

The country code is da, not dk.

Suggested-by: Sylvestre Ledru <sylvestre@debian.org>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix default zooming.

Set default zoom level only when at least one dive selected
and user have not changed it.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix message widget visibility.

Hide message widget when closing dive with no GPS coordinates.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'bug111' of https://github.com/tcanabrava/subsurface
Add a "sort role" for sorting the dive list

By default, sorting is done by the display role, but then we end up
sorting by the string we display, which is almost always the wrong thing.

So this adds a new "SORT_ROLE" that is used for sorting, and then the
data lookup can return the raw data we want to sort by.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reimplement the Sort method to change from Tree / List, and remember selection.

Things are working as they should, but I hit on -probably- a Qt bug
that makes painting on the table view a bit weird ( it only updates
the painting by moving the mouse around ). I'll try to fake the
mouse movements in a couple of commits after this one.
There's also a few columns that are not being correctly sorted,
probably something to do with the SortRole.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
More work on bug 111, Sorting works as it should.

Sorting is now working as it should, changing
from table to tree, keeping the selection from
table to tree ( but there's a regression on
tree to table conversion, I'll try to fix it
in the following commit. ).

this commit also cleans a lot of boilerplate
code that I wrote to bypass a graphics bug,
that I seem to have correctly fixed in this
version.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fixed the regression of selection not being stored from table to tree

This fixes the regression that I caused in the last commit,
where the selection was being correctly reestored from tree-to-table,
but it was incorrectly being restored from table-to-tree.

I also added a bit of speedup on the view while changing columns.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Code Cleanup.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Code layout changes

Tomaz convinced me (with help from Linus) that it might be a good idea
to go with the compacter "single line" case statements in some specific
instances where this makes the code much more compact and easier to
read.

While doing that I changed Linus' code to do 'retVal = ...; break;'
instead of just 'return ...;' - this is more consistent and makes
debugging a little easier.

And while doing all that, I also cleaned up divelistview.cpp a little bit.
And removed an unused variable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Ignore ui_* files

This makes using git from within QtCreator much easier.
Fix sorting by rating

In commit beb4ed38f264 ("Add a "sort role" for sorting the dive list")
Linus forgot to add a case for the rating value.

Now all columns sort correctly.

With this I think we can close the bug...

Fixes #111

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Stop building prefs.c

The only tiny function in there that was still needed seems to fit
nicely into main.c

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