'Cancel' action Cancels editing Cylinders.

Made the default 'Cancel' action correctly cancel
the cylinder edition. This is needed only because
we bypassed the default behavior on Qt that took
care of this, because we wanted to have more control
on how the view would update the items accordingly
with wich one of the cylinders were selected
on the edition pane - the pressure and size of the
cylinders needed to have it's data set, but the Qt
Model/View system *thinks* that cancel-edition is
simply 'do not commit the edition data, then.' wich
would not work with us, because we passed the strange
data already. So, I created a backup data that serves
us very well. When the user cancels, this backup data
is added back on the cylinder, making everything as
it was before.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Added the code to revert Weigths when user cancels edition

This is a follow up commit to the previous one that
enabled cancel for cylinders, everything in the commit
log for the cylinders also applyes here.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fixes incorrect editing policies.

The Working Press didn't correctly updated when there was a 'bar'
or 'psi' in the string ( and that was defalt behaviour );

The o2 didn't correctly updated when there was a '%' on the string
(and that was default behaviour ),

The He didn't correctly updated when there was a '%' on the string,
and that was also default behavior.

Now all of them correctly updates.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fix crash in DiveComputerList::addDC() when importing from DM4.

DiveComputerList::getExact() created a temporary QList with the
DiveComputerNodes matching a specific model. A pointer to a node in the
list was returned, which becomes invalid when the list goes out of scope
and gets destroyed. Causing a crash when the model strings are compared
later.

Instead of using contains() and creating a temporary list, we can just
use an iterator, which should be both faster and safer.

The crash is easy to trigger with DM4 imports, but can probably be
triggered in other cases too.

Similar problem with DiveComputerList::get().

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Support more than one event of the same type in Qt tooltip.

Since the tooltip text was used as key in the map, two events of the
same type, close to eachother, would cause one of them to not be
removed.

Since ToolTip::removeToolTip() isn't used, we don't need a QMap and can
use a QList instead, so all tooltips are properly cleared.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix " begin" and " end" for events in plot.

QObject::tr() has source string as first argument and disambiguation as
second argument. Currently the events shows "Starts with space!" instead
of " begin" or " end" after the event name.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Print: improve table printing by using QTableView

The current QTextDocument implementation is slow due to
HTML parsing. By using QTableView with QAbstractTableModel
we boost the performance of the table print drastically.
This patch completely replaces the old solution.

There is a hidden QTableView widget which is populated
with all data and rendered using a QPainter attached to
the printer device.

A couple of new classes are added in models.h/cpp
that handle the table print model and these are then used
in printlayout.h/cpp.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Clean up code to remove false messages about errors in Eclipse

Imported the subsurface project into Eclipse to try and pull apart
how it all works together. Added an include for profile.h and some
brackets around a condition, but didn't make any functional changes
(I hope). These 2 changes should be purely cosmetic.

Signed-off-by: Benjamin Fogel <benjaminfogel@yahoo.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Delte the temporary dive from the divelist after calculating deco.

This bug manifested itself as too long deco obligation when moving
waypoints to later and then back to earlier times as all intermedite
versions were created as dives in the divelist (and the saturation of
these "previous dives" was taken into account.

It is not entirely clear to me how the dive will be permanently added to
the divelist once ok is pressed: One could in createDecoStops allocate
struct dive from the heap rather than from the stack and return a pointer
to it and which is then added to the dive list upon pressing ok.

[Dirk Hohndel: add include file to make this compile]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Crude hack to stop the build from failing without asciidoc

This could be made much more elegant. For now it serves its purpose.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
ifdef out includes when we build without gtk

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use maxx from graphics context for time calculation.

Fixes #128.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Makes the 'auto' edition behave in a better way.

This patch makes the auto editon behave in a better way,
now you can scroll the notes widget without marking it as
editable, and also adds a bit of code cleanup, and a better
logic for editing the other widgets.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fixes showing the labels of divemaster and buddy after a trip selection

This patches fixes showing back the labels 'Dive master' and 'Buddy'
after a trip selection  was done, then back to single dive selection.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Added classes to handle the Completion of Dive Editions.

Added classes to handle the completion of dive editions, the
classes are BuddyCompletionModel, DiveMasterCompletionModel,
SuitCompletionModel and LocationCompletionModel, thanks to
plain old C macros, code got really small. and I hope the
logic is better than the Gtk version. :)
Now next step is to integrate it to the Ui. shouldn't be hard.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Added completion for buddy, divemaster, location and suit.

Added completion for buddy, divemaster, location and suit.
The completions uses some models that I created in the last
commit - everytime that a divelog file is loaded, it creates
a list of completion items.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fixed a bug where the auto-completion would not work via commandline.

Fixed a bug where the auto-completion would not work via command
line, I fixed it by reloading the information of dives when a
dive file is open via command line or via UI.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Compile fix

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix for double-rendering, double selection and other annoyances.

This patch fixes a thing that I run into when trying to implement
the multi-edition system. Whenever a dive was selected, via mouse
or keyboard, it had two stages: first, it would select the previous
and the current ( and thus, render the profile of the current) and
then whould release the previous and select the current again ( and
thus, rerendering the profile again, plus a few other things. )
With the multi-edition system this caused a more severe bug, since
the edition of the dives is directly applied as soon as the text fields
changes, as soon as we selected any dive on the list, the 'before' dive
would be modified by the 'current'. This patch fixes this - but since it's
just a 'code removal' patch, this can led to bad things in the future,
I tested it quite a bit, but didn't found anything, no regression.
*fingers crossed.*

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Enable Multi Dive Editing.

This patch enables multi dive editing on the selected
dives. It's a bit of big patch where I reworked how it
worked since it was written just for a single dive.
this means that this can introduce bugs - I'v tested it
quite a bit but a thing could slip thru my fingers. :)

How this is supposed to work:

Select a few dives that you want ( one or more ) then
click on the field that you wanna edit / multi edit, and
press 'accept'. *only* the edited field will be modified
thru all dives.

Next patch - I'll change the bg color of the edited fields.A

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