aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
AgeCommit message (Collapse)Author
2014-06-01Use proper typesGravatar Dirk Hohndel
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-01Remove the .used member of the cylinder structureGravatar Dirk Hohndel
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-05-31Revert "Show the calculated deco stops in the planner table"Gravatar Dirk Hohndel
This reverts commit 7d42b53bba235894668ed1f2da3f5d17cd97b9c5. 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-31Planner: don't include the disclaimer in the dive plan detail widgetGravatar Dirk Hohndel
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-31Planner: show the plan notes in the new widgetGravatar Dirk Hohndel
That was easy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31Allow editing segment duration. This shifts all following waypoints.Gravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30Planner: don't recreate the dive while cleaning up the widgetsGravatar Dirk Hohndel
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-30Planner: remove check for empty diveplanGravatar Dirk Hohndel
This was introduced in commit fc1336107930 ("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-30Planner: don't do unnecessary work on empty dive plansGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30Planner: after freeing the plan, throw away the pointerGravatar Dirk Hohndel
Otherwise we'll happily go back and access the freed data structures later. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29Do not offer an editor when double-clicking REMOVE on the planner.Gravatar Tomaz Canabrava
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-29Do not show 'trash' icon for deco stops.Gravatar Tomaz Canabrava
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-29Do not remove a Deco Stop by clicking on the trashGravatar Tomaz Canabrava
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-29Show the calculated deco stops in the planner tableGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29Planner: track gas consumption in cylinders and samplesGravatar Dirk Hohndel
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-28Planner: record the new dive at the correct timeGravatar Dirk Hohndel
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-28Planner: always recreate staging diveGravatar Dirk Hohndel
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-28Planner: make sure stagingDive is reset to NULLGravatar Dirk Hohndel
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-28Add dive: only copy cylinders when necessaryGravatar Dirk Hohndel
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-28Move code from the Planner that doesn't belongs there.Gravatar Tomaz Canabrava
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-28Planner: set up a cylinder, even if no current dive is selectedGravatar Dirk Hohndel
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-28Fixes showing the Empty Profile when Add / Plan dive is cancelled.Gravatar Tomaz Canabrava
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-28Dive planner: remove the fake dive earlier on cancelGravatar Dirk Hohndel
This way it's already gone from the dive list before it gets reprocessed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27Planner: correctly refresh the displayGravatar Dirk Hohndel
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-27Planner: return Profile widget to profile stateGravatar Dirk Hohndel
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-27Planner: use the gas in the first cylinder for initial planGravatar Dirk Hohndel
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-27Planner: better handle the temporary dive used for planningGravatar Dirk Hohndel
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-26Merge branch 'Planner'Gravatar Dirk Hohndel
2014-05-26Planner: copy samples and events for plan and addGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Planner: Don't include the ascent in the default diveGravatar Dirk Hohndel
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-26Planner: Re-enable using the new profile.Gravatar Tomaz Canabrava
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-26Merge branch 'atdotde'Gravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Conflicts: qt-ui/diveplanner.cpp
2014-05-26Reenabled copying the diveplan to dive notes.Gravatar Robert C. Helling
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-26Merge branch 'atdotde'Gravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Conflicts: qt-ui/diveplanner.cpp qt-ui/models.cpp
2014-05-26Use get_o2() and get_he() instead of accessing permilles directlyGravatar Robert C. Helling
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-25Move mod calculations to a separate helperGravatar Anton Lundin
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-24Remove leftovers from the planner.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24Reenamble 'Delete Dive Point' on the planer / addGravatar Tomaz Canabrava
Just removed an #if 0 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24Port the KeyPress actions to the new profile.Gravatar Tomaz Canabrava
[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-24Remove a ton of code.Gravatar Tomaz Canabrava
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-24Remove the depth / time increase and decrease functions.Gravatar Tomaz Canabrava
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-24Remove unused code.Gravatar Tomaz Canabrava
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-24Remove code already ported to the new profile.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24Make the planner actually work.Gravatar Tomaz Canabrava
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-24Change how the handler handlers itself.Gravatar Tomaz Canabrava
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-22Gratuitous whitespace changesGravatar Dirk Hohndel
I keep trying to get to consistenct. Completely hopeless. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22Good code cleanup on the old DivePlanner code.Gravatar Tomaz Canabrava
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-22Profile now correctly displays the planned dive.Gravatar Tomaz Canabrava
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-22Code Cleanup: connections can be made between signals.Gravatar Tomaz Canabrava
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-20Remove silly macro to pretend that we were doing things the right way.Gravatar Tomaz Canabrava
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>