aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
AgeCommit message (Collapse)Author
2013-12-08Keep track of user requested minimum depthGravatar Anton Lundin
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-08If we have defined a gas, default to that one.Gravatar Anton Lundin
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-08Calculate gas consumption for planned divesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08Remove the air point at 0,0Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07Show CC-sp in bar, and not mbarGravatar Anton Lundin
Fixes #257 Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07Fix gas for start dpGravatar Anton Lundin
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-07Propagate gas and setpoint from previous pointGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07Adapt depth-scale to current way pointsGravatar Anton Lundin
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-03Correct parameter namesGravatar Dirk Hohndel
It's very confusing when a parameter is called "minutes" but holds seconds... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03Fix bug in creating dive plan from diveGravatar Dirk Hohndel
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-11-30Fix all leak-at-exit from singletons in SubsurfaceGravatar Thiago Macieira
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-30Delete the graphics items for the ticks and labels in the rulerGravatar Thiago Macieira
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-27Remove some constants and use helpers insteadGravatar Anton Lundin
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-26Changing the preferences should update the Add Dive interfaceGravatar Tomaz Canabrava
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-21Work around QMessageBox not showing its title on MacGravatar Dirk Hohndel
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-19Use the correct dive to create the gas listGravatar Dirk Hohndel
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-19Better handle the mouse movements on the Add Dive profileGravatar Tomaz Canabrava
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-19Enable gas selection through a context menuGravatar Tomaz Canabrava
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-19Fixes positioning the first Gas Label on the add dive profile.Gravatar Tomaz Canabrava
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-19Removed obsolete Code ( gaslist on text click )Gravatar Tomaz Canabrava
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-18Quick hack to make the dive add icons smallerGravatar Dirk Hohndel
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-18Change the order of the increase / decrease buttons on the planner.Gravatar Tomaz Canabrava
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-18Anchor bottom of the dive ruler editor ro items on the DivePlannerGravatar Tomaz Canabrava
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-18Just some code cleanup.Gravatar Tomaz Canabrava
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-18Fix various issues with the dive add / edit manual dive codeGravatar Dirk Hohndel
- 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-18Don't add spurious 5m/15ft node at 10 minutes when canceling editGravatar Dirk Hohndel
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-17Removed the ugly icons on the visual profile editorGravatar Tomaz Canabrava
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-17Remove ununsed variablesGravatar Dirk Hohndel
The warnings are distracting - and the variables are truly obsolete by now. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Don't create stop at time zero when re-editing manually added diveGravatar Dirk Hohndel
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-15Once again remove debug output.Gravatar Dirk Hohndel
Oops again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Enable a context menu to remove dive handlers.Gravatar Tomaz Canabrava
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-15Fix dive planner widgetGravatar Dirk Hohndel
In commit 0f50b73f9e88 ("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-15Fix planner / add dive handling of DiveHandler PointsGravatar Tomaz Canabrava
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-15Adds the first DiveNode at 5meters / 10minutes when clicking on plusGravatar Tomaz Canabrava
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-15Fix adding DivePoints on the planner via the table.Gravatar Tomaz Canabrava
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-15Correctly handle changes on the CylinderModel to update the AirModel.Gravatar Tomaz Canabrava
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-15Close the Air list when clicking outside of it.Gravatar Tomaz Canabrava
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-15Remove some unneeded member functionsGravatar Anton Lundin
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-15Planner: Default to GF from prefs.Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Planner: use a QSpinBox for GFLow/GFHighGravatar Anton Lundin
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-14Hook up the tank change and tank update for the plannerGravatar Dirk Hohndel
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-14Fix some random compiler warningsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Handle tank data correctly in profile editing mode for manually added diveGravatar Dirk Hohndel
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-13Correctly convert an existing dive into a planGravatar Dirk Hohndel
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-13Fix addGas to look at the correct cylinderGravatar Dirk Hohndel
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-13Don't change gas used in segments if there is still a cylinder with that gasGravatar Dirk Hohndel
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-13Connect changes in the tanks with the dive that is being addedGravatar Dirk Hohndel
- 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-13Instead of a "Cylinder for planning" use a default cylinderGravatar Dirk Hohndel
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-13Partially revert d72c69db7a49f and fix its errorsGravatar Tomaz Canabrava
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-12First steps to make add dive work with the correct infrastructureGravatar Dirk Hohndel
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>