Commit graph

363 commits

Author SHA1 Message Date
Dirk Hohndel
a26719c541 Picture handling: switch to stronger typed offset
Also change the on file XML to be even easier to read by making it a
duration as well (which gets us '32:34 min' instead of un-typed seconds).
This is backwards compatible, it will happily read what was written with
the previous commit).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 09:38:50 -07:00
Dirk Hohndel
a70a0662f5 Pick the correct API function name for Qt5
Subtle change in function name from Qt4 to Qt5

setAcceptsHoverEvents -> setAcceptHoverEvents

Now Subsurface builds with Qt5 again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 17:54:51 -07:00
Dirk Hohndel
1604299a5b Picture handling: change data structure to store offset instead timestamp
It makes no sense to store a 64bit time stamp with every picture. Even the
32bit offset (in seconds) from the dive start is WAY overkill. But
switching to that makes the code much more simple in a number of spots.
And makes what is saved to the XML file easier to read, too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 17:17:49 -07:00
Dirk Hohndel
3a14076b1d Picture handling: stagger the pictures
If the pictures are too close to each other, spread them out a bit more.
This seems to give a reasonably pleasant layout.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Dirk Hohndel
f037f03268 Picture handling: put the picture near its correct time during the dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Tomaz Canabrava
380385d86f Rotate the picture around -4 and 4 degrees.
This patch rotates the picture a bit, so it looks like it was
splattered around the profile.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Tomaz Canabrava
c21122af40 Add a drop shadow on the picture
This patch adds a drop shadow on the picture. a real blurry shadow
could be much better, but without OpenGL it's too costly to calculate
the shadow for each picture.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Tomaz Canabrava
8e682c41e8 Add a nice white rectangle around the picture
This makes the picture looks a bit more like a real paper picture
shadow's missing, though.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Tomaz Canabrava
e14a15e61c Subtle animation when the picture gets hovered with the mouse.
This patch adds a subtle animation when the picture gets hovered
with the mouse, and restored to it's original size when mouse exits
the image area.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Tomaz Canabrava
38ac6ed35f Add a scaleTo animation
ScaleTo animation will scale or shrinks an graphical element in an
animated way. This is going primarelly to be used on the pictures on the
profile, but can be used on anything else later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:51 -07:00
Anton Lundin
efd8da9b08 Gas was printed in permille, use gasname instead
After the switch to a central event decoder and just return gasmix from
that we printed things in permille, eg. EAN1000 and 180/550 which looks
kinda strange.
This fixes that by using gasname instead to give the gas a name.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 09:25:27 -07:00
Dirk Hohndel
714fdc7ced Force TTS/NDL calculation off if things take too long
This is kind of a random cut off, but if plotting the dive takes more than
a second and TTS/NDL is on, we force it off. Because the algorithm for
that is fundamentally quadratic in nature it can take a VERY long time -
getting users to think something is broken.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 13:44:34 -07:00
Tomaz Canabrava
3e46b4862a Do not plot pictures that don't have a timestamp.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:47:43 -07:00
Tomaz Canabrava
43cf9fdb7a Add a method to plot the pictures on the profile.
It plots in the wrong place for now, because I need to change the model a
bit. But it shares the same pixmap with the other widget which is nice. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:43:06 -07:00
Tomaz Canabrava
ebe799e0a0 Connect & disconnect the PictureModel on the profile
Ignore the warnings for now, this patch connects and disconnects the (not
done yet) plotPictures() method.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:41:51 -07:00
Dirk Hohndel
49053e86aa Make most of the shortcuts widget specific
Having the window specific means that you can't have a key do different
things on different widgets.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 15:30:27 -07:00
Dirk Hohndel
cc012c1fa6 Fix addStop to work as slot again
In order to call this as slot it needs to have defaults for all arguments.
So we need to change the gasmix into a pointer - which is actually better
as this allows to easily pass a NULL pointer when we want to continue to
use the previous gas.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 12:40:36 -07:00
Dirk Hohndel
5bead467d7 Rename two C++ methods to the more typical CamelCase
Silly little change. Whatever.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 21:02:42 -07:00
Dirk Hohndel
d740ad1317 Convert plot_gas_value to gasmix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 21:00:09 -07:00
Dirk Hohndel
89f3532145 More conversions to gasmix
addStop, addGas and createSimpleDive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 18:18:57 -07:00
Tomaz Canabrava
57d3baa410 Simplify ruler update code.
This should fix the infinite recursion on OSX and also clean a lot of
code, which is also very nice. <3

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:42:32 -07:00
Dirk Hohndel
2bf46381a8 Use proper types
This is step one of many to use gasmix instead of int o2/he.
Right now some of these changes look ridiculous because after changing a
few lines we immediately go back to o2 = get_o2(gas). The reason is that I
wanted to convert a hand full of functions at a time. So in this commit I
only change validate_gas(), get_gas_from_events() and get_gasidx() to use
a struct gasmix instead of int o2, int he.

This state builds and survived some mild testing. Let's continue on top of
that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 14:19:19 -07:00
Dirk Hohndel
1a04013453 Encapsulate the horrid gas encoding in gas change events
We should never pass permille values around as integers. And we shouldn't
have to decode the stupid value in more than one place.

This doesn't tackle all the places where we access O2 and He "too early"
and should instead keep passing around a gaxmix. But it's a first step.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 12:07:29 -07:00
Dirk Hohndel
e74914fdd0 Planner: wild guess attempt to fix a crash on Mac
Staring at the stack trace it seems that it gets into an infinite
recursion when trying to recalculate after being alerted to a change on
the ruler. I cannot recreate this here (not on Linux, not on Mac), but
here's a random attempt to prevent the issue: simply refuse to recalculate
the ruler while in Add or Plan mode.

Crude, but might show us if this really is the issue. Otherwise it's easy
enough to revert this change. The qDebug() in there should tell us if
people on a Mac do indeed see this even without moving the ruler around in
Add or Plan mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 14:57:57 -07:00
Tomaz Canabrava
2744714970 Hide the DiveHandlers that are not entered by mouse.
We need to create them, even if we don't display ( only because it
was a pain to correctly track them from the model ) - so, hide them
if it's not entered by mouse, but a deco one.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:38:24 -07:00
Tomaz Canabrava
490c7a0645 Hide DiveHandlers and GasTexts when on profile mode too.
When switching from PLAN or ADD mode to PROFILE, we
kept the dive handlers visible, not anymore.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:37:59 -07:00
Robert C. Helling
45725d1c30 Planner: remove infobox overlay and enable calculated ceiling
Make the infobox invisible in planner (it really doesn't provide a lot of
useful info while planning a dive and more likely gets in the way).
Make the calculated ceiling always visible in planner and add mode.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 08:26:55 -07:00
Tomaz Canabrava
1e4f744165 Fixes showing the Empty Profile when Add / Plan dive is cancelled.
for some reason the next selected dive is NULL after cancelling the
plan. I'm investigating.

This patch fixes the show of the empty profile and it also untangles
some parts of the code, keeping the mainwindow where it should belong
: the mainwindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 12:25:36 -07:00
Tomaz Canabrava
4e3793c053 Paint the dive red if the user is breaking ceiling on the planner.
This patch paints the dive red if the user is breaking ceiling
on the planner - it's quite fast, it analizes the depth over the
max(tissue_1 .. tissue_16) and changes the color of the profile.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 15:42:43 -07:00
Tomaz Canabrava
d9abf885c2 Better movements from the lines when added / removed.
This makes the movements from the lines when added / removed
SO much better.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 15:39:04 -07:00
Dirk Hohndel
0d58cfb641 Planner: don't try to update the MainTab dive info while in plan mode
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 15:18:15 -07:00
Tomaz Canabrava
4c9dd0e698 Speed up the grid: don't repaint when uneeded.
Added a flag to only recalculate the axis when needed.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 14:07:48 -07:00
Tomaz Canabrava
addec6b69f Do not set maxTime when the handler is moving.
Fixes massive cpu hog.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 14:07:27 -07:00
Tomaz Canabrava
eec0b327a3 Make the planner show something.
This is working in the wrong way, mostly because I'm setting the
plannermodel to ADD state ( and the planner graphic to the
correct PLAN state ), but I don't know why - when on PLAN state
on the model, things just don't work.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:18:53 -07:00
Tomaz Canabrava
c4d022356e Planner: states Add and Plan have a similar behavior
So, the code is equal.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:18:00 -07:00
Tomaz Canabrava
feff22c222 Planner: Re-enable using the new profile.
This correctly enables the planner on the new profile,
but it doesn't triggers the correct paint on the canvas.

[Dirk Hohndel: remove other remnants of the disabled planner as well]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:17:32 -07:00
Tomaz Canabrava
2359bd3c2c Reenables the air edition and deletion of handlers on the planner/add
Only a tiny bit of poke around the contextMenuEvent - the events
of the planner are dealt by the QGraphicsItem, and this makes the
logic pretty easy to follow. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 21:11:30 -07:00
Tomaz Canabrava
bc047238d4 Port the KeyPress actions to the new profile.
[Dirk Hohndel: combined two commits into one and cleaned up some
               whitespace issues]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 09:07:34 -07:00
Tomaz Canabrava
d2569c6688 Remove a ton of code.
The code removed was already ported to the New Profile.
We managed to clean quite a bit. huhhy

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:36:44 -07:00
Tomaz Canabrava
f67693b2e0 Make mouse dragging work as it should.
This patch makes mouse dragging work as it should, a tiny
bit different than the old version, but I think it's a better
way. What's missing: Keyboard actions.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:32:23 -07:00
Tomaz Canabrava
963178d3d4 Fixe movement of DiveHandlers when moving the NotificationArea
The QGraphicsView system moves every selected item when the user
clicks and drags one. This patch makes a cache of all selected
items and removes the selection on them. When the user stops dragging
the Notification, the selection is restored.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:30:36 -07:00
Tomaz Canabrava
ea4d4ac020 Make the planner actually work.
This commit makes the planner actually work. There ar still
a few edges, but oh, joy - the new Profile gave a very unexpected
and nice addition to it - Grab the last handler of the initial
dive, and move it to the right, or get any handler, and move it
to the bottom to see what I mean.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:28:39 -07:00
Dirk Hohndel
5ba573240f Gratuitous whitespace changes
I keep trying to get to consistenct.
Completely hopeless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 11:40:22 -07:00
Tomaz Canabrava
f99ccc8ac2 Profile now correctly displays the planned dive.
But it doesn't move the handlers yet, and when you confirm it you also
must click on the dive to select it or the profile will show garbage.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 14:41:26 +09:00
Tomaz Canabrava
e249fe8703 Disconnect temporary connections on the Profile.
This code adds the disconnections of temporaries. A temporary connection
is a connection that should be active only on a certain state, and we need
to clean that for the new state that will enter after.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 14:31:37 +09:00
Tomaz Canabrava
27afb33806 Move two necessary functions for the Planner behavior to the Profile code.
Those two functions are important and necessary for the Planner, they
create and remove the little balls that act as handlers so the profile
can be edited with the mouse.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 14:28:54 +09:00
Tomaz Canabrava
fe1df6b1cc Back to profile or empty state when finishing addition.
This patch adds a signal to MainTab, that should be removed from there
when we finish the rework on the edit part, to go to the edit classes,
but in the meantime, let's keep it there.

The signal is connected to the ProfileWidget in a way that the end of the
edit will also trigger the profile to go back to ProfileState (show the
dive, if there's any) or empty Profile (if there's none).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:12:32 +09:00
Tomaz Canabrava
3661f291a4 Enable editing the 'Add dive' from the new profile.
This is highly broken in many ways - but it's the right first step.
I ported two of the most important methods from the old profile and now if
you are in add dive mode, double clicking on the new profile will
correctly add a handler on the planned dive. To see and move the handler
around, however, you need to activate the old planner.

Next step: add the handlers on the new profile.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:11:50 +09:00
Tomaz Canabrava
f416cdd9e8 Source and dest are created on the constructor, no need to check for them.
The code checked if dest and source existed before trying to call an
method on them, but dest and source are created on the constructor,
and thus, the if is dummy.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:06:16 +09:00
Tomaz Canabrava
119950b6db Move settings of the Ruler to the Ruler.
As with any other graphics object, the settings for the ruler
should be managed by the ruler, clearing up the Profile logic
and making the code easier to read.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:05:30 +09:00
Tomaz Canabrava
6aab69b298 PreferencesChanged -> settingsChanged.
We used both preferencesChanged and settingsChanged in different
methods and classes to mean the same thing, this adds consistency.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:03:51 +09:00
Tomaz Canabrava
3c7a6ab750 Don't replot every time a pref changes, regardless of what preferences.
The list of preferences that should trigger a full repaint are at the top
of this method, *if* this introduces a bug it is because some of the
preferences are not being correctly triaged yet and that needs to be
fixed.  Regardless of that, now the profile will only enable / disable
the *ruler* instead of replotting everything.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 07:31:51 +09:00
Tomaz Canabrava
1988da779f Remove use of QSettings for ruler visibility, use prefs.rulergraph instead.
The QSettings is a bit bloated on its use, so we are trying to narrow
down the amount of calls to it. We have a preferences struct, use that
instead.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 07:31:05 +09:00
Tomaz Canabrava
2a48170fd3 Code Cleanup: Move the Hide/Show ruler to an internal method
By moving the Hide/Show of the ruler to an internal method, we gain a bit
of codecleanuperism by removing a lot of unnecessary calls to their dest
and source drag-handlers.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 07:30:20 +09:00
Tomaz Canabrava
ef4705070f Create a 'remove_event' function that removes an event.
The logic of removing the event was in the UI, and this makes
the code harder to test because we need to take into account
also the events that the interface is receiving, instead of
only relying on the algorithm to test.

so, now it lives in dive.h/.c and a unittest is easyer to make.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 07:28:27 +09:00
Tomaz Canabrava
0b6cbe0f79 Code Cleanup: use qMin instad of if( min ) setMin else setMax.
silly code cleanup.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 14:48:07 +09:00
Tomaz Canabrava
b34fb70d78 Speed Improvement: Unhide all events by calling event->show()
The old code replotted the whole dive, while what we really wanted was to
show the events. so just ->show() them.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 14:46:12 +09:00
Tomaz Canabrava
97419a0d6a Speed Improvement: hide events instead of replotting everything
The 'Hide Similar Events' function asked the Profile to replot eveything,
only because some events were hidden from the interface. Instead of that
we can simply hide the events since the graph will be the same.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 14:45:08 +09:00
Tomaz Canabrava
4bc3687b21 Only set the state to profile if it's empty, not if it's Add or Plan.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 14:29:24 +09:00
Dirk Hohndel
a117428ff4 Add ability to make a dive computer the first dive computer of a dive
If a dive has multiple dive computers we enable a special context menu
when the user right-clicks on the dive computer name AND is not already
showing the first dive computer. In that case we offer to make the
currently shown dive computer the first one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:59 +09:00
Dirk Hohndel
419434f494 Show the dive computer number (if a dive has more than one)
For most users this is no change at all. For the few who download from
multiple dive computers this now shows them which of them is the primary
dive computer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:59 +09:00
Dirk Hohndel
cae51ff0aa Change get_dive_by_diveid to get_dive_by_uniq_id
The original name was a really bad choice as we have a 'diveid' as part of
struct divecomputer - and that is not the diveid that is being used here.
Instead we use the 'id' member of struct dive which holds the "unique ID"
for this dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19 20:12:59 +09:00
Tomaz Canabrava
e0c0ac5d5c Rename getDiveById to get_dive_by_id to keep current c code organized.
This commit renames getDiveById to get_dive_by_id, and it also removes the
Q_ASSERTS and if(!dive) return that the callers of this function were
calling. If it has a Q_ASSERT this means that the dive must exist,
so checking for nullness was bogus too. I've changed the assert (done
in a silly C-Way.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:24:37 +09:00
Thiago Macieira
2e0a51264f Fix another dangling pointer
Same problem as the previous commit: toStdString() returns a temporary,
and c_str() will return a pointer to internal data, freed at the end of
the statement. So get the pointer to be strcpy'ed in the same statement.

Changed to toUtf8() to be more explicit about the encoding and to avoid
std::string

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 22:02:21 -07:00
Dirk Hohndel
223d99f79f Change the profile redraw logic after preferences were changed
I we are showing a calculated ceiling, then we have to replot the profile
after a preferences change as the gradient factors could have changed
which might change a calculated ceiling.

Also use the rulergraph preference instead of checking the settings
directly.

Fixes #511

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 15:58:25 -07:00
Dirk Hohndel
3063991e4e Fix bug in handling of fake SAMPLE_EVENT_PO2 events
In commit bcdd6192fe ("Show translated event names in tooltip") I was
too aggressive in replacing the checking for event names with checking for
event types. It turns out that we are abusing an existing event type in
the planner (and use a different event name to mark the difference). By
just checking for the type this now caused incorrect information to be
displayed in the info box (a simply "PO2 warning" on a Suunto D9 could
turn into a "Bailing out to OC" notice).

The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from
libdivecomputer. Once we have those, we can do this the right way. For now
we just fall back to also checking the event name (which is what I wanted
to get away from so translated names don't trip us up).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 09:32:13 -07:00
Dirk Hohndel
0e49e61ddc Fix test for "air" in tooltip display of gaschange
The "is_air()" test works when we have the gases in permille, but not in
percent. In that case we can just check for He == 0 and O2 == 21.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-29 22:39:33 -07:00
Dirk Hohndel
bcdd6192fe Show translated event names in tooltip
In order for this to work we need to compare against the event type
instead of the event name - which makes much more sense to do, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-29 22:38:55 -07:00
Dirk Hohndel
2d24779b62 Make heartrate grid less confusing
Having all the grid lines in the same color made things visually
confusing. To clean this up a little make the heartrate lines a light gray
color.

Fixes #484

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-28 12:45:42 -07:00
Gehad Elrobey
8380f09619 Renaming the prefs struct members to be consistent with the QSettings.
-Renaming prefs members for consistency.
-Changing references of QSettings to the prefs structure instead.
-Removing unused functions in pref.h were left over from an old version.
-Changing the data-type of bool members to short for consistency with other members.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-16 13:09:55 -07:00
Dirk Hohndel
f7a327077b Simplify code
This seems like a rather obvious optimization...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-14 23:21:09 -07:00
Dirk Hohndel
e5967dd193 Make red ceiling work
The existing code for toggling the DC reported ceiling in red or "surface
color" clearly had never been tested.

This seems to create a reasonably attractive implementation - not exactly
what we had in the past, but good enough.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-14 22:52:22 -07:00
Gehad elrobey
cdf83f5ef6 Change some references of QSettings to the pref struct.
After adding the animation member in the preference struct, it is
very resonable to change these references of QSettings to the
preference structure instead.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-11 07:21:15 -07:00
Lakshman
6a8d929876 Feature to show or hide heart rate graph
Adds new push button "HR" to the button bar on the dive profile to
toggle display of heart rate.

TODO: New icon for the heart rate button is needed.

Fixes #485

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-10 09:21:43 -07:00
Willem Ferguson
4c627ddb30 Change position of heart rate labels on y-axis
The lettering of the heart rate numbers on the lefthand exis "fall off"
the left hand of the profile panel when the panel is a bit narrow. This
minute change moves the letters a bit closer to the Y-axis so that their
left-hand extreme is more or less in line with those of the depth-labels
on the Y-axis. This is a partial response to Ticket # 484.

See #484

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-07 13:24:08 -07:00
Dirk Hohndel
9a0e40b456 Random small whitespace cleanups
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-03 12:52:05 -07:00
Yosef Hamza
0f5664e584 Edit name option for bookmarks
Add the option to edit the name of a bookmark to be more meaningful for
the user they prefer.
It works just as simple bookmarks and can be removed and hidden.
It won't accept names longer than 22 characters because longer names will
display as garbage text.
Also changed the code from displaying flag depending on event name to
depending on event type.

Signed-off-by: Yousef Hamza <jo.adama.93@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-03 12:49:22 -07:00
Lakshman
7696fbf9cd Toggle showing average depth
Add additional check box in "preferences->graph" section that allows
users to hide average depth on dive profile.
By default this option is checked to show average depth.

Fixes #475

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-28 09:38:08 -07:00
Lubomir I. Ivanov
d2f1a02523 Profile2: hide the tooltip and ruler if we are printing
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:22 -07:00
Lubomir I. Ivanov
b3f6a4f994 Profile2: add use of the isGrayscale flag when getting a color
getColor() has a default argument for grayscale set to false.
With this patch we pass it the local isGrayscale flag, which
can only be set during printing.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:22 -07:00
Lubomir I. Ivanov
06a1cb0975 Profile2: add some print related flags
Some flags like printMode and isGrayscale are missing yet needed.
The flag printMode is required so that we know *when* to hide
certain elements such as the ruler and tool tip (e.g. not needed
while printing).

isGrayscale should be passed to all getColor() calls, so that
the greyscale color table is respected.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:22 -07:00
Lubomir I. Ivanov
ac23d7397f Ruler: fix bad scaling for the text background
The ruler text's white background scales badly. This patch
adds the ItemIgnoresTransformations for the textItemBack
object and matches the dimensions and position of the
textItem object in front of it.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:22 -07:00
Jan Mulder
486db77ac8 Repaint ruler when enable/disabling it
Repaint ruler when enable/disabling it.
Straightforward replot() added.

Fixes #479

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-27 10:58:22 -07:00
Jan Mulder
41209005c9 Make pp graphs visible at startup according to settings
Changeset a90818671 introduces a small inconvenience. The pp graphs at
startup are not shown according to the visibility settings. Requiring to
toggle the icons to show the desired pp graph.

Trivial fix.

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-21 21:29:22 -07:00
Hugle
2ca6009dfa Removed Duplicate Includes
Signed-off-by: Hugle <wulong@comp.nus.edu.sg>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20 09:52:24 -07:00
Tomaz Canabrava
6ee3a6da52 Remove a bit of space from the Axis and its labels.
This should make the layout work better on smaller screens.

Fixes #458

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20 09:49:05 -07:00
Tomaz Canabrava
dfaa302383 Make ruler respect dive depth.
The only place on the code that the y() position didn't accompanied the
dive-depth was this one, so let's see if this patch fixes it.

See #455

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20 09:48:34 -07:00
Lubomir I. Ivanov
71f2fd91b5 Profile2: fix widths on some lines for Qt5
Qt5 uses different widths for some of the poly. lines
in the profile. Setting an explicit value fixes that.

Tested-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-19 09:37:12 -07:00
Lubomir I. Ivanov
6d6721dc9b Profile2: use unsigned int for the divecomputer number
display.h: dc_number is unsigned int, thus a couple of warnings
may pop-out.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-18 11:56:06 -07:00
Hugle
a908186716 Clear PN2 PO2 PHE GasItem
After the dive log has been closed, the ProfileWidget2 does not clear
the pn2 po2 and ph2 gas line.

This patch cleared the three lines after dive log closed.

Acked-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Hugle <wulong@comp.nus.edu.sg>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-18 11:49:57 -07:00
Linus Torvalds
37794e2e23 Be more careful about dive computer selection
The selection logic was a bit random: some places would return NULL if
the dive computer index was out of range, others would return the
primary dive computer, and actually moving between dive computers would
just blindly increment and decrement the number.

This always selects the primary computer if the index is out of bounds,
and makes sure we stay in bound when switching beteen dive computers
(but switching between dives can then turn an in-bound number into an
out-of-bounds one)

Fixes #464

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 10:53:49 -07:00
Dirk Hohndel
60ceb8ebc1 Silly change to a comment
I had intended to amend the previous commit with this before pushing it
out. This changes the comment that pointed out the bug that the previous
commit fixed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17 10:53:12 -07:00
Dirk Hohndel
33b1b0ed9d New profile: fix event hiding logic
Turns out we unconditionally set all events as visible when redrawing the
dive - even with a comment that this should take into account if the event
is visible. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-16 15:11:35 -07:00
Dirk Hohndel
401aa210ff New profile: add event manipulation to context menu
This got lost when we switched to the new profile.
Remove event works. Hide events does call hide() on the DiveEventItem but
for some reason it stays visible. I'll hope for one of the more
experienced Qt people to fix that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 21:12:34 -07:00
Jan Mulder
aa0cd792bb Bugfix: generalize pp graphs to allow for multi over-threshold periods
Especially in O2 decompression parts of a dive, the pp02 is typically very
close to the threshold value (normally 1.60 bar). The old implementation
of the pp profile graphs assumes that there is exacty 1 consecutive set of
samples that needs to be in the "warning color". This results in an
erroneous display of the mentioned graphs, connecting multiple episodes of
too high pp with bogus lines in between.

This fix generalizes the pp graph logic to allow for multiple segments of
high pp, each to been drawn seperately in the "warning color".

Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 12:07:34 -07:00
Dirk Hohndel
ae2f18678d New profile: fix Information overlay location
By simply storing the coordinates based on the scene (instead of trying to
map them to real coordinates) the overlay position is correctly restored.

Also remove the redundant positioning before readPos is called.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-13 10:28:15 -07:00
Lubomir I. Ivanov
4abe9d5c8b Profile2: place the ruler and tooltip on top (Z order)
The topmost Z order of items in the profile should be:
- background (poster / logo)
- toolTipItem
- rulerItem
...

This mostly fixes the ruler being under other elements.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-12 11:25:23 -07:00
Lubomir I. Ivanov
f2bfc72648 Ruler: change how the ruler text drawing works
A couple of problems with the ruler:
- the rotated text doesn't look very well at all and interpolation doesn't
  help it much
- measuring towards the right most part of the profile makes the text go
  out of the screen

To solve these issues and attempt to improve the ruler this patch does the
following:
- place the text at the bottom of the lowest of the start and end points.
  this way the line will never intersect with the text
- clamp the x position, so that the text doesn't ever leave the screen
  horizontally
- place a white background behind the text so that it will cover text and
  graphics under the ruler item

(TODO: place the ruler on top of everything else)

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-12 11:24:20 -07:00
Tomaz Canabrava
9cc942376e Only anim if not first dive when openning subsurface with a divelog.
The animation appeared when the user started subsurface with a default
file, wich was a little annoying since it didn't had a 'from' position
to go and it was also increasing it's size on some window managers
that do subtle windows animations when a program starts. This patch
treats the first dive opened when the program loads with a divelog pa
rameter differently as the following ones storing the velocity value
on a temporary, and reassigning it later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 17:42:42 -07:00
Tomaz Canabrava
751c76a578 Support save / load for the Animation Speed on the Preferences
User can now fine-tune the animation speed on the preferences,
a value of zero disables it completely.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-11 17:41:41 -07:00