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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>