Commit graph

198 commits

Author SHA1 Message Date
Dirk Hohndel
06711732c9 Correct parameter names
It's very confusing when a parameter is called "minutes" but holds
seconds...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 20:55:00 -08:00
Dirk Hohndel
623be2e46f Fix bug in creating dive plan from dive
We don't want to add the last sample - the dive plan functions want to
figure out the path to the surface by themselves and get confused by this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 20:52:28 -08:00
Thiago Macieira
b22f1da59e Fix all leak-at-exit from singletons in Subsurface
Subsurface creates a lot of singleton instances on demand, but nothing
ever deleted them. Since they are singletons, these memory allocations
are technically not leaks. However, they clutter the output in valgrind
and other memory analysers, hiding the real issues.

The solution is to delete these items at exit. For the models and for
gettextFromC, the solution is to use a QScopedPointer, which will delete
its payload when it gets destroyed. For the dialogs and other widgets,
we can't do that: they need to be deleted before QApplication exits, so
we just set the parent in all of them to the main window.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 09:28:42 -08:00
Thiago Macieira
bd7ded8894 Delete the graphics items for the ticks and labels in the ruler
Ruler::updateTicks() was creating them, but nothing deleted them.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 09:25:16 -08:00
Anton Lundin
3fd39a7a87 Remove some constants and use helpers instead
We have allot of helpers, use them instead of local variants.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-27 08:30:12 -08:00
Tomaz Canabrava
c94101dd4f Changing the preferences should update the Add Dive interface
Since all internal units are in mm we needed to only update what's shown
on the interface.

Fixes #299

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-26 12:28:16 -08:00
Dirk Hohndel
995192c5fb Work around QMessageBox not showing its title on Mac
This is a bit hacky and simply adds the title to the message text when
compiling on a Mac, but hopefully this will be enough.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 04:23:10 -08:00
Dirk Hohndel
28ad26e878 Use the correct dive to create the gas list
If we are adding a dive, it's the stagingDive, otherwise it's the
current_dive that we need to look at.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 18:23:14 -08:00
Tomaz Canabrava
732f7a69b0 Better handle the mouse movements on the Add Dive profile
Better handle the mouse movements on the add dive profile,
when outside of the canvas boundaries. It had bugged me for
quite a while, but this is so much better.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 15:43:12 -08:00
Tomaz Canabrava
82ac9ef9c6 Enable gas selection through a context menu
This patch re-enables gas selection through in the add dive profile.
Good thing ( and I really didn't think of that before ) is that
it is less than half of the code of the other implementation.
:D

Fixes #265

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 15:41:34 -08:00
Tomaz Canabrava
25a52056c6 Fixes positioning the first Gas Label on the add dive profile.
We didn't take into account that last == first when checking for
the first item on the list. Now the gas is correctly placed on screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 15:41:11 -08:00
Tomaz Canabrava
f5be24609a Removed obsolete Code ( gaslist on text click )
This commit removes obsolete code, there was a
gaslist selection when user clicked on the buttons, but
this shouldn't be anymore, since the next commit will
add a menu to select the gas for that particular point.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 15:38:58 -08:00
Dirk Hohndel
0877d93457 Quick hack to make the dive add icons smaller
This is about the right size, but the scaling pixelates the icons. So this
is not really a fix, just a hack.

See #269

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 17:01:58 -08:00
Tomaz Canabrava
a63d61042d Change the order of the increase / decrease buttons on the planner.
Change the order of the increase / decrease depth button on the planner
since 'bottom' means increase depth and 'top' means decrease. Sorry
I'm too undiver currently :)

See #269

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 17:01:45 -08:00
Tomaz Canabrava
4433830f55 Anchor bottom of the dive ruler editor ro items on the DivePlanner
This patch is a crude attempt to 'anchor' the bottom of the Dive
ruler editor ( the new graphics ) to the bottom of the scene.
since QGraphicsView doesn't have a good way to modify the origin
point of an item, I'v just shifted all other items up a bit, this
way the 0,0 point is in the bottom of the drawing and I can safely
move it around, making it bottom-anchorable. :D

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 16:43:41 -08:00
Tomaz Canabrava
0c3eef1c4c Just some code cleanup.
This flag is added to all items on the parent, so there's no need
to implement this on all of them.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 16:42:04 -08:00
Dirk Hohndel
8ae8c81d3d Fix various issues with the dive add / edit manual dive code
- get_gas_from_events does NOT always set o2/he. It only updates them IFF
  a matching event is found; so we need to make sure we start out with a
  valid gas mix
- the way we tried to restore the edited dive in case of an edit to a
  manually added that is cancelled was completely bogus. Way too complex
  when we can simply and reliably simply store the dive and then copy it
  back

Fixes #270

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 11:55:56 -08:00
Dirk Hohndel
3801b765ff Don't add spurious 5m/15ft node at 10 minutes when canceling edit
When cancelling the edit of a manually added dive, we should send the
sample with timestamp 0 to addStop - that's a magic value and causes us to
add a node at 5m/15ft and 10 minutes instead. Since the dive always starts
at the surface, calling addStop is redundant, anyway, so let's just not do
that.

See #270

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 10:46:01 -08:00
Tomaz Canabrava
5945c18c8a Removed the ugly icons on the visual profile editor
Removed the ugly icons on the visual profile editor and replaced them with
the much better looking ones that Luisa designed.  This was not a simple
search and replace since Luisa's design was a bit more sophisticated.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-17 15:38:48 -08:00
Dirk Hohndel
962abba1f7 Remove ununsed variables
The warnings are distracting - and the variables are truly obsolete by
now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-17 14:36:37 -08:00
Dirk Hohndel
3b9c28bce7 Don't create stop at time zero when re-editing manually added dive
To our addStop method time = 0 & depth = 0 are a magic flag. And since we
always start at the surface, that is assumed, anyway. So let's just not
add a stop for that when re-creating a plan from a dive.

Fixes #254

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 12:42:21 -08:00
Dirk Hohndel
66f5f32f11 Once again remove debug output.
Oops again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 13:17:38 +09:00
Tomaz Canabrava
cec30c27d9 Enable a context menu to remove dive handlers.
This commit enables a context menu to remove dive handlers,
because it was hard to find that ctrl+click selected it,
then a delete button press removed it. it's better now. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 13:15:35 +09:00
Dirk Hohndel
c0a6c136f0 Fix dive planner widget
In commit 0f50b73f9e ("Fix planner / add dive handling of DiveHandler
Points") some issues were introduced. While it is fine to remove the
artificial first point at the surface, the commit broke the special
handling for o2 == -1, i.e., the usual case where a default gas needs to
be picked.

This generalizes the algorithm previously used to also look to the right,
now that we are no longer guaranteed that there is a first point to our
left.

This also cleans up some whitespace damage introduced in the same commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 11:54:13 +09:00
Tomaz Canabrava
0f50b73f9e Fix planner / add dive handling of DiveHandler Points
Dirk, is this really necessary or it's just something that you forgot
to remove? this is adding a bit of pain to fix some issues on the planner,
so I'm commenting this out untill you have a bit of time to look at it.
It looks like this was added to handle the gas in the pos-1, but you reverted
if so, this completely reverts it, and things works as expected again.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:27:41 +09:00
Tomaz Canabrava
1ee08005b2 Adds the first DiveNode at 5meters / 10minutes when clicking on plus
Adds the first DiveNode at 5m / 10 minutes when clicking on the plus
button on the DiveNotes Table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:27:13 +09:00
Tomaz Canabrava
2235da57a7 Fix adding DivePoints on the planner via the table.
Somewhere we broke this, most probably in the code that activated the
planner to be used together as an 'add dive'. This commit makes the code
workable again.

There's one thing, though. if the model is empty, this will add something
in the first point - it's behaving strangely. I'll try to fix this in a
way that's invisible to the user, but overall, why are we inserting
something in the first(0,0) time and depth?

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:21:50 +09:00
Tomaz Canabrava
96d5687ab8 Correctly handle changes on the CylinderModel to update the AirModel.
What happened before was that the AirTypes model was only being updated
when the user requested to change the air by clicking directly
on the Air, in the planner ( but not on the Air Table. ).

This fixes it by calling 'repopulate' whenever the cylinder model
changes ( by adding, removing and changing something.)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:19:14 +09:00
Tomaz Canabrava
b77d990ed6 Close the Air list when clicking outside of it.
This patch closes the air list when clicing outside of it,
making the use of the planner more pleasant.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:16:22 +09:00
Anton Lundin
419e425030 Remove some unneeded member functions
We can wire qt to call the right functions directly, so we don't need
these members.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 08:59:46 +09:00
Anton Lundin
83426c59e1 Planner: Default to GF from prefs.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 08:59:01 +09:00
Anton Lundin
bc6a1a4c53 Planner: use a QSpinBox for GFLow/GFHigh
Switch to using a QSpinBox instead of a QLineEdit. This makes it a bit
more intuitive and now you can see how the deco plan changes based on
the GF's.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 08:58:35 +09:00
Dirk Hohndel
8d284b0e24 Hook up the tank change and tank update for the planner
This failed spectacularly when I first tried it, so I put it on the back
burner. And it appears that with all my recent fixes for "add dive" as a
side effect this is working, too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:58:04 +09:00
Dirk Hohndel
9c90d6790a Fix some random compiler warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:06:31 +09:00
Dirk Hohndel
f6eb26dbae Handle tank data correctly in profile editing mode for manually added dive
This is subtle. Normally you would expect someone to edit the tank data by
simply clicking on it in the equipment tab. But a user could conceivably
edit the tank data after clicking on the profile editing button instead.
This works now as well.

This also addresses the issue that start and end pressure were not shown
in profile editing mode.

Fixes #235

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 18:36:21 +09:00
Dirk Hohndel
98322a976c Correctly convert an existing dive into a plan
I missed this one spot when converting back to the different semantics for
divedatapoints.

With this change add dive appears to work correctly (fingers crossed).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 22:39:53 +09:00
Dirk Hohndel
bb041069a3 Fix addGas to look at the correct cylinder
That was a stupid bug. You have to actually update the variable to look at
the right cylinder. Duh.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 22:38:14 +09:00
Dirk Hohndel
1a3ea5636a Don't change gas used in segments if there is still a cylinder with that gas
Otherwise adding a second cylinder (to the default one cylinder of air)
and subsequently changing the gas of that cylinder will illogically change
the gas used in all the segments.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:56:51 +09:00
Dirk Hohndel
d7fb6853a3 Connect changes in the tanks with the dive that is being added
- you can no longer delete a tank when its gas is in use
- therefore you can no longer delete the last tank
- when you change the gas mix of a tank, the corresponding segments in the
  dive change as well
- when changing gas for a segment the correct available gases are offered

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:56:22 +09:00
Dirk Hohndel
aa76d35923 Instead of a "Cylinder for planning" use a default cylinder
Right now hardcoded to AL80. This way in the future we'll have a volume of
gas that's available. And this makes much more sense then a random string
in the description field.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:45:24 +09:00
Tomaz Canabrava
b98157a519 Partially revert d72c69db7a and fix its errors
In the offending commit a QWidget was changed to QTableView, but
only in the header - and thus making avaliable all method calls,
but the initialization of the widgets was still a QWidget, and
nothing of QTableView was used besides an incorrect call to
setColumnHidden.

This commit fixes that by using the view() method provided by the
TableView implementation which returns the true QTableView that should be
used for specific nitpicking, like hidding columns. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:58:47 +09:00
Dirk Hohndel
a683a217b9 First steps to make add dive work with the correct infrastructure
This just makes sure that we do the right thing with the staging drive,
that we don't mess up the selection, the we are smart about using our
helper functions, etc.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 14:21:50 +09:00
Dirk Hohndel
94222fbe49 Remove some debug output
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:20:23 +09:00
Dirk Hohndel
ad4812c22e Make planner work again
This partially reverts changes in commit 1b655d5c806b ("Correctly track
gases when manually adding and then editing dives") as it turns out this
did NOT help us correctly track gases (which is ironic, given the title of
that commit). I didn't actually want to revert that commit as
infrastructure has changed since then and this made the patches look even
more incomprehensible.

So we are back to tracking the "gas on which we arrive at this spot" in
each dive plan node as this makes the rest of our planning so much easier
- I had forgotten about the reasons why we did things this way when I made
the above mentioned commit.

Instead we now make sure that our available tanks are added the correct
way, that such entries are ignored when planning and when drawing the
editable profile, and that at the end it all gets assembled correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:19:04 +09:00
Dirk Hohndel
d72c69db7a Add depth colum to cylinder model
To make the planner work this adds a new column to the Cylinder widget
(depth - for the depth at which we want to change to a certain gas
during deco).

This also tries to hide that column in the equipment view and hide the
start/end pressure columns in the planner view. Oddly that fails :-(

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:17:40 +09:00
Dirk Hohndel
cd1149e57f When entering a new point, pick the previous gas by default
This is much more useful than always picking air.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 18:13:55 +09:00
Dirk Hohndel
0a8892379d Connect cylinders entered in planner with the gases available
Now the gases for which we have cylinders are offered in the gas selection
list and correctly recognized and added for the plan.

Still tons of work to be done to make this work the way it is designed,
but we are getting closer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 17:09:19 +09:00
Dirk Hohndel
e5098c443f Hook up delegate to enable cylinder autocompletion in planner
That was easy

Hand-holding-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 05:51:39 +09:00
Dirk Hohndel
55c127f7c3 Enable adding cylinders in the dive planner
This is in preparation of using those to define the gases available for
planning.

Right now this doesn't seem to work quite right - I don't get the
auto-completions for the cylinders that I was hoping for...

This commit also corrects the tooltip for addint dive data points.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10 21:02:53 +09:00
Dirk Hohndel
aa4931e8c6 Show a cylinder widget in the dive planner
This is intended to allow the user to provide the gases / cylinders that
she will be diving with. With that information the planner can warn the
user about insufficient gases, but more importantly it can show relevant
gases in the gas select drop down.

Right now the add cylinder button doesn't add a cylinder - that's a
problem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10 07:07:59 +09:00