aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
AgeCommit message (Collapse)Author
2014-08-06Don't show a SAC of 0.0l/min (or cuft/min)Gravatar Dirk Hohndel
When we have no data about the gas consumption it makes no sense to show a SAC of 0. Instead we should show either "unknown" or nothing. Fixes #693 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06Don't list gases that weren't used in profile printGravatar Dirk Hohndel
If the divecomputer adds additional, unused cylinders to the dive, they would be listed in the profile based printouts. Given that the field is named "Gas used" that seems wrong. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Data validationGravatar Dirk Hohndel
Instead of refusing cylinder pressure data let's just mark it as red when the values don't seem to make sense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-02Enforce end pressures to be not above starting pressures.Gravatar Robert C. Helling
We don't blow into our cylinders under water. Negative pressures should be allowed as they might arise from dive planning without taking care of gas consumption. fixes #644 Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-17Replace cylinder_is_used with is_cylinder_usedGravatar Anton Lundin
is_cylinder_used uses get_cylinder_index as underlaying function that does the right thing with with respect on how to find the closest matching cylinder, and handles both types of gaschange events correctly. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Improve handling of cylinders with identical gasmixGravatar Dirk Hohndel
In reality we have no concept for handling those, yet. But the UI doesn't prevent the user from entering multiple cylinders with the same gasmix, so we need to help the user to get rid of them as well. If the user attempts to remove a cylinder we check if there's a second cylinder with the same gas. If that's the case then we can proceed and remove the cylinder the user wants to get rid of without losing that gas for the dive. The only tricky issue is that we need to make sure that if we remove the first cylinder that one is actually replaced with one with the same gas. Fixes #622 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Correctly track the 'changed' status of the equipment widgetsGravatar Dirk Hohndel
updateDive() cannot reset the changed status - this is called while the dive is edited. Instead this status is reset when the user either accepts or rejects the changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Don't ignore equipment just because the dive list is emptyGravatar Dirk Hohndel
This was a fun little bug. Tomaz pointed me in the right direction. The UI restructure with the displayed_dive had another unintended side effect here. It is not valid not to set up the widgets just because the dive_list is empty. The displayed_dive isn't on the dive_list until it is saved - so while the user is adding or planning a dive, we still need to show the equipment widgets. Fixes #614 Fixes #601 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Use QObject::tr instead of OurClasses::tr for functionsGravatar Tomaz Canabrava
This will make more easy to move code around in the future. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15Do not create a backup for Q_FOREACH containerGravatar Tomaz Canabrava
Q_FOREACH will expand and already creates a copy of the contained container, so this is just a waste of cpu cycles and also increases a tiny bit the memory consumption. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: print depth unit in tableGravatar Dirk Hohndel
When adding the method that includes the depth unit to the DiveItem class I realized that this was yet another implementation of our depth unit conversion. We should just call the existing helper instead. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: make table more usefulGravatar Dirk Hohndel
Tweak font size and column widths. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: change the header to show depth / durationGravatar Dirk Hohndel
At least for my dives there wasn't enough space for depth and duration in the header, most likely because I made the last two columns smaller to create more space for tags and suit. With this commit the depth and doration in the header now spans two columns and easily fits. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: print tags instead of max CNSGravatar Dirk Hohndel
And re-order / re-size the fields so more useful information is actually shown. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Printing: use more appropriate font sizesGravatar Dirk Hohndel
2-up and 6-up need different fonts. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Better default font for printing.Gravatar Tomaz Canabrava
use setPointSize instead of setPixelSize to make it device independent, also reduced a bit the size of the font. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11dive list context menu capitalisationGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11misc capitalisation and spellingGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Print: make the profile table font size 7pxGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: get rid of "current" pointer in cylinders and weightsGravatar Dirk Hohndel
Instead always display the display_dive. Now the only thing left to slay is the stagingDive... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-30Align the texts on the Left inside of Right for the DiveListGravatar Tomaz Canabrava
The Qt Framework adds a visual 'tab' on the children of a node, but if we forced a right alignment on them, it will lose that. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25Make gas mod be reasonable for users of imperial units as wellGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25Make pO2 settings functional in plannerGravatar Robert C. Helling
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-23Be more consistent in partial pressure namingGravatar Henrik Brautaset Aronsen
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-08Change character for liter in SAC values as wellGravatar Dirk Hohndel
And fix the bug that in the info overlay SAC was always given in metric values. And try to reduce the number of places in which we calculate the unit conversions... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08Really display liters with script elGravatar Dirk Hohndel
In commit 125ddd955c04 ("Display liters with script el") Robert only fixed the C routine we use to show units. Strangely, we had a separately implemented C++ function as well. Instead of implementing this in two spots I now simply have the C++ function use the C function to do the actual work and then wrap this into an easier to use (from UI code) QString output. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Next step to using gasmix instead of o2/heGravatar Dirk Hohndel
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-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-29Planner: only update the plan after the cylinder data has been updatedGravatar Dirk Hohndel
This way we avoid trying to create a dive from the plan while the plan references the cylinder that has just been changed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Merge branch 'Planner'Gravatar Dirk Hohndel
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-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-22Gratuitous whitespace changesGravatar Dirk Hohndel
I keep trying to get to consistenct. Completely hopeless. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Change get_dive_by_diveid to get_dive_by_uniq_idGravatar Dirk Hohndel
The original name was a really bad choice as we have a 'diveid' as part of struct divecomputer - and that is not the diveid that is being used here. Instead we use the 'id' member of struct dive which holds the "unique ID" for this dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Rename getDiveById to get_dive_by_id to keep current c code organized.Gravatar Tomaz Canabrava
This commit renames getDiveById to get_dive_by_id, and it also removes the Q_ASSERTS and if(!dive) return that the callers of this function were calling. If it has a Q_ASSERT this means that the dive must exist, so checking for nullness was bogus too. I've changed the assert (done in a silly C-Way. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08When starting the planner, copy cylinders from currently selected dive.Gravatar Robert C. Helling
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-04-17Mark a lot of TODO's where I think it should be moved to C code.Gravatar Tomaz Canabrava
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-17Improvement for various bits of the plannerGravatar Robert Helling
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-03-23Enable parts of planner based on defineGravatar Anton Lundin
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-15Correctly check if tank is in useGravatar Dirk Hohndel
We always checked if the tank was in use by the planner / dive editor - even if we were not in dive edit mode. With this patch, when not in dive edit mode, we check our cylinder "used" flag instead. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05Another small tweak to whitespace toolGravatar Dirk Hohndel
clang-format doesn't appear to reindent multi line #define statements correctly - so this hopefully will clean those up. The included whitespace corrections to the code should stay in place when using the updated tool. This includes cleaning up some multi-line comments that were messed up the last time around as well as a few other minor changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03Fix possibly uninitialized valueGravatar Dirk Hohndel
I'm not sure about this one. It's possible that there's something happening behind the scenes that I don't understand. But let's just initialize this to 0 and be sure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
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-12Replace mainWindow() with MainWindow::instance()Gravatar Boris Barbulovski
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-12Whitespace and dead code cleanupGravatar Dirk Hohndel
The coding style for switch isn't the prettiest, but let's at least keep things consistent. Also, those ugly break statements never got reached, anyway. And there was no need to re-declare and re-generate currentString. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11Update #include statement for QStringListModelGravatar Boris Barbulovski
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26Disable the switching depth column for cylindersGravatar Dirk Hohndel
Since the planner is disabled this column isn't needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Fix some memory leaks.Gravatar Boris Barbulovski
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-16Whitespace and coding style updatesGravatar Dirk Hohndel
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-15Fix "hide unused cylinder" behaviorGravatar Dirk Hohndel
There are at least two scenarios where our old code was flat out wrong. If you manually add a cylinder (because you may want to switch to it in the profile), then at least until the next time you restart Subsurface this cylinder should be shown. Also, when you switch to a cylinder by adding a gas switch event on the profile, that change should then make that cylinder visible. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>