Commit graph

227 commits

Author SHA1 Message Date
Anton Lundin
43997d3b36 Convert more TRUE/FALSE to stdbools true/false
In Qt5, Qt doesn't define TRUE/FALSE anymore, so we need to stick to
stdbools to have Qt5 builds working.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-19 07:13:56 -08:00
Tomaz Canabrava
31ee4dac65 Make part of the context menu work (gas change event)
The code of the context menu and the gas change event callback is mostly
the same as the old profile, with minimum modifications, as this changes
the order of the code on the callback to make it a bit saner (declare
variables first, call code later).

This also fixes a bug on the model that was not cleaning itself in the
correct way after a call to clear.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 14:50:14 -08:00
Dirk Hohndel
d81223b3f4 Missing initializer
This was causing us to access uninitialized memory at times.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 14:40:10 -08:00
Dirk Hohndel
16e03ff86e New profile: some more slight rearrangements
This is just an attempt to not have the time markers and dive computer
name printed right on top of each other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 14:16:39 -08:00
Dirk Hohndel
21ca39ab0a Fine tune positioning of temperature and tank pressure lines
Maybe not yet perfect, but better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 11:17:29 -08:00
Dirk Hohndel
582fb693a0 New profile: improve mean depth line
Show decimal depth and make the line length more appropriate for the dive
profile shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 10:57:11 -08:00
Dirk Hohndel
e0f8ec7144 Clean up some warnings
Unused variables, more initialization order complaints.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 10:44:23 -08:00
Tomaz Canabrava
4525fbb147 Fix z-value of the PartialPressure gas graph over the timeAxis
Fiz zvalue of the partialPressure Gas Graph over the TimeAxis, and also
corrects the position of the PartialPressure gas graph. It now no longer
appears to 'float' over the TimeAxis, now it's on the very top of it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
44a72b805c Make it possible to hide some of the grid lines.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
4699363a9e Better setup of the defaults for the grid.
This patch creates better defaults for the grid lines, size, position and
z-level.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
883b25cea3 Create the grids.
Create the grids, and the way that they move is fabulous <3

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
38e25458ee Change the axis update method to move the lines.
Change the axis update method to move the lines alongside the texts.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:21 -08:00
Tomaz Canabrava
0c5fd7db8e New template-based-function: remove the uneeded items on a QList.
This function is for non-duplication of code for different QLists, since I
now have Texts and Lines, I needed to make the code in a way that it
worked without dupplication.

It's a pretty standard use of templates, I think that even the C guys will
not be offended by it. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:16:15 -08:00
Tomaz Canabrava
fc55b2abfe Remove the class 'CartesianPlane'
This class was pratically a re-do of the axis, I'll do the axis to plot
the lines when it feels like it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:16:02 -08:00
Tomaz Canabrava
87d5289920 Move the events when a partial pressure graph is enabled / disabled
The events were static on the canvas even if the profile changed its size
because of a toggle of the partial pressure gas. This patch makes events
move on the canvas to their correct place.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:15:14 -08:00
Tomaz Canabrava
6c67f90858 If the depth is zero, dont show it.
The first depth label of its axis is always zero, do not show it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:15:03 -08:00
Tomaz Canabrava
021d799ff9 Fix crash opening testdive0.xml
That particular dive didn't have a temperature, and thus we got a crash
while accessing the last temperature text.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:14:49 -08:00
Dirk Hohndel
191a3064a7 Removed unused setup function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 11:17:23 -08:00
Dirk Hohndel
6be62c1d90 Make font label scale a per axis property
This way the partial pressure graph can have smaller pressure labels than
all the other labels on the profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 11:15:57 -08:00
Dirk Hohndel
980737221d New Profile: make axis labels smaller
Previously all text in the new profile was deawn in the same font. With
this change the labels on all axes are smaller.
It might be even better to allow per-axis configuration of the label size
as along the time axis the bigger size looked better. But especially for
partial pressures this looks much better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 07:06:09 -08:00
Tomaz Canabrava
e49bd86f5e Align Right side of Cylinder Pressure Text to the Left.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Tomaz Canabrava
822ed20625 Left-Align the last Temperature Text.
The last temperature text used to have the same align flags
as all the other texts: Right. this makes it much more appealing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Tomaz Canabrava
bd5cc109f0 Show the last temperature on the graph.
The code shamelessy copied from the old profile introduced
a bug where the old temperature was not correctly shown.
I'v added a new member to the class that will store the
last valid temperature, and use that to calculate if there's
a reason or not to display it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Boris Barbulovski
c86822c2f4 Replace mainWindow() with MainWindow::instance()
C++ style of accessing single instance class object.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 11:42:59 -08:00
Tomaz Canabrava
cc37d2e94a Make the mean depth line follow the size of the axis.
When we move, shrink or expand the depth axis, the
meandepth should also change it's position. this
patch adds that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:33:14 -08:00
Tomaz Canabrava
0333de426f Hide the extra axis labels on release mode, show on debug mode.
The extra axis labels on the Temperature and Cylinder Pressure
graphs are not wanted in release mode as they create a lot of visual
clutter, but they are useful to have in debug mode since we can then
better understand what went wrong.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:31:24 -08:00
Tomaz Canabrava
8041a2ed85 Added cylinder pressure shrinking on show/hide partial pressure.
Same as the last commit, but for cylinder pressure. Another bug
was spotted, where the mean depth line does not move to the correct
location after a axis-size-changed - fixing that on next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:30:45 -08:00
Tomaz Canabrava
49642cacbc Shrink temperature axis when partial pressures are shown.
This patch adds shrinking of the Temperature axis when partial
pressures are shown. This adds an unwanted side effect however,
the axis started showing it's values - and we didn't do that on
the gtk version or on the old profile. While this is good for
debugging, it's not wanted for the software if it's on release
mode. I'll fix that in due time.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:29:57 -08:00
Tomaz Canabrava
b08c38da33 Animate transition between show / hide partial pressure graphs
When the user checked the option to show or hide the partial
presure graph the size of the profile graph was kept the same;
usually I do those changes on the objects themselves, on the
settingsChanged method, but since the calculation of the
size of the profile was done on the ProfileView class for
consistency with the other objects, I had to change it there
too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 10:08:46 -08:00
Dirk Hohndel
48e9257de4 Fix variable scope issue
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 14:08:17 -08:00
Dirk Hohndel
92bbed3304 Take the on-canvas position into account for DiveCartesianAxis::valueAt()
We did this right for posAtValue(), but not for the inverse.

Fixes #438

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:37:09 -08:00
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
Dirk Hohndel
b839cd4cb0 More renaming
I don't even know what a partial gas might be...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:11 -08:00
Dirk Hohndel
d1c4bcf570 New profile: enable switching between dive computers
This was mostly in place, just needed to be hooked up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:35:54 -08:00
Dirk Hohndel
73d6057424 Minor cleanup
Remove obsolete header and unused variable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:35:47 -08:00
Dirk Hohndel
6ea6a4305c Use our macro for FP comparisons
I think that catches all the ones we missed (thanks clang -Wfloat-equal).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:35:40 -08:00
Dirk Hohndel
2bd2df0349 Fix bug in logic expression
Yes, the old code made perfect sense when you read it - except the C++
compiler turned it into something quite different from what was intended.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:34:42 -08:00
Dirk Hohndel
d49acdb3c0 Clean up include files
They should have a newline at the end.
Forward declarations of classes should be 'class'.
Function / method definitions don't end on a ';'
Remove obsolete QStateMachine forward reference.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:34:34 -08:00
Dirk Hohndel
829473ddc6 Don't repopulate the model if the dive didn't change
plotDives takes a list of dives (for future use) but currently only looks
at the first dive in this list. With that semantic in mind we can save
ourselves some work if we first check if this is the same dive we are
already showing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 16:32:10 -08:00
Dirk Hohndel
ba6713f0d8 Clean up the setDive function
* This should never be called with a NULL dive.
* The dc variable was set then never used.
* We now have a unique id for each dive, but we can't simply not
  repopulate the model in setDive as the old comment might make you
  consider, as otherwise the dataModel will reference already freed data
  in pInfo.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 16:27:05 -08:00
Dirk Hohndel
74c75938bf Set up the dive that was passed in as first dive
We carefully extracted the first dive passed in with the QList, but then
always used current_dive. That's silly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 15:12:01 -08:00
Lubomir I. Ivanov
4b21e2f9a3 Profile2: Prevent another crash if no dives are present
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 14:33:44 -08:00
Tomaz Canabrava
691fbabb7a Do not add the items to the scene twice.
Those items have parent(), which means that when the parent has a scene,
they are automatically added and removed from the scene.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 09:58:42 -08:00
Tomaz Canabrava
bb71707321 Fixed item visibility on emptyState after being on profileState.
Background was not correctly back to it's original position
and a few other items kept their visibility when it shouldn't.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 09:57:45 -08:00
Tomaz Canabrava
cafc7e4b13 Clear the data when the model resets.
This patch does a few things:
1 - reset the model when user closes the dive file
2 - connects the 'rowsAboutToBeRemoved' in a way that the graphics can
    remove their polygons too
3 - adds a 'clear' virtual method so items that don't follow the rules can
    clean themseves up.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 09:57:04 -08:00
Boris Barbulovski
e7eb06d78c Improve sanity check for DivePlotDataModel::data()
Adds DivePlotDataModel row upper-boundary check (isValid method already
checks for negative values).

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:55:55 -08:00
Boris Barbulovski
0e3852e625 memory leak fix(that I created in some previous commits).
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:51:52 -08:00
Lubomir I. Ivanov
0dfff310de Profile2: Prevent a crash if no dives are present
But in general we should not show the profile of a dive that
was recently removed from the list - e.g. via File->Close.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:06:37 -08:00
Linus Torvalds
50424df653 Use 'struct membuffer' for profile info string generation
The profile info was generated using nasty string concatenation that the
membuffers are much better at anyway.  And membuffers don't need those
arbitrarily sized fixed buffers (500 bytes? Why 500 bytes?).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:03:27 -08:00
Boris Barbulovski
1d871eb749 ProfileWidget2 class improvements
* Reorder ProfileWidget2 class constructor initialize list.
* Initialize(lazy) ProfileWidget2::plotInfo structure.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Boris Barbulovski
8bb5cd6012 ToolTipItem class improvements
* Initialize every ToolTipItem variable member in initialize list.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Boris Barbulovski
9b84f82160 DiveTextItem improvements
* Add colorIndex to initialize list.
* Reorder initialize to correct order.

Note: colorIndex initialize value is set too SAC_DEFAULT. I do not know
what is the rigth value since this variable member is not used anywhere.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:06 -08:00
Boris Barbulovski
6a6fe045b4 diveprofileitem.cpp improvements
* Initialize/construct all variable members in constructor list.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:06 -08:00
Boris Barbulovski
38f0104d10 DivePlotDataModel improvements
* Add missing improvements::diveId variable member to the initialize list.
* Cleanup DivePlotDataModel::pInfo structure instead only one member.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:06 -08:00
Boris Barbulovski
6ae870bd22 Initialize variable members in DiveCartesianAxis class.
* Initialize variable members in DiveCartesianAxis class.

Note: Initialized values I put needs to be doublechecked.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:06 -08:00
Tomaz Canabrava
39a11d7092 Fix placement of notification area and dive computer name.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:22:42 -08:00
Tomaz Canabrava
cacf5b3b24 Fix the rest of item visibilities and a few alignment fixes.
Every item is now back on the profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:22:30 -08:00
Tomaz Canabrava
c05575e103 Re-enable more items on the new profile.
Temperature and DC Label.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:22:17 -08:00
Tomaz Canabrava
4882336315 Partial pressures and cylinder pressure back on profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:21:50 -08:00
Tomaz Canabrava
7fbeb71dce Remove code that was unused.
Ancient code that was unused and only adding complexity to the
DiveCartesianAxis.

Also remove the spacing between the text and the lines of the Axis.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:21:28 -08:00
Tomaz Canabrava
0ad2a69c42 Show the profile again.
This patch re-enables a few items on the profile, most notably, the
profile itself.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:21:13 -08:00
Tomaz Canabrava
ed72aabde5 Fix time and half of depth lines.
Comment out most of the items on the profile since they are
currently completely broken ( positioning, etc ).

Also, remove the settingsChanged stuff from the DepthAxis because it
doesn't have the shrinked / expanded size on it ( it sits on the profile
code ) so I'll most probably move that to the profile settingsChanged in
the future - or if anyone knows of a better place to have this, I'm all
ears.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:20:18 -08:00
Tomaz Canabrava
266daa326d Start the profile state
The setup of the item positions for the profile state should be done here.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:19:58 -08:00
Tomaz Canabrava
d66e4b5236 Fix the 'Empty' profile state that was broken for ages.
Show a nice poster that Luisa did for Subsurface ( we have a few other
options that I'm waiting her to send. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:18:40 -08:00
Tomaz Canabrava
86bc3bd58f Start to make things sane again...
Change the 'namespace ItemPos' declared on the commit before this one to a
struct that will have all the 'on canvas' and 'off canvas' positions and
representations of all items, so we know where to change.

Also remove the remaining stuff from planer that was going to exist on
this profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:18:12 -08:00
Tomaz Canabrava
9756be59aa Remove duplicated additem
This addItem was being called twice, and a warning that the item was
already in the scene was annoying me.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:17:04 -08:00
Tomaz Canabrava
9cf6b2be6b Break everything to make it correct next time.
This commit breaks the whole new profile. <3
The problem with the old code is that I was using the QStateMachine
and I just got tired of it. I will implement a much-simpler state
machine to do what I want instead of hitting my head on the wall
to understand how that was supposed to work.

This commit also adds a few helper methods to simplify the understanding
of the constructor and tries to make the logic a bit better. No graphics
are being show right now. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:16:16 -08:00
Tomaz Canabrava
6de9b329d1 Huge code cleanup.
This patch starts the cleanup that will take a few iterations to finish.
The current profile code uses QStateMachine, and it's much too verbose
for something we can do with less than a third of its lines of code.

I also added on the beginning of the redesign of the profile code for
planner, edit and a few other things that are going to be ported to
the new profile in the future, but not currently - I just lack the time
to make that work for the next release.

This commit basically:
 - moves all 'new' calls to the initializer-list
 - create a new 'setupItem' private method to concentrate the calls
   that any item will do

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:14:50 -08:00
Tomaz Canabrava
677e75fbe4 Process events just after starting the StateMachine
This is needed because of a braindead issue on the Qt event
loop:

http://stackoverflow.com/questions/10059721/qt-qstatemachine-sync-problems-initial-state-not-set-on-started-signali

For the "event 1" to be received, the machine must already be
in a state that react to that signal. Even it was a queued
connection, the slot would be queued but only after the signal
 was received, which it isn't since there is no connection
yet at that point.

To solve your problem, you can wait for the machine is in
"state A" before emitting the signal:

machine->start();
qApp->processEvents();

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 11:32:44 -08:00
Tomaz Canabrava
49f8456ce8 Remove a lot of unused code.
This will probably be added back in the future, but for now
they have no use and it was making me nauseaus.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 11:32:32 -08:00
Tomaz Canabrava
2a9289ac99 Add an event filter to hide normal tooltips
This patch adds an event filter to hide normal tooltips on the new
profile. All tooltips should be displayed in the Notification Area.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:31:55 -08:00
Tomaz Canabrava
151a90bec0 Big improvement in speed ( callgrind )
This patch makes use of a cache variable instead of creating / accessing a
new one via operator[], because for some reason QGraphicsPolygonItem
doesn't return a reference for polygon and a copy is always made.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:31:11 -08:00
Tomaz Canabrava
ed230f8aac Make the Tooltip Item work on the new profile.
Just refresh the tooltip item.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:29:55 -08:00
Tomaz Canabrava
40cb57b202 Adapt the ToolTip to work on the new profile
With this patch the tooltip is ready to work on the new profile, we just
need to actually use it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:29:19 -08:00
Tomaz Canabrava
19585d9a13 Add the tooltip item to the new profile.
The functionality is not there yet - just the item hovering
the screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:28:21 -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
Michael Andreen
ddd7d2edcc Fix DepthAxis when partial pressures aren't used.
Set showWithPPGraph so that animateChangeLine() is always called the
first time settingsChanged() is called.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 15:36:29 -08:00
Lubomir I. Ivanov
4ccd6fb3b6 Fix the zoom-panning for the new profile
This works in a different way compared to the old widget.
To make it work we use vieport()'s height() and width()
and simplify the scroll position to:
scrollPosition = (mousePosition / totalLength) * scrollMaximum

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 09:27:39 -08:00
Tomaz Canabrava
a649bcc7bc Added Mouse based Zoom / Movement.
This patch uses the same code that lubomir used on the
old profile. It strangely didn't worked - most probably
because the scene has a fixed width() and height() of
100. the zoom works, and the movement works, but only
on the 100 first pixels of the profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 06:30:33 -08:00
Tomaz Canabrava
dc077e7bff Fix hiding the tissues when user set 'show ceiling' to false.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 06:30:33 -08:00
Tomaz Canabrava
7b9400685d Optimizations and fixes on the new profile.
This patch optimizes a few items when hitting the
'save preferences' dialog, since when a preference is
modified, all the items try to reload their visual
based on wether a preference changed or not, the correct
code for 'hey, my pref changed, let's update' needed
to be done.

now the axis will only set a new maximum if it's different
from the old one ( and thus, going to a new dive with
the same maxdepth or maxtime as the old one will not touch
their axis, not triggering gratuitous animations. )

also, the 'incr by 3m' was not being called - it seems
that our 'syncsettings' method is not storing things on
the 'prefs' global var. I added just for the incr by 3m
case, but it's something that we need to check later.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 06:30:33 -08:00
Tomaz Canabrava
25b0a846af Created a method to check if calculations should take place.
Created a method to check if calculations should take place
taking into consideration what changed on the model. if the
model changes *everything*, them, all calculations should
be done, but if just some of the columns of the model are
changed, only those columns should trigger an visual update
on the items.

In theory this patch looks right, but something is wrong (
calculations are not being made. ), so I'll commit this any
how, and fix on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 06:30:33 -08:00
Tomaz Canabrava
042c34df09 Fix positioning of many text items.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-29 09:35:16 -08:00
Tomaz Canabrava
354acb0fe6 Show gradient factor.
The gradient factor is shown with this patch, but the correct position
should still be adjusted.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-29 09:34:31 -08:00
Tomaz Canabrava
ae56119a9a Make the calculated ceiling be preferences aware
This patch only adds preference-awareness for the ceiling.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-29 09:33:01 -08:00
Tomaz Canabrava
607bf47989 Fix an issue added in the last commit
The last commit made the time and all other axis behave like the time
axis. Not cool.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-28 11:31:40 -08:00
Tomaz Canabrava
9f6ebf96a7 Use the same behavior as the old time markers
This commit adds the same behavior for the old time markers on the new
ones.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-28 11:31:18 -08:00
Tomaz Canabrava
7a07665d89 Do not create label if string is empty.
Do not create a text label if the returned string is empty.
Also, fixed a potential crash after not creating a label and adding it to
the list of created labels.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-28 11:29:29 -08:00
Tomaz Canabrava
fcc17c717d Move the 'getSacColor' out of old profile and use it.
This patch makes the color of the cylinder pressure use the sac colors.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27 13:00:29 -08:00
Tomaz Canabrava
c99089e1fa Add settings awareness for the PP graph
This commit is rather big, and I forgot to cut it in pieces.
The first part creates a new 'calculate_gas_information' that will not
fill the profile_info->maxpp member ( that should be removed from it as
soon as the new dialog is finished ). The reason for that is that all of
the profile data will be calculated and the graph needs to update
dynamically, so whenever the settings changes, I ask for the model which
is the biggest graph and replot only the ones we need.

The second part adds a new animation function 'animdelete' to fade-out and
delete the item when it's done. the old function 'hide' did just that but
a hide shouldn't delete anything.

The third part is preferenes awareness for the PP graphs. I created two
new functions that receive the settings key for visibility and use the
QSettings to show / hide them. This also works quite well for the axis;
if no graph is visible, the axis will also hide itself.

The fourth part is colors. The pp graphs now have the correct colors.

And a bit of code cleanup too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27 09:15:28 -08:00
Dirk Hohndel
f4a2ce1017 Fix potential crash at startup
Strangely enough, on the system I build this, I don't see the crash. But
when I create a DMG and run it on a different Mac, it crashes if
updateTicks() is called but scene() still returns 0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-25 07:25:03 -08:00
Tomaz Canabrava
b5e8ef160a Added the Po2 Partial Pressure Graph.
Important to note that no Partial Pressure Graph handles
settings yet.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
1cae362c16 Added the code for the PHE gas pressure.
Using the PartialPressureGasItem the addition of a new partial plot
is very easy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
caa45a1539 Added the first Partial Gas Pressure: PN2
This makes the beginning of the partial gas pressures, there's
two more. but this code uses a good part of the Model View system,
and it's way clearer than the old one. Luckly the other 2
missing items will be even more clear ( the diffs ) to do,
because I just need to create a new PartialPressureGasItem and
set the properties. <3

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
fd45e646dc Added comments explaining why the events are created on the setDive
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
0f5069784d Prevent memory leak by removing the texts on the TemperatureItem
This patch prevents memory leak by adding the text on the list of
'delete me when model changes' items. it also makes things a bit more
snappy because the scene doesn't have to deal with all of the
texts bounding rectangles eveytime.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
43cf4fb984 Move profile item to be used as cache.
the profile item should also use the model to know when to
change something, this makes it happen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:14 -08:00
Tomaz Canabrava
563c39b822 Moved the temperature item as a 'Cache'
This patch moves the temperature item as a cache that will
be updated as the model updates, instead of deleting / recreating
it everytime the dive changes.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:14 -08:00
Tomaz Canabrava
555ca8245d Fix the ghost-text-on-profile regression
The last patch correctly moved the GasPressure item to use
a cache-based system, but ignored the fact that the Gas
pressure text was not being removed from the scene. this fixed
it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:14 -08:00
Tomaz Canabrava
2c2d3351ac Move the creation of the Gas Pressure item to the constructor
This makes the Gas Pressure Item a 'cached' item, when the dive
changes, the item will regenerate the drawing based on it's model.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:14 -08:00