Commit graph

68 commits

Author SHA1 Message Date
Boris Barbulovski
ccb1c33d02 Put include guard to every header
* ensure include guard to every header
* comment endif guard block

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:37:01 -08:00
Tomaz Canabrava
c1ed9babc7 Move the divetooltipitem to its own file.
This is needed so we can share the dive tooltip item with the
new and old profile at the same time. Next few commits will be
setting the functionality of the tooltip item on the new one.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:26:50 -08:00
Tomaz Canabrava
0a4e21a168 Add the depth text.
Depth text got added to the new profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 09:39:09 -08:00
Tomaz Canabrava
35979537d9 Plot the Temperature Text.
I Moved the 'plot text' method of the Old Graphics to the new
layout - this one was mostly unchanged as it was already good
as is.

And used the TemperatureProfileItem to also display texts.
This was the first implementation of the new system that uses
*less* code than the original one, wich makes me happy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 14:04:47 -08:00
Anton Lundin
7e9582631d Convert to TRUE/FALSE to stdbools true/false
I had problems with this one on Qt5.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:52:31 +07:00
Dirk Hohndel
c3fe1a9e9f Get rid of pointers to dive structures in the UI
The assumption that the pointer will keep pointing to a valid structure is
fundamentally flawed. And even if that is true today, it might change in
the future - just don't do it. Use the diveId instead.

The exception is when you own the structure and use it within one UI
interaction during which any way to change the dive_table is disabled
(e.g., while adding / editing a dive).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07 12:10:19 +08:00
Tomaz Canabrava
1a933e7e19 Don't use QList if sizeof(item) > void*.
QList is optimized for storing pointer-sized items, thus
a QVector is the better choice for everything else.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Tim Wootton
ecc33e6375 Adds unhide to profile menu context menu
Unhide menu is only shown when hidden events exist.
Also updates relavent manual section.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-18 14:07:41 -08:00
Anton Lundin
26a1904cf8 Remove some unused variables
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09 22:47:28 +01:00
Tomaz Canabrava
441838def0 Different Icon for a Bookmark Event.
This patch adds a different icon for a Bookmark Event, and it
also cleaned a lot of code. :)

See #300

[Dirk Hohndel: made the two icons slightly bigger]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-04 19:41:29 -08:00
Tomaz Canabrava
a75168dcc9 Add legend for the Partial Gass Pressure if active.
This patch adds legend for the partial gass pressures if the
graphs are active. when enabling / disabling the square
that represents the color of a gas will also appear / disappear.

Fixes: #272

[Dirk Hohndel: minor changes to layout and whitespace]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 12:58:54 -08:00
Tomaz Canabrava
e8d1f14c90 Enable the 'Remove Event' callback.
Based on the code in the Gtk branch.

[Dirk Hohndel: whitespace cleanup and changed the message text]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 17:58:18 -08:00
Tomaz Canabrava
4c2e6c4658 Adds half of the support for the menu on the profile.
This adds the menu, it just doesn't do anything, yet.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 17:04:25 -08:00
Tomaz Canabrava
69d4ccae6d Added a new option to edit the dives.
Added a new option to edit the dive in the profile view. The option
will only be visible if the dive was manually entered or if the dive
is a plan.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
2013-11-01 09:33:39 -04:00
Tomaz Canabrava
22afca58bf Fixed the moving around of the InfoPanel on non KDE enviroments.
This patch restores the ability to move the info-overlay panel on the
profile. For some reason the eventFilter wasn't working (and actually,
looking at the code, it really shouldn't, because I didn't see where I set
it to work, maybe someone (me) broke it a long time ago) well, it seems
fixed now at least. :)

Tested on XFCE, Gnome and KDE, with three different window managers.

[Dirk Hohndel: removed debug output]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 19:40:16 -07:00
Dirk Hohndel
6ccb541f1d Random white space cleanup
Because I can.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 04:37:31 -07:00
Anton Lundin
dd3b8210a9 Remove unused arg in plot_cylinder_pressure
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11 10:18:07 -07:00
Maximilian Güntner
88172571ca Added a toolbar to the profile
The toolbar adds two buttons to the profile.
The user can now toggle the scaling (zoomed to dive/round up to 30 mins)
and adding /removing ruler to/from the profile using this toolbar.

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-09-27 18:45:04 +02:00
Maximilian Güntner
248f1b86d1 Added a ruler which can be dragged along the profile
This patch adds a ruler QGraphicsItem which can be dragged
along the profile. The ruler displays minimum, maximum and
average for depth and speed (ascent/descent rate). Also, all used
gas will be displayed.

This also adds a new attribute to struct plot_data to store the
speed (not just as velocity_t).

Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-09-27 18:42:19 +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
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
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
8ea849d0c2 Profile: use a printMode flag in ProfileGraphicsView
When printing the profile there are certain features which
we want different (or disabled). This includes font scale ignoring
and showing a toolip. To achieve that we check for a printMode flag
in ProfileGraphicsView which can be set using setPrintMode(bool).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
2e26de5ae6 Profile: improve tooltip animation
Remove a couple of expand() calls(?). Also store the last
expanded rectangle size in the private variable nextRectangle
and use that in collapse() animation. Patch prevents a small
jump/resize glitch if the user quickly hovers over and out
of the profile while the tooltip is still resizing.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:27 -07:00
Lubomir I. Ivanov
c7f8ada4ff Profile: attempt on better zoom and pan logic
QGraphicsView::AnchorUnderMouse does not work for
Qt 4.8.1 on Ubuntu 12.04 and if the mouseMoveEvent
overload is disabled it practically can be seen that
the anchor point is [0, 0] instead of the mouse location.

After a suggestion found on the web this patch attempts
to use the hidden scroll bars to calculate reposition
on pan and zoom *near the mouse cursor.

On the other hand QAbstactSlider (QScrollBar) class
strangly uses negative offsets for minimum scroll
position, which makes the implementation even more
ugly.

[*near] because it's not that accurate!

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:59:46 -07:00
Lubomir I. Ivanov
b68e86a141 Profile: add white outline to all text
To draw the white outline around profile text we trace a text path
using QPainterPath::addText() and then create a couple of
QGraphicsPathItem objects. One of the objects is outlined using
QPainterPathStroker and is placed at the bottom of a QGraphicsItemGroup
with a white brush. The other object holds the standard colored text
and is placed on top.

Notes:
- possibly quite expensive on older machines
- ProfileGraphicsView::plot_text() now returns a QGraphicsItemGroup
- QGraphicsSimpleTextItem uses a top-left baseline anchor
while QPainterPath::addText() uses a bottom-left baseline
which is a bit mysterious, requires the -3 offset for a match
and is possibly non-portable across fonts and sizes.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 15:51:10 -07:00
Dirk Hohndel
07a16574e9 Consistently use slots / signals
We started out using Q_SLOTS and Q_SIGNALS but then changed our mind.
Let's make this consistent again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 10:20:56 -07:00
Dirk Hohndel
5e51d1e354 Plot cleanup
Use a helper to make things easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14 14:34:44 +02:00
Tomaz Canabrava
72d0030509 Added a slot to set the full time of the dive plan
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 21:00:30 -07:00
Tomaz Canabrava
939246acda Added a simple "TextEditor" in the graph, for a plan mode.
Added a simple TextEditor in the graph for the 'Dive Plan' mode,
this text editor is very simple, so the user can double click on
'depth' or 'duration' to set the depth or duration of the dive.
Since this was a test, only 'duration' was done, and I'll add
duration on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 20:59:58 -07:00
Tomaz Canabrava
b4835badb6 Added a 'Plan' mode and a 'Dive' mode on the profile.
Added a 'Plan' mode and a 'Dive' mode on the profile. Those modes
tell the application what can be done: Plan - the dive's dinamyc and
can be changed, 'Dive', the dive is fixed ( most probably downloaded
from a dive computer and it's readonly. ) - now I need to properly
populate stuff.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 17:33:46 -03:00
Tomaz Canabrava
ad5c186553 Implemented the movement of the ToolTip by Hand.
Reimplement the movement of the tooltip by hand,
we were adding / removing childs of the tooltip
quite often, wich broke the movement of the item
using the default behavior, aparently Qt uses
a cache of the transformation of the item, assuming
that the bounding box of it will not get modified
while dragging. wich in our particular case, is
a falacy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 14:48:31 -03:00
Tomaz Canabrava
34c6eec9ba Save / Restore toolTip information position on the Profile when switching dives.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 14:28:44 -03:00
Tomaz Canabrava
45f80afc1f Fix memory leak
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 13:54:17 -03:00
Helio Chissini de Castro
ef873b4082 Hide/Show tooltip on mouse over view widget
Proper hide/show tooltip under ProfileGraphicsView. Events are not
properly handled and no custom tolltip status was stored.
Text are properly hidden now when tooltip is collapsed.

Reported-by: Tomaz Canabrava
Signed-off-by: Helio Chissini de Castro <helio@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-07 21:25:16 -07:00
Dirk Hohndel
6f7467de7a Show the gas with the pressure diagram
This is a feature that had been requested a few times in the past and when
debugging my "show only used gases" commit I realized that this would have
been extremely useful to have...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31 17:31:53 +10:00
Dirk Hohndel
b947cc924f Hook up most of the Preferences dialog
The imperial/metric super setting doesn't have any effect. But changing
the individual units now works and is tracked. And causes the display to
change after clicking "OK" (but not yet when clicking "Apply").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-26 11:33:45 -07:00
Dirk Hohndel
115e5e5fbc The never ending, futile fight for whitespace consistency
I just need to write a tool that does this...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 21:31:45 -07:00
Dirk Hohndel
7757363953 Re-enable dive computer selectiom
This had been disabled by some redraw optimizations in commit
81406b80c6ec ("Fix loading a second dive, after the first file was
loaded."). We need to redraw the plot not only if the dive changed but
also if the selected divecomputer changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 20:59:50 -07:00
Tomaz Canabrava
d39b1aedcd Fix loading a second dive, after the first file was loaded.
This patch fixes loading a second dive-file after the first
one had been loaded. it simply clears some information and
makes sure that the current selected dive is invalid when
the file closes. I also did a bit of code cleanup on this one
to make things simpler in the future.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-16 12:23:38 -07:00
Tomaz Canabrava
56c4cced53 Fixed loading the first dive via command line on the profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 10:49:00 -07:00
Tomaz Canabrava
1fec7d849c Fixed Zoom and Positioning of the Ruler Items
The items are still being placed far from each other when
zooming in - I need a bit of help with the math for that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 10:48:37 -07:00
Dirk Hohndel
c129902793 Fix some compiler warnings
Passing the alignment as int instead of float or double was actually a bug
as CENTER is defined as (-0.5) ...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 10:47:37 -07:00
Tomaz Canabrava
b3b1b3f58f Change the plot text so it receives a QPointF instead of x,y, and a Parent
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 13:03:16 -03:00
Tomaz Canabrava
ea5353025f Only drag the tooltip panel when not zooming.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 08:16:00 -07:00
Tomaz Canabrava
2052e44ba1 Fix Tooltip Positions, code cleanup
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 11:07:44 -03:00
Tomaz Canabrava
acdb5d97eb The Zoom is working just like the GTK Version.
This code enables Zoom in / Out with the Wheel,
and it also enables panning by moving the mouse around.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
9cc089f9f6 Removed unused code that I'm sure it's safe to delete.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
cb8198b524 Plot the vertical ruler on the left of the profile.
Plot the numbers on the left of the profile.
It seems that everythign is being plotted -
But I can see that there are coordinate-errors on the
code. ( the GTK one plots some curves below of the
dive, but the Qt one is overlapping - probably the
way that I'm using the gc information)

Need to investigate a bit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
b794c23099 Plot pp Text
This patch plots the PP text, but when I plotted I realized
that the gc.pi.mapp is being calculated wrong, probably
something went wrong on the calculations - it's comming
zered always. So, only one line & text is plotted.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00