Commit graph

574 commits

Author SHA1 Message Date
Tomaz Canabrava
959bdbbca7 Fix '+' sign for time on the planer, plus code cleanup.
The plus sign for time was in a very strange position,
this puts it back to where it belongs, plus a bit of
code cleanup since the planner was in heavily modifications,
this will be needed quite a bit. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 16:21:55 -03:00
Tomaz Canabrava
72807017ae Make planned points deletion works on the Table too.
Now the planner deletes points by clicking on the
trash icon on the table. The dive planner is almost
finished. <3

next: add a point from the table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 16:08:55 -03:00
Tomaz Canabrava
d37213a413 Moves deletion logic of divepoints to the Model.
Deletes the logic of divepoints to the model, this
makes automatic updates on the table on deletions.
( remember, to select dive points, ctrl+click on it.
) if you want to delete it, press 'delete', it will
be removed from the graphics part and also from the
table.

Next: delete point by clicking on the table trash-
icon.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 15:53:10 -03:00
Tomaz Canabrava
5e722a93e4 Gas choices working, both directions ( Planner and Table )
The gas choice now works and correctly ( I hope ) calculates
the gas choosen to show on the planner. User can choose the
gas from the list on the visual planner, and also on the table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 15:06:26 -03:00
Tomaz Canabrava
2d0e877bb2 Added support for changing Depth and Time on the Table.
Added support for changing depth and time on the table.
It now works both ways, one can edit the planner via the
table for a fine tuning. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 13:27:15 -03:00
Tomaz Canabrava
69903903d2 Started the work of Editable Model for the Planner
This commit is the start of the Editable Model work
for the planner, it creates a new delegate and shares
the code for the model that creates the gas types, so
we only need to change in one place to add new gases.

The table is already edition-enabled, but the outcome
is still undone, next commit - put all together.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 07:14:30 -03:00
Tomaz Canabrava
6c56f07959 Code Cleanup - Remove temporaries.
Just code cleanup, removing temporaries.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 06:54:41 -03:00
Tomaz Canabrava
2921f4c825 Code cleanup - Dead Code.
Just removing an #if 0

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 06:52:58 -03:00
Tomaz Canabrava
bb59202812 Made the TableViews share a bit of code, code cleanup.
Made the tableviews share a bit of code, and code cleanup.
The tableviews for Cylinders, Weigth and Dive Planner Points
now shares the CSS and I also implemented the save / load
methods for the dive planner points, so the functionality
is mostly done on the vieualization side. - since we are
now using three tables maybe it's a better idea to create
one class SubSurfaceTable that knows how to handle saving
/ loading of the columns... TODO for the future. ;)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-28 07:48:46 -03:00
Tomaz Canabrava
cfd17116eb Added a 'remove' icon on the dive planner table.
Added a 'remove' icon on the dive planner table,
this makes the ui more consistent between the other
tables that also manages addition and removal of data.

the delete method is still unimplemented.
next - css.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-28 07:27:59 -03:00
Tomaz Canabrava
65ab236948 Fixed moving a dive point between dive points
Fixed moving a dive point between dive points.
this fixes mostly everything that I have broked
by using a Qt Model instead of a linked list -
but a model is better to make everything updated
and only poke in one place. sharing code++. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 17:15:48 -03:00
Tomaz Canabrava
3323fecea8 Made possible to add a divepoint between two others.
Made possible to add a divepoint between two others,
this also implemented the last patch in the correct way.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 17:02:34 -03:00
Tomaz Canabrava
760c14ac0c Fixed entering a dive stop before another dive stop.
Fixed entering a dive stop before another dive stop,
the correct way is to fix the position of them but
this is easyer - I'll update the correct one in
a couple of patches.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:55:30 -03:00
Tomaz Canabrava
9d90034109 Fixed invalid values on the TableView
The values of the dive points on the tableview were
too big, I'm now dividing time by 60 and depth by 1000
to get the correct results.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:38:12 -03:00
Tomaz Canabrava
5ad4cfe8e2 Fixed a bug where moving a handler would mess the planner
Fixed a bug where moving a handler would mess the planner
by calculating invalid values to the planner on the model
side.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:36:30 -03:00
Tomaz Canabrava
367fc6e1c3 Moved a lot of code to the Model, cleaning the interface.
Moved a lot of code that handled the positioning of the
DiveHandles on the interface to the model. there are a
few bugs left ( regressions ) that I will fix in the
next commits. With this commit an edition of the points
on the widget will trigger a repaint of the planner profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:34:06 -03:00
Tomaz Canabrava
de2f5d9e60 Moving Handler on Graphics Updates the Model on the Planner
Moving the handler on the graphics updates the model on the planner
Unfortunately, the graphics will move back to it's original
position because of the legacy code used to calculate the
dive plan. Next: fix the legacy code used to calculate the dive plan.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 14:54:07 -03:00
Tomaz Canabrava
bc71f9a916 Moved the creation of the data plan point to the model.
Moved the creation of the data plan point to the model,
this way when the user creates a data point on the
graphical planner, or when the user creates the point
on the QWidget based view, both of them will be updated.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 14:17:39 -03:00
Tomaz Canabrava
024dd80664 First implementation of the Shared Model for the Planner
This implementation of the shared model already shares
some, but not all data between the two views, but it's
already a huge improvement. When the user clicks on the
visual planner, it will update the view on the qt-widget
based view. The editing of the view is still not allowed,
and removing nodes is not allowed too ( yet. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 13:18:21 -03:00
Tomaz Canabrava
9856aaaa86 Started the Model to handle the DivePoints
Started the model to handle the divepoints between the
Qt Widget interface and the QGraphicsView one. good thing
is that we share code. Bad is that a model is harder to
work, but doable. :)

With this finished ( in a couple of commits ) one can
insert a point on the Qt widget or on the graphics view
and it will be 'mirrored' to both interfaces.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 09:14:19 -03:00
Tomaz Canabrava
aceb002a33 Changed the WindowHint of the planner popup to 'Popup'
Changed the Window Hint of the planner popup to 'Popup'
this removes ghost items from the task bar.

Hint By: Danilo Cesar
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:49:28 -03:00
Tomaz Canabrava
6cb1f1a250 Code Cleanup: Buttons on Graphical Planner
Removed a bunch of non-used graphics buttons,
since the new widget now contains everything
needed for the creation / cancelation of the
dive plan.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:47:45 -03:00
Tomaz Canabrava
0a043528f7 Added a new widget to control the Planner
Added a new widget to control the DivePlanner, now we
have two widgets, a graphics one and a qt sidget based one.
the Technical divers will most likely use the QtWidget one
while the hobbists will most likely use the QGraphicsView
one. there's not a option to choose one, they both will
appear at the same time.

Next step: make the screens to work.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:43:37 -03:00
Dirk Hohndel
2fb2918607 Compile fix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-13 20:29:22 +02:00
Tomaz Canabrava
41ada82a04 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>
2013-08-13 11:53:48 -03:00
Tomaz Canabrava
6da2d40d3c 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>
2013-08-13 10:49:59 -03:00
Tomaz Canabrava
84f73a5fb1 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>
2013-08-13 10:30:22 -03:00
Tomaz Canabrava
663ab6e23e 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>
2013-08-13 08:58:52 -03:00
Tomaz Canabrava
3464bcf6ef 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>
2013-08-13 08:34:04 -03:00
Michael Andreen
16addbf373 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>
2013-08-08 20:00:15 +02:00
Robert C. Helling
7293885178 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>
2013-08-05 16:59:29 +02:00
Lubomir I. Ivanov
e5b18db802 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>
2013-08-05 06:59:19 +02:00
Michael Andreen
1f976371bf 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>
2013-08-05 06:56:34 +02:00
Michael Andreen
069f588d9d 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>
2013-08-05 06:55:18 +02:00
Tomaz Canabrava
67fec4da70 Added the possibility to choose gases in the planner.
Added the possibility to choose gases in the planner,
now the user should click on the name of the gas, a
popup window will appear, asking the user to choose
what gas he wants for that ascent / descent.

now we need to hook that up with the createDecoStops
method that calculates the decompression.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 13:54:21 -03:00
Tomaz Canabrava
83c73168b0 Added a missing #UNDEF
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 13:01:33 -03:00
Tomaz Canabrava
3e3d8b2210 Good code cleanup.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 12:56:21 -03:00
Tomaz Canabrava
9dde9b3d4c Added the current gas used on the planner
Added the current gas used on the planner, now it's a matter
of choosing the new gas, that will be done in the next commit.e

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 12:12:31 -03:00
Tomaz Canabrava
b36dfc7c4f Removed unused code.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 10:03:04 -03:00
Tomaz Canabrava
a6025c8efd Added button to reduce dive time on the planner.
Added a button and a method to reduce time on the dive
planner. The dive planner will not reduce below deco-time
and it will also not reduce below TIME_INITIAL_MAX.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 09:44:52 -03:00
Tomaz Canabrava
29cb15950e Added ( finally ) the code to reduce depth on the planner
Added the code to reduce depth on the planner. Depth
cannot be lower than 40m and it also won't let the
user reduce if there's any point on the 'reduced' area.
the icon is ugly - we need an artist.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 09:27:04 -03:00
Miika Turkia
d776bb9eb3 Fix compile on clean source
Fixes #163

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-19 10:24:59 -07:00
Tomaz Canabrava
8ad7216e70 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>
2013-07-18 12:01:48 -07:00
Tomaz Canabrava
3aa55462dc 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>
2013-07-18 12:01:48 -07:00
Tomaz Canabrava
7e029980b8 '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.

[Dirk Hohndel: removed the inadvertendly added boost header]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-18 12:01:05 -07:00
Lubomir I. Ivanov
f470f559d1 Colors: a couple of grayscale color tweaks
change the B/W color (index 1) of some of the
colors - e.g. BACKGROUND, ALERT_FG.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
9de15dec60 Profile: support grayscale plotting
This patch adds the getColor() helper function to
ProfileGraphicsView and EventItem so that retrieving
a certain color can depend on a 'isGrayscale' flag.
This flag is private and only set by
ProfileGraphicsView::setPrintMode() at this point.
EventItem also now accepts 'grayscale' as a constructor
argument.

A couple of side modifications are:
- move setBackgroundBrush() to ProfileGraphicsView::plot()
- set the same pen color as brush color for the dot in the
'!' symbol inside EventItem::EventItem().

TODO: look for color issues when printing using the
custom grayscale table

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
17c97b921f Print: pass grayscale flag to setPrintMode()
We pass the value of 'color_selected' stored in the
print options to ProfileGraphicsView::setPrintMode().
This way the profile can be printed in grayscale
internally instead of converting a QPixmap to
grayscale.

There are a couple of questions here:
1) Are all the 'if/then' checks for all individual
colors faster than the direct QPixmap/QImage grayscale
coversation.
2) The direct grayscale conversation does not give
control of individual colors, but can it look actually
better?

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
3076dc6d47 Profile: add the isGrayscale flag
setPrintMode() can now be used to set the
profile to be plotted in grayscale.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
fc84f8868d Print: add method to convert profile to grayscale
(experimental)

Add the method PrintLayout::convertPixmapToGrayscale()
to convert a rendered profile pixmap to grayscale.
It will probably be faster to have
ProfileGraphicsView render in grayscale under certain
conditions (and use a specific color table) instead -
e.g.:

ProfileGraphicsView::setPrintMode(bool printMode,
	bool useGrayScale);

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00