Commit graph

427 commits

Author SHA1 Message Date
Dirk Hohndel
7f3efbdc98 Make gas mod be reasonable for users of imperial units as well
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 21:41:58 +08:00
Robert C. Helling
65c5d6815c Make pO2 settings functional in planner
Spin boxes for pO2 are now hooked up to preference values. Adding new
cylinders (or changing their fo2) computes the MOD accordin to the current
value of decopo2. Note that chaning the limits for deco pO2 does _not_
automatically update the switch depth of all cylinders as those might have
been manually entered.

Furthermore, MOD has now to option of rounding to multiples of a given
depth. That is used for the automatic switch depth which are now always
multiples of 3m (so that EAN50 is switched to at 21m rather than 22m).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 21:07:10 +08:00
Anton Lundin
c7231adde1 Connect prefs.descrate to drop_stone_mode points
This enables so we can change the decent speed for drop like a stone
mode.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 20:53:05 +08:00
Anton Lundin
f2afddf4ad Fix typo in connecting ui.descRate to setDescRate
Qt didn't find the right function without the type there. This also gets
rid of the warning about that.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 20:52:49 +08:00
Robert C. Helling
772727fc7f Hook up UI elements for ascent rates to planner
That provides some UI elements that were recently introduced with function
of allowing the ascent rates of the planner to be configured by the user.

I tried to make it work both with senisble as well as with imperial units.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 13:48:44 +08:00
Anton Lundin
ccfdcca6e6 Drop like a stone mode in planner
Most of my dives i plan i know it will just be full speed down a line in
the beginning and thus the planner can figure out that leg of the plan
by it self.

The config box added here isn't connected, because i saw that the other
planner boxes wasn't connected ether, so i left it in the same state as
they where.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-24 17:26:31 +08:00
Anton Lundin
5904be2e06 Fix NO_PRINTING building again
Back in 6699e3ab ("Add print button to planner") unconditional printing
code was added. This puts that same code behind NO_PRINTING macro.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-24 17:18:58 +08:00
Henrik Brautaset Aronsen
630ec88dd4 Be more consistent in partial pressure naming
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:48:54 +08:00
Anton Lundin
bb44908507 planner: Switch to QSpinBox for SAC
QSpinBox is nice to see how different sac rate would affect our dive
plan.
"Hey, What would happen if I would be stressed and my sac goes up by 50%?"

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20 06:37:44 -07:00
Robert C. Helling
708f19830e Planner: New plannerSettingsWidget
In planner mode, this replaces the globe with the dive plan and introduces
a new plannerSettingsWidget in the diveListPane. All new fields are still
disfunctional. This is WIP.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-12 09:30:46 -07:00
Dirk Hohndel
79c68367c6 Fix uninitialized memory warning
It's kinda bogus, but since we add it to the Vector, we might as well
initialize all of it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 14:07:57 -07:00
Dirk Hohndel
e4a9fa74e8 Planner: don't reset GF when preferences change
The planner has its own view of the gradient factors. So replacing those
with the ones set up for viewing dives in the preferences is wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 09:28:17 -07:00
Dirk Hohndel
6daeb276ad Planner: reset GFlow and GFhigh when we're done
While planning we might change the gradient factors. Make sure they are
back to what's in the preferences when we're done planning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 09:11:34 -07:00
Dirk Hohndel
c92bb9e021 Planner: don't redo the plan after partial edits of GFlow/high
In most cases this wouldn't really matter, but when planning very deep or
very long dive with corresponding very long deco times, calculating the
deco takes long enough to make this notable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 09:34:08 -07:00
Dirk Hohndel
5bc5cae6dc Planner: only copy cylinders that were used in the template dive
This was only semi-implemented the first time around. Now we really only
copy the ones that are indeed used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 23:09:12 -07:00
Dirk Hohndel
09403f3724 Planner: reject plan if escape key is pressed
This seems intuitive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 15:30:27 -07:00
Dirk Hohndel
2cfa7fead0 Planner: fix editing the dive planner points table
The edit starts with the current value, but our data() function didn't
return that in the edit role.

Thanks Tomaz for explaining this to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:44:05 -07:00
Robert C. Helling
6699e3ab3e Add print button to planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:23:43 -07:00
Robert C. Helling
90885bfb8e Optionally strip diveplan to bare minimum
There are new check-boxes to modify the look of the diveplan in the notes.

The old behaviour appears with "verbatim display", others are shorter,
runtimes, stoplengths and transitions being optional.  Also round to full
meters and minutes to remove optical clutter.

To be done: Remember these setting in the config.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 12:40:36 -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
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
Dirk Hohndel
fe773241ee Next step to using gasmix instead of o2/he
This changes the divedatapoints and functions that deal with them.

It changes plan_add_segment(), create_dp(), gasToStr(), and tankInUse() to
consume gasmix instead of o2/he.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:40:46 -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
c539c8f861 Remove the .used member of the cylinder structure
Instead calculate this information on the fly, taking into account all
dive computers on the dive in questions.

There is one wrinkle to this - previously we abused the '.used' member to
make sure that a manually added cylinder didn't disappear the moment it
was added (think of the workflow: you add a cylinder, then you add a gas
change to that cylinder -> right after you add it it is unused and would
not be shown).

I am thinking that we might have to add the "manually_added" property to
the properties that we store in XML / git.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 12:43:40 -07:00
Dirk Hohndel
ac1168f186 Revert "Show the calculated deco stops in the planner table"
This reverts commit 7d42b53bba.

With the addition of the dive plan details widget we no longer want to
show the deco points in the dive planner points table.

Conflicts:
	qt-ui/diveplanner.cpp
2014-05-31 21:36:35 -07:00
Dirk Hohndel
ed26dfdd6b Planner: don't include the disclaimer in the dive plan detail widget
We want the disclaimer in the final dive that can be printed, but it's
distracting when shown while planning the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 21:25:03 -07:00
Dirk Hohndel
6333f3aa35 Planner: show the plan notes in the new widget
That was easy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 21:14:44 -07:00
Robert C. Helling
eb26823b34 Allow editing segment duration. This shifts all following waypoints.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 06:26:55 -07:00
Dirk Hohndel
6f1e071a54 Planner: don't recreate the dive while cleaning up the widgets
Otherwise the change to the Cylinder widget would trigger a recreation of
the dive in an inconsistent state.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 16:12:35 -07:00
Dirk Hohndel
a0136a3b8c Planner: remove check for empty diveplan
This was introduced in commit fc13361079 ("Don't crash if we try to save
a empty plan") - but it doesn't seem to make any sense. It is perfectly
reasonable for the diveplan to have no datapoints at this spot - we are
just about to call createTemporaryPlan() which will fill those datapoints
from the mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 15:47:42 -07:00
Dirk Hohndel
65f3135a92 Planner: don't do unnecessary work on empty dive plans
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 15:40:13 -07:00
Dirk Hohndel
b36f8dd738 Planner: after freeing the plan, throw away the pointer
Otherwise we'll happily go back and access the freed data structures
later. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 11:01:37 -07:00
Tomaz Canabrava
f9166e3c0e Do not offer an editor when double-clicking REMOVE on the planner.
The  planner would offer an text-editor if the user double
clicked it's remove column. forbidding that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:39:33 -07:00
Tomaz Canabrava
e7f764b090 Do not show 'trash' icon for deco stops.
Besides not deleting them, we shouldn't offer the icon for it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:39:16 -07:00
Tomaz Canabrava
221b1a9e01 Do not remove a Deco Stop by clicking on the trash
This patch forbids deletion of the Deco Stop from the
QTableView that holds the model.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:39:02 -07:00
Robert C. Helling
7d42b53bba Show the calculated deco stops in the planner table
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 15:12:49 -07:00
Dirk Hohndel
d054e8c457 Planner: track gas consumption in cylinders and samples
This commit is a little bigger than I usually prefer, but it's all
somewhat interconnected.

- we pass around the cylinders throughout the planning process and as we
  create the plan we calculate the gas consumption in every segment and
  track this both in the end pressure of the cylinder and over time in
  the samples
- because of that we no longer try to calculate the gas consumption after
  being done planning; we just use what we calculated along the way
- we also no longer add gases during the planning process - all gases
  have to come from the list of cylinders passed in (which makes sense
  as we should only use those gases that the user added in the UI or
  inherited from a the selected dive (when starting to plan with a dive
  already selected)

With this patch I think we are close do being able to move all of the
planning logic back into the planner.c code where it belongs. The one
issue that still bothers me is that we are juggling so many dive
structures and then keep copying content around. It seems like we should
be able to reduce that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 14:43:24 -07:00
Dirk Hohndel
b37422c447 Planner: record the new dive at the correct time
We don't want to do this when calling plan() from createTemporaryPlan() -
we only want to record the dive at the end of createPlan().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 22:16:15 -07:00
Dirk Hohndel
03eba8f99d Planner: always recreate staging dive
Instead of even trying to keep one around (which then could cause all
kinds of trouble) we now always delete it at the end of the planner.
So simply always recreate one when starting the planner (and make sure
that the staging dive has always been cleared out, first).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 22:15:44 -07:00
Dirk Hohndel
ff7bff48b8 Planner: make sure stagingDive is reset to NULL
If we first ADD a dive and then PLAN a dive, stagingDive first was an
alias to the current_dive (for ADD) - we need to make sure that when PLAN
is started, a new dive is allocated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 21:34:10 -07:00
Dirk Hohndel
6576790ff6 Add dive: only copy cylinders when necessary
If the stagingDive is just an alias for the current_dive (as it is in dive
ADD mode), there's no need to copy the cylinders; they are already there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 21:30:21 -07:00
Tomaz Canabrava
86d7f6ace0 Move code from the Planner that doesn't belongs there.
Moved the connections between DivePlannerPointsModel and
MainWindow from inside the Planner class to the MainWindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:02:46 -07:00
Dirk Hohndel
412317c91f Planner: set up a cylinder, even if no current dive is selected
If there was no current dive we didn't set up any cylinder at all which
was a bit awkward as we use AIR but have no cylinder corresponding to it,
which breaks assumptions elsewhere.

Instead we use either the default cylinder or make one up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:01:18 -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
Dirk Hohndel
e4a438c96c Dive planner: remove the fake dive earlier on cancel
This way it's already gone from the dive list before it gets reprocessed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 10:13:24 -07:00
Dirk Hohndel
c88a90f379 Planner: correctly refresh the display
We were making things way too hard (and were doing things that don't need
doing, like clearing the DivePlanPointModel).

Currently we still crash after manually adding a dive or when canceling
a plan.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:44:47 -07:00
Dirk Hohndel
1f2159dd0c Planner: return Profile widget to profile state
This still crashes when canceling the plan.
And doesn't display the correct dive profile until you switch to a
different dive and back.
And Keyboard focus is wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:27:53 -07:00
Dirk Hohndel
7bed6e9873 Planner: use the gas in the first cylinder for initial plan
As Tomaz suggested, I don't need to pass the information whether we are on
the planner into the function - it's part of the DivePlannerPointsModel
and therefore already knows.

Also, we want to make sure we actually use the gas that's in the first
cylidner of the staging dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:12:41 -07:00
Dirk Hohndel
d1cd1eb933 Planner: better handle the temporary dive used for planning
This still crashes when you abort the plan.
And when you accept the plan, the profile stays stuck in PLAN mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:12:41 -07:00
Dirk Hohndel
9cc8e39d42 Merge branch 'Planner' 2014-05-26 13:28:18 -07:00
Dirk Hohndel
42c54e7b7e Planner: copy samples and events for plan and add
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:23:52 -07:00
Dirk Hohndel
660235c9b7 Planner: Don't include the ascent in the default dive
Allow to both create the full default dive or ownly the descent and bottom
part (so the planner can deal with the ascent).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:19:35 -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
Dirk Hohndel
a61c04bb58 Merge branch 'atdotde'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	qt-ui/diveplanner.cpp
2014-05-26 09:59:08 -07:00
Robert C. Helling
1093d6235b Reenabled copying the diveplan to dive notes.
Gas consumption calculation fixed. Pressure difference still needs cylinder size to be set.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 09:58:23 -07:00
Dirk Hohndel
cfe865dd0c Merge branch 'atdotde'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	qt-ui/diveplanner.cpp
	qt-ui/models.cpp
2014-05-26 08:23:22 -07:00
Robert C. Helling
04b6b6aaf9 Use get_o2() and get_he() instead of accessing permilles directly
This gets rid of problems with air.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 08:12:32 -07:00
Anton Lundin
ff966f2c1a Move mod calculations to a separate helper
We use mod calculations on multiple places, so make a separate helper
from it with proper types.

The "clumsiness" of defining a local variable to pass into the function
and out from it comes from the discrepancies in how c and c++ handles
initializations of variables in a struct.

Thanks goes to Tiago and Linus for pointing me in the right direction.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25 06:20:52 -07:00
Tomaz Canabrava
b88e6dc5fa Remove leftovers from the planner.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 21:11:55 -07:00
Tomaz Canabrava
2d41c4da09 Reenamble 'Delete Dive Point' on the planer / add
Just removed an #if 0

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 21:11:21 -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
93f35971c6 Remove the depth / time increase and decrease functions.
The new profile code handles the resizing of the profile area in order to
accomodate the depth and time of the dive much more intuitively - the old
manual buttons to do so are no longer needed.

This also removes a few other unused methods.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:34:32 -07:00
Tomaz Canabrava
8a1e4b04db Remove unused code.
This code is not ported to the new profile, but from what I
can understand from it, it doesn't need to be. The purpose
of this code was to setup the correct colors and strings
for the current mouse position, we already do this on the
Profile in a different way, on the Notification Area.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:32:01 -07:00
Tomaz Canabrava
e6c294f718 Remove code already ported to the new profile.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:31:27 -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
Tomaz Canabrava
e1dcd8eac3 Change how the handler handlers itself.
This patch adds a itemChange method, that emits a 'changed'
signal when the handler is moved. I'll use that signal on
the profile to call the correct method.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:26:53 -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
f24f0f3936 Good code cleanup on the old DivePlanner code.
All code that was removed already is working on the New Profile,
The code that's behind #if 0 means that it still needs to be ported and
because of some removal, it was not possible to keep it compiling (mostly
the removal of the Ruler class, that is the Axis, on the new profile).

The rest of the code that's untouched - most probably will keep that way.
The DivePlannerPointsModel is correct and well done, no need to change
that, only the Graphics part.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 14:41:37 +09: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
c6ad04d076 Code Cleanup: connections can be made between signals.
A signal can connect to another signal, so I removed a slot that had the
sole purpose to call another signal and replaced that with a direct call.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 14:32:26 +09:00
Tomaz Canabrava
b31becd2d9 Remove silly macro to pretend that we were doing things the right way.
That macro was useless, I should have been drunk when I wrote it, and I
don't drink.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 14:27:31 +09:00
Robert C. Helling
9a4f8b50bd When starting the planner, copy cylinders from currently selected dive.
This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 14:58:47 -07:00
Robert C. Helling
e3ef1b7a1e Planner: show gas for the NEXT segment
For deco stops show the gas of the next segment in the table. In
recalculation remove old deco stops earlier.

In struct diveplan, the items are "segments" with a beginning, a duration,
and a gas. In contrast, the UI of the planner uses "waypoints" which are
the boundaries between segments. It is conventional at least for deco
stops to display the gas of the _next_ segment in the runtime table (i.e.
the gas possibly to be switched to).

Furthermore, in addStop, the old deco stops have to be removed earlier as
otherwise a new waypoint later than a previous generated gas switch
inherits the gas of the old switch.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 13:13:49 -07:00
Robert C. Helling
00e7ef2cf8 Planner: Change when we recalculate deco
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 12:25:38 -07:00
Dirk Hohndel
d191f5af6f Remove unused variables and fix signed/unsigned mismatch
The depth types are unsigned for dive plan datapoints.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18 13:06:21 -07:00
Dirk Hohndel
0a018f30de Fix crash when manually adding a dive
When a manually added dive is saved we cancel the plan. In that process
we throw away the cylinders which triggers a redraw of the profile. Which
tries to access the diveplan and its data points that have already been
freed. BOOM.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18 10:21:58 -07:00
Robert C. Helling
cb4daa85c3 Comments added to planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18 10:01:46 -07:00
Lakshman
e871169e4c Fixed mismatched connections
Fixed connections to call drawProfile() in diveplanner whenever cylinder
table widget is edited.

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 22:39:36 -07:00
Tomaz Canabrava
f14c14c383 Mark a lot of TODO's where I think it should be moved to C code.
This marks a lot of todo's where I think there's core stuff being mangled
on the interface - we should remove this from the interface to make
testing and maintenability easier.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 08:33:51 -07:00
Dirk Hohndel
1a1cbc296b Quick whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 08:06:11 -07:00
Robert Helling
9ddef367b5 Improvement for various bits of the planner
Rewrite of the actual planner logic. Now ascend to the next potential stop
depth. There the state is cached and we try to ascend to the next stop
depth. If we hit the ceiling while doing that we go back to the cached
state and wait there for a minute. Then we try again. Then loop.

Converted all depth related variables from unsigned int to int. During
planning, in a time step the current depth can temporarily be negative and
comparisons of a negative int with an unsigned it have not the result I
expected ( (int) -2 < (unsigned int) 3 turns out to be false). And we
don’t really need the 32nd bit that unsigned buys us for depths.

Deco stops are now shown in the same table as manually entered stops in
boldface (I removed the second table to save screen estate).

The gas shown in the table is still misleading as it means the gas used on
the segment leading up to that event.

The update of the profile only works partially upon changes in the list of
available gases.

Treatment of various gases is basically there but needs some more love.

The ascent velocity is now provided by a function that takes the current
depth as argument. Currently it always returns 10m/min but that will later
be variable (and hopefully user configurable).

The profile is not redrawn while deco is computed (avoiding an infinite
recursion).

The table got a new column for the duration of a segment while the old
“duration” column was renamed “Runtime” to reflect what it actually shows.
Currently, only the run time but not the duration are editable.

All deco gases are used from the depth where their pO2 is 1.4bar. This
should become more flexible.

Calculation of the pressure drop in cylinders without configured volumes
is suppressed. This solves a problem with the planner crashing when saving
a dive where not all cylinders had been manually given a volume.

[Short rant break: Treating 0/0 as air bites back at so many places. E.g.
Cylinder data is initialized with memsetting the whole structures to 0.
Then later suddenly this totally unconfigured cylinder is being treated as
it would contain air. Maybe at some point this was a feature. But it lead
to a naughty bug which took me over an hour to resolve. We should
seriously reconsider this choice and better move to 209/0 being air if
changing this everywhere is not too much trouble]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 07:29:44 -07:00
Lakshman
4722104e1c Add missing REMOVE slot
Model derived from tableview is expected to have remove slot,
which is missing in DivePlannerDisplay currently. This patch fixes
the annoying warning message while starting Subsurface because of
not including remove slot.

Currently there is lot of work to do, that either requires modifying
the model to skip 'remove' slot or find a way to make them inactive.

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-02 10:21:02 -07:00
Lakshman
b629905ec5 Make compute waypoints content uneditable
Currently user can edit content in compute waypoints table
(in PLAN mode), ofcourse this does not trigger any calculations in
the code, but user cannot see the content he needs to see after edit.
This patch makes the content uneditable.

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-02 10:16:06 -07:00
Dirk Hohndel
0de21c24fa Merge branch 'planner-mods'
Nothing exciting here, just a few independent changes close to each other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31 22:18:00 -07:00
Lakshman Anumolu
18ec989ef5 Diveplan with entered and computed waypoints to UI
Recently Robert Helling provided a patch "Distinguish between entered and
calculated waypoints" in an attempt to distinguish between entered and
calculated stops.

This patch is an independent (content wise) extension of the above
patch and is built relative to it which adds new table to display
computed waypoints in plan mode.

Currently table includes only two columns "Comp. Depth" and "Comp.
Duration", which can extended to show further information.

This is only a start to the UI interaction in PLAN mode.
In addition to this there are many TODO things that diveplan feature
demands

TODO:
1. Show more details through "Computed Waypoints" table.
2. Remove tooltip from "Computed Waypoints" table widget.
3. Make contents in "Computed Waypoints" table widget non-editable.
4. Fix error when trying to save dive plan without using cylinder data.
5. Make dive plan editable after saving it.
6. Improvise dive planner graphics window.

Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31 22:01:16 -07:00
Robert C. Helling
30bdfc8160 Distinguish between entered and calculated waypoints
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31 22:01:05 -07:00
Anton Lundin
fc13361079 Don't crash if we try to save a empty plan
Just treat it as a cancel instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23 17:24:42 -07:00
Anton Lundin
8bc2ad1473 Enable parts of planner based on define
In bf205726 DEPTH/Switch at was disabled by commenting out that code.
This puts it back behind ifdefs

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23 17:24:40 -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
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
Linus Torvalds
609715ab69 Convert other users of showError() to the new world order
The "report_error()" interface is a lot simpler, although some of the
C++ code uses QStrings which make them a bit annoying, especially for
the varargs model.  Still, even with the explicit conversion to UTF8 and
"char *", the report_error() model is much nicer.

This also just makes refreshDisplay() do the error reporting in the UI
automatically, so a number of error paths don't even have to worry.  And
the multi-line model of error reporting means that it all automatically
does the right thing, and reports errors for each file rather than just
for the last file that failed to open.

So this removes closer to a hundred lines of cruft, while being a
simpler interface and doing better error reporting.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14 12:36:06 -07:00
Tomaz Canabrava
5bba84e57f Fix colors on the new profile.
This patch fixes the colors on the new profile, the init of the colors map
was not being done. This fixes it.

A few problems were spotted on the new profile dealing with the ruler
graph and a newly added dive, when using the dive add dialog.

I'll be on it later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 20:37:17 -08:00
Tomaz Canabrava
ac9a23ef3b Remove the old profile from the main screen of Subsurface
This patch partially removes the code for the old profile from
Subsurface. It removes the use of the old profile on the mainwindow,
but keeping the code in the tree for now.

A bit of code-cleanup also entered this commit because I had to change
every instance of the code that used the old profile.

Now to the real code-cleanup

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:54:20 -08:00
Dirk Hohndel
c64227efe0 Fix real memory leak
We can't keep the cache around (even though it's tempting) as the next
iteration might change the start time of the planned dive or other
parameters which would make the cached data invalid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06 14:26:33 -08:00
Andrey Zhdanov
64b7a3b85f Depth widget minor UX improvement
Decrease depth by tapping left part of widget. Icon is showing "up" (i.e. closer to surface).
Increase depth by tapping right part of widget. Icon is showing "down" (i.e. deeper).

Fixes #354

Signed-off-by: Andrey Zhdanov <andrjufka@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 13:33:03 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -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
Dirk Hohndel
11559f1704 Don't reuse a variable name with a different type inside the same function
Since the variable was inside of an inner scope this was technically legal,
but it's just too annoying for words.
(The diff in the commit doesn't make this obvious, but outside the for
loop in the same function there is a divedatapoint *dp, so we had a
pointer to divedatapoint and a divedatapoint with the same name...)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 05:43:31 -08:00
Dirk Hohndel
ffc61e1357 Don't use current_dive instead of the argument to the function
I could have gone either way - the other alternative would have been to
remove the argument to the function. But since current_dive is a macro
and since the semantic of the function make sense with the argument being
passed in, it seemed better to just not use current_dive in the function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 05:37:18 -08:00
Boris Barbulovski
a3d82bf9b1 Update #include statement for QStringListModel
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:36:53 -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
Boris Barbulovski
d48910b711 more diveplanner.cpp improvements
* Move variable members construction to the initializer lists.

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
9ffb459ff3 diveplanner.cpp improvements
* Add missing variable members to the initializer lists.
* Add *lazy* structure initializations.

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
2d3e48f4ae diveplanner.cpp cleanup
* Add missing DivePlannerPointsModel::tempDive to the constructor
  initialize list.
* ExpanderGraphics class: Construct pointer-variable members into
  initialize list,

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:41:49 -08:00
Dirk Hohndel
bf20572630 Disable the switching depth column for cylinders
Since the planner is disabled this column isn't needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26 07:37:11 -08:00
Dirk Hohndel
f11001ff4e Don't dereference NULL pointer when adding tanks to a dive plan
The code was obviously bogus before.

Fixes #429

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26 07:22:54 -08:00
Dirk Hohndel
733108b473 Fix potential crash in getColor functions
If the index is out of range, just return black.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-18 14:37:08 -08:00
Boris Barbulovski
6cc65f5e1c Fix some memory leaks.
Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:15:47 +07:00
Dirk Hohndel
a27f67c026 Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...

This commit should ONLY change whitespace

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 11:50:56 +07:00
Anton Lundin
7e9582631d Convert to TRUE/FALSE to stdbools true/false
I had problems with this one on Qt5.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15 15:52:31 +07:00
Tomaz Canabrava
09096f9af4 use qMakePair helper instead of QPair<int,int> and such.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:12 -08:00
Tomaz Canabrava
1a933e7e19 Don't use QList if sizeof(item) > void*.
QList is optimized for storing pointer-sized items, thus
a QVector is the better choice for everything else.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 07:24:11 -08:00
Dirk Hohndel
4ab58d6b47 Use M_OR_FT macro instead of switch statement
This is easier to read and also avoids an incorrect gcc warning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:06 -08:00
Anton Lundin
a84826090a Planner: don't abort when saving a dive
The fix for dereferencing a null pointer from me was a bad fix that
broke the possibility of saving a planned dive as a dive.

This is a better fix to not dereference a null pointer and be able to
save the plan again.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Tomaz Canabrava
9a497b1cb0 Keep track of the minimum Depth / time on the planner.
This patch makes sure that the minimum time / depth is
correctly set on the profile planner.

Fixes: #358

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:26:39 +01:00
Anton Lundin
82b86fe924 Fix potential null pointer dereference
If createTemporaryPlan was called on a empty diveplan.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11 03:13:30 +01:00
Lubomir I. Ivanov
cf9748278f Planner: fix potential assert in clear()
If rowCount() is 0 we get an assert:
ASSERT: "last >= first" in file kernel/qabstractitemmodel.cpp...

To solve that we wrap the beginRemoveRows() call in a bnrach:
if (rowCount() > 0) {
...

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-10 05:22:01 +01:00
Anton Lundin
6ff345731b Fix another potential crash
Initialize diveplan.dp to NULL, so we know that we will bail in
drawProfile, when the initial settingsChanged is fired.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09 21:40:12 +01:00
Anton Lundin
35b0924335 Fix potential crash
Initialize stagingDive to NULL, so we know that we will bail in
createTemporaryPlan, when the initial settingsChanged is fired.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09 20:11:12 +01:00
Anton Lundin
e6c51cc314 Implement a settingsChanged in DivePlannerWidget
This is so we can default to the GF's from the preferences. We need the
bail handler in createTemporaryPlan, because its triggered when we
change GF's, and if we don't have a stagingDive there, we will access a
NULL-pointer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09 07:51:40 +01:00
Anton Lundin
44848d5457 Keep track of user requested minimum depth
When got auto-rescaling of the depth scale, always reset the depth scale
to what the profile would suggest. This introduces a concept of user
requested minimum witch we will update and not scale down to lower than.

Reported-by: Henrik Brautaset Aronsen <henrik@synth.no>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 16:20:40 +01:00
Anton Lundin
f96ea9cc9a If we have defined a gas, default to that one.
If we start to define a gas, we should use that one by default instead
of air.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 09:42:15 +01:00
Anton Lundin
01e3210725 Calculate gas consumption for planned dives
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 09:42:03 +01:00
Anton Lundin
1ec61e1288 Remove the air point at 0,0
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 09:41:31 +01:00
Anton Lundin
4c3f51291e Show CC-sp in bar, and not mbar
Fixes #257

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 08:09:05 -08:00
Anton Lundin
bb979260b0 Fix gas for start dp
It previously always started with o2 in air, now we start with 0 as its
the same default as in the cylinders too, which fixes a uninitialized
index there too.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 08:09:05 -08:00
Anton Lundin
90634b3814 Propagate gas and setpoint from previous point
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 08:09:05 -08:00
Anton Lundin
4696354f4b Adapt depth-scale to current way points
If the scale is too big or too small, adapt the scale automatically.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 08:02:34 -08:00
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