aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/cylindermodel.cpp
AgeCommit message (Collapse)Author
2018-06-24Localization: remove gettextFromC::instance()Gravatar Berthold Stoeger
There were a handfull instances of the kind 1) gettextFromC::instance()->tr(...) 2) gettextFromC::instance()->trGettext(...) 1) is pointless, as tr is a static function. All instances of 2) were likewise pointless, because trGettext() returns a C-string, which was then immediately converted to a QString. Thus, replace both constructs by gettextFromC::tr(...). After this change there was only one user of gettextFromC::instance() left, viz. the C-interface funtion trGettext(). Therefore, remove gettextFromC::instance() and do all the caching / translating directly in the global trGettext(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21qt-models: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Core: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05Use correct numeric format based on selected locale (Qt domain part)Gravatar Stefan Fuchs
This changes the numeric format of many values printed to the UI to reflect the correct numeric format of the selected locale: - dot or comma as decimal separator - comma or dot as thousands separator In the Qt domain the `L` flag is used case specific mostly in qthelper.cpp. Then the helper functions get_xxx_string() are used more consistently. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-27Updated strategy for removing cylindersGravatar Stefan Fuchs
Change the strategy when to allow cylinder removal from a dive: - Not remove when cylinder has gas switch events, in any other cases allow removal - Remove this whole "cylinder with same gas" thing being a criteria for cylinder removal When removing a cylinder which has corresponding pressure info in samples, also remove this pressure info from the samples. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-26Initialise cylinder start pressure with working pressureGravatar Robert C. Helling
In the planner, this is the natural assumption. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-24Remove superfluous QScopedPointer<>s in singletonsGravatar Berthold Stoeger
There was a curious pattern of singletons being implemented based on QScopedPointer<>s. This is an unnecessary level of indirection: The lifetime of the smart pointer is the same as that of the pointed-to object. Therefore, replace these pointers by the respective objects. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01Prevent redundant replanningGravatar Robert C. Helling
Planning dives is heavy on CPU, so better be sure we only do it when needed. In particular, when moving around dive points, we only want a new plan once per move and not three times (triggered at various points in the chain of events). This should significantly improve planner snappiness. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-27Add debug function dump_cylindersGravatar Stefan Fuchs
This function can be used to dump print all cylinder data. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-30Tidy up code for cylinder remove decision in cylindermodel.cppGravatar Stefan Fuchs
Replace currentMode() != ...:NOTHING with equivalent in_planner() Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-21When removing a cylinder completely fill the mapping tableGravatar Stefan Fuchs
When deleting a cylinder the mapping was not filled with all necessary values. Values for cylinders before deleted cylinder were missing. Plus do the endRemoveRows at the right time. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-20Silence random warningsGravatar Dirk Hohndel
None of these seem to point to actual issues, so let's quiet them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20Update dive planner points cylinder names also when cyl is addedGravatar Stefan Fuchs
Amendment to c29456f0bb11f07befc3af66ee7973258b491d20 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-20Do cylinder renumber for dive data points only when in planner modeGravatar Stefan Fuchs
Amendment to 73d2ab8099ce08ab20f119a126334463ffd41b1e Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Planner: Autom. move first datapoint gas to first gaslist positionGravatar Stefan Fuchs
In the planner it is best practise to start the dive with the first gas in the gaslist. Otherwise one would get a gaschange event at the very beginning of a dive. This change implements the following feature: Automatically move a gas to position 0 in the gaslist if the user selects this gas for the first dive data point. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Update diveplannerpoints cylinderidx when deleting a cylinderGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Used gas in dive planner points: Support for multiple cyl with same gasGravatar Stefan Fuchs
In the planner if one adds two or more cylinders with the same gasmix (e.g. back gas and bottom stage 18/45) the drop down and data in the used gas column of the planner points table will be filled with a more verbose string mentioning also the cyl number and the cyl type description. Makes it easier in such a case to select the right cylinder. Introduces also a helper function which tells you if there is another cylinder with the same gasmix as the provided cylinder. This also has an option if it should consider unused cylinders or not. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Removing cylinders in planner: Be more restrictiveGravatar Stefan Fuchs
Be even more restrictive regarding which cylinders can be removed from the cylinder table in the planner. Only if a cyliner is not used in the planned part of the dive it can be removed. It doesn't matter if there is another cylinder with same gasmix. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-07-30Tweak the "display_unused_tanks" preferences logicGravatar Linus Torvalds
This is really unrelated to my recent "multiple gas pressures" work, but the test case from Gaetan Bisson showed that the logic for which cylinders to show in the equipment tab was less than optimal. We basically used to show only cylinders that were actively used, unless you had the "display_unused_tanks" preference option set. That comes from some dive computers reporting a *lot* of cylinders that the diver really doesn't even have with him on the dive. And showing those extra dummy cylinders gets pretty annoying after a time, which is why we default to not showing unused tanks. However, in Gaetan's case, he had a total of four cylinders on the dive: the O2 and diluent bottle for the rebreather dive, and then bailout bottles (both air and deco). And while the bailout bottles weren't actually used, Gaetan had actually filled in all the pressure details etc for them, and so you'd really expect them to show up. These were *not* just some extraneous default cylinder filled in by an over-eager dive computer. But because the bailout wasn't used, the manual pressures at the end were the same as at the beginning, and the "unused cylinder" logic triggered anyway. So tweak the logic a bit, and say that you show cylinder equipment not only if it has been used on the dive, but also if it has any pressure information for it. So the o nly cylinders we don't show are the ones that really have no interesting information at all, except for possibly the cylinder tank type itself (which is exactly what the over-eager dive computer case might fill in, usually in the form of a default cylinder type). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to Qt modelsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-24Don't erroneously mark the cylinder pressure red - second tryGravatar Stefan Fuchs
Second attempt to do the thing with the red background color for cylinder start and end pressure correctly. This now should cover all scenarios. This rewrites and partitially reverts commit b8e044d Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-13Correctly trigger update of cylinder table trash icons in plannerGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Correct trash or trashforbidden icon and tooltip in cylinder tableGravatar Stefan Fuchs
Display the correct trash or trashforbidden icon and tooltip in the cylinder table. This should fit together with if it is really possible to remove a cylinder. Search for "same gas" based on used cylinders only. Otherwise one could remove a used cylinder because there is an unused cylinder with same gas. ToDo: In planner update trash icon on change of planner points. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Add units (m or ft) for MOD and MND in cylinder table in plannerGravatar Stefan Fuchs
We do display the unit for "Gas change at" today so we should also display it for MOD and MND. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Use abbreviations with dots.Gravatar Martin Měřinský
2017-03-11Don't erroneously mark the cylinder pressure red and set font italicGravatar Stefan Fuchs
In the cylinder table today the cylinder start and end pressure fields are marked red and the end pressure font is set to italic if cyl->end is 0. But sometimes with planned dives there is no cyl->end but only cyl->sample_end. This is taken into account now. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Fix cyclinder table issue "workingpressure" in plannerGravatar Stefan Fuchs
Fixes the issue that the cylinder table in the planner is messed up after changing the table header. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-02-26Call the cylinder working pressure "starting pressure" in plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03Revert "In statistics, ignore gas use of planned dives"Gravatar Dirk Hohndel
This reverts commit 1d8662006cbb5edae941315e30ede381c23a817b. Mistakenly pushed to master Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-02In statistics, ignore gas use of planned divesGravatar Robert C. Helling
When merged with real dives, those would double count otherwise. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-23Allow user to disable a cylinder in plannerGravatar Robert C. Helling
In the cylinder table, the last column ("use") always showed OC-GAS. Editing was enabled, but the user had to guess to enter a small integer meaning dilluent or CCR oxygen cylingder. I guess, nobody has ever done that. This patch makes this column clickable. A click toggles if the cylinder is used for planning or not. This wait it is much easier to investigate the consequences of gas loss on a plan. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-16Revert "Show both the nominal and "real" size for an imperial cylinder"Gravatar Dirk Hohndel
This reverts commit adaeb506b7a1485cab741f12450abeb76e109276. commit a8e8d56ec016 ("Tweak cylinder equipment tooltips") does a much better job allowing the user to know the true volume of the cylinder (given the gas entered) and clutters the UI a lot less.
2017-01-16Tweak cylinder equipment tooltipsGravatar Linus Torvalds
While playing around with the current subsurface, I realized that while we give the gas volume and Z factor for the beginning/end pressures in the newly added tooltips, there is no way to actually see that same information for the working pressure. So if you have filled in cylinder type information, but don't have any actual gas usage information, there will be no cylinder tooltips at all. But you might still want to know what the actual volume for a particular cylinder is, and what the Z value for that working pressure is. So this tweaks the tool-tips a bit. When mousing over the pressure fields (ie "working pressure", "start" and "end"), it now always gives the cylinder gas volume and Z factor for that pressure, so for example on an AL72 that has a working pressure of 3000 psi and that contains air the tooltip will say: 69 cuft, Z=1.040 when you mouse over the working pressure field (that's obviously with imperial units, in metric you'll see liters of gas). When mousing over the type/size field, it gives the used gas amounts, ie something like this: 37 cuft (82 cuft -> 45 cuft) but if the cylinder doesn't have starting/ending pressures (and thus no used gas information), this patch will make subsurface show the working pressure data instead, so that you at least get something. This all seems more useful than what my first version gave. NOTE! This makes commit adaeb506b7a1 ("Show both the nominal and "real" size for an imperial cylinder") kind of pointless. You now see the real size in the tooltip when you mouse over the size, and now it actually works both for imperial and metric people, so the tooltip is in many ways the better model. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-12Add cylinder equipment tooltips with gas volumeGravatar Linus Torvalds
This adds tooltips for the equipment tab for each cylinder, showing the amount of gas used. When you mouse over the size and working pressure fields, the tooltip will show the amount of gas used (along with start and end gas volumes). And when you mouse over the start and end pressures, it will show the start and end gas volumes, and the Z factor used. I started doing this because of the gas volume questions in the last day or two (and a few from a few weeks ago). When even Robert Helling starts wondering about the effects of compressibility on the SAC calculation, our numbers are clearly too opaque. With these tooltips, at least you can see what went into the used gas calculations, instead of having to add debugging options to print out Z factors. [ This patch also adds a "rint()" to get the rounding right in the gas_volume() function. Although rounding to the nearst milliliter really doesn't matter, it's the right thing to do after doing FP calculations ;^] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-08-10CylindersModel: add tooltips for Deco switch at, Bot MOD and MNDGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Remove unnecessary DivePlannerPointsModel functions and variablesGravatar Rick Walsh
Commit b1ed04a means that DivePlannerPointsModel::rememberTanks() and related functions and variables are no longer required Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Relabel cylindermodel "Deco MOD" column to "Deco switch at"Gravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Planner: update cylinder mixes and MND and MOD when prefs are changedGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Fixup: don't capitalise best_HeGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Planner: automate calculation of best mix for max depthGravatar Rick Walsh
Add option to calculate the best mix portion of O2 and He for the dive's max depth if the user enters * in the MOD and MND cylinder fields. Gas portions are automatically recalculated if the max depth of the dive changes. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Be more clear about deco MOD / switch depth and bottom MODGravatar Rick Walsh
The switch depth of a decompression gas is its MOD. By renaming the heading to "Deco MOD", it is more clearly distinguished from the bottom MOD, and it is more obvious how they relate to the Bottom pO2 and Deco pO2 preferences. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Add MOD and MND fields to cylindermodelGravatar Rick Walsh
Adds fields to the planner cylinder model for maximum operating depth (MOD) for a bottom mix gas, and maximum narcotic depth (MND). Fields are read/write, so changing MOD changes %O2 and vice-versa. Changing MND changes %He and vice-versa. When setting MOD directly, the %O2 is truncated (rounded down) to an integer, which re-calculates the MOD, which is sometimes a few metres greater than the input depth. This is desireable behaviour, as the rounding is conservative. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Update gas deco MOD when deco pO2 is changedGravatar Rick Walsh
This fix is reasonably straightforward when the divedatapoint structure stores the cylinder rather than gasmix. Fixes #970 Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Have divedatapoint store cylinder id instead of gasmixGravatar Rick Walsh
Determining the correct cylinder index from a known gas mix can be complicated, but it is trivial to look up the gasmix from the cylinder_t structure. It makes sense to remember which cylinder is being used. This simplifies handling changing a cylinder's gas mix, either directly by the user, or indirectly in the planner. It also permits tracking of multiple cylinders of the same mix, e.g. independent twins / sidemount. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28Add some gas mix validation to the plannerGravatar Rick Walsh
A few basic rules for gas validation: We can't have <0%, or >100% of either O2 or He O2 + He must not be >100% Switch depth can't be <0% This places limits on user-input values Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21Add best mix function to planner cylinder modelGravatar Rick Walsh
This allows calculation and selection of best mix in the planner cylinder entry, by entering the gas depth, followed by "b" for best (trimix) mix, or "bn" for best nitrox mix. The UI is not intuitive, but it is quick and easy. At the very least, it should be documented. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29CylindersModel: clamp the "cylinderuse" valuesGravatar Lubomir I. Ivanov
If the value for "use" is negative or larger than the number of elements in "enum cylinderuse", later CylindersModel::data() can request a string in the lines of cylinderuse_text[cyl->cylinder_use], which can SIGSEGV. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>