aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
AgeCommit message (Collapse)Author
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-28Fix edition of manually added dives.Gravatar Tomaz Canabrava
This patch correctly sets the state of the planner to "NOTHING" after trying to edit a manually added dive. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Fix crash on adding / removing a dives from add menuGravatar Tomaz Canabrava
This patch removes some inconsistencies that were happening on the add dive / cancel actions. a bit of legacy code from the old system was still in, which made things quite... EXPLOSIVE. This fixes restoring the selection only if we have a selection and not deleting the temporary dive twice. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> 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-28Planner: really fix crash after aborting plannerGravatar Dirk Hohndel
Duh. We had to reload the list (and make sure the internal data structures are recreated as well) before restoring the selection. I also switched to simply accessing the widget directly, instead of via the dive_list() call. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Planner: prevent crash when canceling plan with existing dive listGravatar Dirk Hohndel
There is still something seriously wrong here. For now let's just not restore the selection and at least this prevents us from crashing. But I still don't understand why it crashes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Dive list: use helper function when restoring selectionGravatar Dirk Hohndel
Looping over the individual dives will be very slow if there are many of them, as the profile will try to render each of them in succession. 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-28Minor cleanupGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Try to clear out the profile when dive list is emptyGravatar Dirk Hohndel
This only partially works. If I start from an empty dive list, plan a dive, then abort, there are still leftovers in the profile widget. Hitting Ctrl-W clears that out. But it just runs the same cleanUpEmpty() again... 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-28Dive planner: remember the selection before new dives get handledGravatar Dirk Hohndel
On an empty dive list we would remember the new dive (which gets auto-selected since it's the only dive) and then crash when we try to restore that selection after cancel (in which case that new dive is gone). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Dive add: remove duplicate codeGravatar Dirk Hohndel
This is already done when we create the fake dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27Dive add: fix crash when cancelingGravatar Dirk Hohndel
We need to reset the editMode right away, otherwise all the changes to the input field (when resetting the data after the user cancels) will cause Subsurface to crash as current_dive will temporarily be NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27Much, much smarter way of finding the TagsGravatar Tomaz Canabrava
The old way manually implemented a parser, where it could simply call a regexp (or, in my case, a QChar) that will split the QString into many, to find the beginning and end of the strings on the tags. This patch also fixes a Qt5 off-by-one bug on the tag Visualization. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27Fix manually adding diveGravatar Dirk Hohndel
I'm sure canceling the plan when saving an added dive made sense at some point for some reason. Right now it makes things crash, so let's not do it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27No need to separately enable and switch focus to the dive listGravatar Dirk Hohndel
RefreshDisplay() does this for us. 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-27SetFocus only works if the widget is enabledGravatar Dirk Hohndel
One could argue that this makes sense... 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-27Planner: disable the dive list when working on a planGravatar Dirk Hohndel
And reenable it when refreshing the screen. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27Planner: clean up the logic for starting up the plannerGravatar Dirk Hohndel
The existing code had no chance of every working - on so many levels. First unselect all dives, then extract data from a selected dive? Set up the cylinder data (which didn't work), and then clear the data again? What the heck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Paint the dive red if the user is breaking ceiling on the planner.Gravatar Tomaz Canabrava
This patch paints the dive red if the user is breaking ceiling on the planner - it's quite fast, it analizes the depth over the max(tissue_1 .. tissue_16) and changes the color of the profile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Better movements from the lines when added / removed.Gravatar Tomaz Canabrava
This makes the movements from the lines when added / removed SO much better. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Planner: don't try to update the MainTab dive info while in plan modeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Speed up the grid: don't repaint when uneeded.Gravatar Tomaz Canabrava
Added a flag to only recalculate the axis when needed. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Do not set maxTime when the handler is moving.Gravatar Tomaz Canabrava
Fixes massive cpu hog. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Activate the PlannerGravatar Tomaz Canabrava
On the cleanup dirk forgot to set the plan tipe to PLAN instead of ADD Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> 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-26Make the planner show something.Gravatar Tomaz Canabrava
This is working in the wrong way, mostly because I'm setting the plannermodel to ADD state ( and the planner graphic to the correct PLAN state ), but I don't know why - when on PLAN state on the model, things just don't work. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Created a function to create a fake dive for Add and Plan states.Gravatar Tomaz Canabrava
This function should likely to move to C in the future, I'm only adding this here because I'm changing this file so much ( already 4 rewrites of the function ) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Remove uneeded call.Gravatar Tomaz Canabrava
The disableDcShortcuts is called inside of the ProfileGraphics ( I actually think that this method should be moved to there ) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Small code cleanup.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Planner: Move method down below to easy comparisson with another.Gravatar Tomaz Canabrava
Planner and add states are driving me nuts. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Planner: states Add and Plan have a similar behaviorGravatar Tomaz Canabrava
So, the code is equal. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> 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-26Rework slot to quiet down Qt5 warningGravatar Anton Lundin
Qt5 got confused about this slot. This does the same as previously but gets Qt5 happy. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25Use gas_mod and fix fpeGravatar Anton Lundin
When removing o2 from a gas, eg setting it to "", air, this code would raise a nice fpe. Fix that by using gas_mod instead. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25Dive list: make saving / restoring column widths actually workGravatar Dirk Hohndel
It's a testament to how much I mess around with things that I hadn't noticed that saving the column width doesn't actually work. Or actually, saving them worked, loading them back failed as it was done too early and the setColumnWidth() calls had no effect - and so the next time we quit subsurface, the default width of 100 was written over all the saved values. This seems like an incredible hack but it has the advantage of actually working. I look forward to someone with better insides into the inner workings of Qt to properly fix this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25Dive list: don't reset column width when reloadingGravatar Dirk Hohndel
We set the column width in the dive list widget when we create that widget, based on what is in the settings. And we save the current column width back to the settings when we destroy that widget (so if Subsurface is shut down correctly and Qt actually gets to run the destructor but not when someone kills the program). That means that if we recreate the dive list at any point while Subsurface is running (and we do that a lot when you manipulate your dive list in any way shape or form), any changes to the column widths are lost. DiveListView::reload() explicitly calls setupUi() which reads the column widths back from the settings - but changes made to the columns aren't saved to the settings until we destroy the widget... I see no reason why reload() should call setupUi(), so I'm removing that call. Let's hope this doesn't break anything else. Fixes #518 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>