Commit graph

64 commits

Author SHA1 Message Date
Berthold Stoeger
b3253304a5 Desktop: don't connect to remove() slot of model from TableModel
When connecting a model to the TableModel class, it would connect
clicking on an item to the remove() slot of the model.

This breaks the program flow implied by the undo code:
Ui --> Undo-Command --> Model --> UI

Moreover, the naming of the remove() slot is illogical, because
clicks can also have different effects, as for example in the
cylinder-table.

Therefore, move the connect() call from TableModel to the
callers. In the case of TabDiveSite, move the remove() function
from the model to the TabWidget, where it makes more sense.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05 10:14:25 -08:00
Robert C. Helling
9c8fbe494d Planner: Add option to treat O2 as narcotic
When computing the best mix for a target depth, for helium, one
can either require that the partial pressure of N2 is the same
as at the target depth or the partial pressure of N2 plus O2.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-10-31 00:30:38 -07:00
Berthold Stoeger
fdfcbd0315 Cleanup: use pointer-to-member-function in addAction() calls
Since requiring Qt >= 5.9.1, we can use the pointer-to-member-function
overloads of addAction (introduced in Qt 5.6). This has the advantage
of compile-time checking of the signal/slot parameters.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-20 03:51:11 -04:00
willemferguson
a969d1dd45 Implement height-to-pressure functions in planner
The units.h file has two functions to convert atm pressure to mbar
and also to convert mbar to atm pressure. Implement these two
functions in the planner.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-05-17 09:46:05 +02:00
Robert C. Helling
178eaa9a67 Add UI element for final surface segment in planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-03-29 06:51:12 -07:00
Robert C. Helling
2c794348c1 Planner: Add checkbox to force OC bailout
This adds a checkbox for rebreather modes of the planner
that force the ascent to be in OC mode. Before, one had
to add a one minute last segment with the mode change but
this is not practical when manually searching for the
maximal bottom time given gas reserves.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-13 15:02:07 -08:00
jan Iversen
a037578015 core/settings: change bestmixend to int, to allow qml to work
depth_t is a good struct in C, but bad in QML.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:25:00 -07:00
Dirk Hohndel
2d87a657d2 Revert "desktop-widgets: remove QSettings from desktop-widgets"
This reverts commit 321a920a98.

It appears that the load_xxx functions aren't called, so while the correct
values are stored to the settings, they aren't retrieved. Let's revert while
this gets fixed.

Fixes #1609

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-29 03:09:10 -07:00
jan Iversen
321a920a98 desktop-widgets: remove QSettings from desktop-widgets
The variables referenced are moved into qPref in earlier commits
so in general all QSettings calls are replaced by qPref*:: calls

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
jan Iversen
0f68e0cc2e desktop-widget: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
21243ec4f7 core: activate qPrefDivePlanner
remove DivePlanner from SettingsObjectWrapper and reference qPrefDivePlanner

update files using SettingsObjectWrapper/DivePlanner to use qPrefDivePlanner

this activated qPrefDivePlanner and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-08 14:29:50 +02:00
Stefan Fuchs
daab13eba9 Code cleanup in diveplanner.cpp
Move a variable declaration and added some initialization.
Added missing spaces.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-13 11:26:28 -07:00
Berthold Stoeger
57c01f7a66 Translations: unify gettextFromC::tr() and QObject::tr()
There were two catch-all classes for translations outside of class
context. gettextFromC was used exclusively from C, but C++ used
both, gettextFromC and QObject. Some of the string were even present
in both. Therefore, unify to gettextFromC throughout the code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 05:33:31 +08:00
Stefan Fuchs
c953aadcf8 Change from gettextFromC::instance()->tr() to gettextFromC::tr();
Code cleanup.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 07:42:39 +02:00
Stefan Fuchs
88e6ba2f61 Use correct "tr" call for translating dive mode names
Correctly use gettextFromC::instance()->tr(); instead of a simple
tr(); to translate the dive mode names.
This goes on top of 0bc9edf855
and finally makes the whole thing work.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 07:42:39 +02:00
Stefan Fuchs
0bc9edf855 Fix an error around translation of dive modes in the UI
This fixes an mistake introduced in
3d1072f886

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17 06:36:20 +09:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
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-06-04 08:50:10 -07:00
Robert C. Helling
7c6e5ed5db Distinguish between user and internal divemode names
The former should be translated but not those that
go to xml/git.

... and fix capitalization of pSCR.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
Robert C. Helling
b8c94cad69 Planner: Add combo box for dive mode selection
I am not really sure what I am doing here but I copied
code from the gas selection.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Oliver Schwaneberg
0ca52f868e Choose water presets from a qcombobox in planner, custom value possible
Add a combo box for water types with defaults for fresh water, sea water
and the EN 13319. All values taken from units.h, where EN 13319 was added
beforehand.
Custom values can be entered through a spinbox.
Also changed "Salinity" in TapDiveInformation.ui to "Water type".

Translation required!

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-03-02 08:38:22 -08:00
Robert C. Helling
2478158c0f Reenable pressure interpolation in context menu
This fixes a bug reported by Willem that removing waypoints
using the right click context menu makes the cylinder
pressure lines partly disappear.

The reason was that clicking a dive handler disables the
pressure interpolation (and other things, controlled by
shouldCalculateMaxdepth). This is turned on again upon
the mouse release event. This event is not triggered when
selecting in item from the context menu (like remove
waypoint or gas selection) so we need to send it manually.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-30 11:36:47 +01:00
Stefan Fuchs
d703ba99c1 Simplify update of gflow and gfhigh values in the code
The more complex handling is no longer needed because:
- Keyboard tracking for gfhigh/low UI fields was switched off here:
  030c094854
- GFhigh was limited to 40 here:
  53fffe0ce3

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Rick Walsh
1985bcb29e Disable plan variation in recreational mode
Calculating variations when in recreational mode doesn't make sense, and can
prevent variations from being calculated when switching back to Buhlmann or
VPM-B modes.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-12-01 15:47:51 -08:00
Stefan Fuchs
60677e513b Planner UI improvements: Enable/disable options
Don't accidentally enable o2breaks option when entering planner in
RECREATIONAL mode.
Disable also label for min_switch_duration according to dive mode.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 20:17:35 +01:00
Stefan Fuchs
ac25b238dd Disable o2 break option if last stop is not at 6m/20ft
Disable the possibility to plan o2 breaks of option
"last stop at 6m/20ft" is not set.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
57032e9fcb In planner for different deco modes enable/disable options correctly
Disable option "safety stop" for all deco modes other than
"recreational".

Disable also labels "reserve gas", "GF ..." and "VPM conservatism"
correctly.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
bfe52f6689 Correctly name member function gasChange of DivePlannerPointsModel
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Robert C. Helling
030c094854 Remove disfunctional asc. rate signals and add disable keyboardTracking
The connection wasn't working anyway since the signal comes without
value while the slot wanted a value and thus only created a runtime
warning.

Turning of keyboard tracking means that when typing the number 123 the
value change signal is not fired three times (with values 1, 12, and 123)
but is only fired upon pressing enter or the spin box losing focus.

We should add a similar setting to the depth, duration and runtime
columns of the DivePlannerPointsModel but i have no clue how to do that.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-07 08:42:06 -07:00
Stefan Fuchs
cf409b59ba Planner settings ascend and descende rate: Wire up UI elements correctly
Wire up the UI elements (QSpinBoxes) for ascend rates (4x) and descend rate
(1x) correctly so that the profile and calculation is updated immediately
after the value is changed (e.g. increased/decresed by 1) by clicking
the QSpinBox arrows.
Until now one had to click into the profile or change another planner
preference first before the change became effective.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-04 08:41:10 +02:00
Robert C. Helling
a6f186279f Add a checkbox to turn off plan variations
... as those come with a performance penalty

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Dirk Hohndel
5a4485b63b Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:20 -07:00
Dirk Hohndel
9021a44ccc Add SPDX header to desktop widgets
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Jan Mulder
89b914e47d Preserve dive mode when planning a dive
Data such as cilinders and used gasses are populated fromn the currently
selected dive when starting the planner. It is more logical to use
the dive mode (OC, CCR, pSCR) of the currently selected dive
as well. This commits changes this.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-20 10:57:11 -07:00
Jeremie Guichard
597539ce39 Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint

Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.

Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-24 09:39:25 -07:00
Dirk Hohndel
08284275e7 Merge branch 'master' of https://github.com/dje29/subsurface 2017-03-11 08:41:41 -08:00
Stefan Fuchs
fa7d3b6ecb Add tooltip for add cylinder button in planner
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 08:07:35 -08:00
Robert C. Helling
295b1b78d8 Make depth conversion work for negative depths
This is needed in the altitude pressure conversion as there
negative altitudes are possible (for diving in the netherlands
or the Dead Sea).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-11 08:03:25 -08:00
Stefan Fuchs
8a4d3876d6 Disable minimum gas calculation for recreational mode
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 08:01:35 -08:00
Stefan Fuchs
7f8c3592ce Minimum gas calculation - Calculations and UI parameters
Add minimum gas calculation to planner output.
Add the two UI parameters prefs.sacfactor and prefs.problemsolvingtime.
Connect UI signals and slots for recalculation of diveplan.

Disable minimum gas calculation if there was already a warning before.
If minimum gas result is larger then cylinder start pressure give warning message instead of result.

Add line break before pO2 warnings but only if warnings exist.

Signed-off-by: Joachim Ritter <jritter@bitsenke.de>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11 08:01:35 -08:00
Jeremie Guichard
406e4287eb Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-08 14:04:17 +07:00
Stefan Fuchs
e34e2693ea Enable bottom pO2 option also for recreational dives in planner
Bottom pO2 gas option in planner should be always enabled because
also recreational dives can use nitrox and produce "high pO2" warnings.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-07 16:21:28 -08:00
Jan Mulder
5c89115efe Fixes cylinder table headers not translated
The cylinder table was constructed very ealy from the contructor of the
planner, so early that the tr() functions are not registered. This fix
instantiates the cylinderModel from the maintab (as it is done
with, for example, the weightsModel) and lets the planner user
this instantiated (and proper translating) cylinderModel.

Fixes: #206

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-02-21 07:28:15 -08:00
Anton Lundin
78059d4010 Update altitude limits on unit change
The limits set in diveplanner.ui is intended for the unit set there,
meters. If we move between units we need to update the limits to.

This fixes #201

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-02-14 07:29:52 -08:00
Robert C. Helling
935734100f Rename prefs.deco_mode to prefs.planner_deco_mode
This is to avoid confusion with planner.display_deco_mode.
When accessing the "current deco mode" use the decoMode()
helper function.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
fb2ba72e42 Set surface pressure and salinity correctly when replanning
We need to initialize the UI elements accordingly.

Fixes #1094

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-26 12:47:54 -08:00
Rick Walsh
46f3b0f238 Planner: connect emitDataChanged slot to ascent/descent rate editingFinished
Call the emitDataChanged slot when ascent and descent rate spinboxes lose
focus.  Without this connection, rates are not updated immediately after
editing the value with keyboard numbers and hitting tab or enter.

It is necessary to keep the valueChanged(int) connections, because
editingFinished() is not triggered by changing the value with the arrows.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-10-27 20:36:02 -07:00
Rick Walsh
7e09a6c7bc Separate VPM-B conservatism preference for planner and profile
Separate the VPM-B conservatism preference into diveplan.vpmb_conservatism for
planning dives and prefs.vpmb_conservatism for profile ceiling display of
saved dives.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:30:11 -07:00
Rick Walsh
7b891904e7 Rename conservatism_level to vpmb_conservatism
Make the variable purpose less ambiguous

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:29:56 -07:00
Tomaz Canabrava
8f178301d8 Settings update: Use the Settings to store the plannersettings
Instead of settings things manually in the code. (btw,
if we use lambdas the code can be quite smaller)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00
Tomaz Canabrava
ad7524fda1 Organize the connect calls per object.
Just to make it easy on the eyes.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-27 11:40:45 -07:00