subsurface/core/settings
Michael Keller 2d8e343221 Planner: Improve Gas Handling in CCR Mode.
This has become a bit of a catch-all overhaul of a large portion of the
planner - I started out wanting to improve the CCR mode, but then as I
started pulling all the other threads that needed addressing started to
come with it.

Improve how the gas selection is handled when planning dives in CCR
mode, by making the type (OC / CCR) of segments dependent on the gas use
type that was set for the selected gas.
Add a preference to allow the user to chose to use OC gases as diluent,
in a similar fashion to the original implementation.
Hide gases that cannot be used in the currently selected dive mode in
all drop downs.
Include usage type in gas names if this is needed.
Hide columns and disable elements in the 'Dive planner points' table if
they can they can not be edited in the curently selected dive mode.
Visually identify gases and usage types that are not appropriate for the
currently selected dive mode.
Move the 'Dive mode' selection to the top of the planner view, to
accommodate the fact that this is a property of the dive and not a
planner setting.
Show a warning instead of the dive plan if the plan contains gases that
are not usable in the selected dive mode.
Fix the data entry for the setpoint in the 'Dive planner points' table.
Fix problems with enabling / disabling planner settings when switching
between dive modes.
Refactor some names to make them more appropriate for their current
usage.

One point that is still open is to hide gas usage graphs in the planner
profile if the gas isn't used for OC, as there is no way to meaningfully
interpolate such usage.

Signed-off-by: Michael Keller <github@ike.ch>
2024-08-26 12:36:31 +12:00
..
qPref.cpp core: remove location service preferences 2021-09-13 11:21:34 -07:00
qPref.h
qPrefCloudStorage.cpp preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefCloudStorage.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefDisplay.cpp preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefDisplay.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefDiveComputer.cpp Import: Add option to sync time on dive computer download 2023-04-17 07:56:02 -07:00
qPrefDiveComputer.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefDivePlanner.cpp
qPrefDivePlanner.h
qPrefEquipment.cpp Equipment: Include Unused Tanks in Merge if Preference is Enabled. 2023-07-25 11:19:03 +12:00
qPrefEquipment.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefGeneral.cpp
qPrefGeneral.h
qPrefGeocoding.cpp
qPrefGeocoding.h
qPrefLanguage.cpp
qPrefLanguage.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefLog.cpp preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefLog.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefMedia.cpp preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefMedia.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefPartialPressureGas.cpp
qPrefPartialPressureGas.h
qPrefPrivate.cpp preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefPrivate.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefProxy.cpp
qPrefProxy.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefTechnicalDetails.cpp Planner: Improve Gas Handling in CCR Mode. 2024-08-26 12:36:31 +12:00
qPrefTechnicalDetails.h Planner: Improve Gas Handling in CCR Mode. 2024-08-26 12:36:31 +12:00
qPrefUnit.cpp
qPrefUnit.h
qPrefUpdateManager.cpp preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
qPrefUpdateManager.h preferences: use std::string in struct preferences 2024-08-13 19:28:30 +02:00
README.md

Short explanation of how qPref works

System startup:

core/qt-init.cpp init_qt_late()

does

qPref::load();

to load all properties from all qPref* classes

System shutdown:

subsurface-mobile-main.cpp and subsurface-desktop-main.cpp main()

calls

call qPref::sync()

to save all changes to disk, this is needed because part of the program modifies struct preferences instead of calling the set method.

EXCEPTION:

Variables not present in struct preferences (local static variables in the class are not written, see later.

System startup/shutdown common handling:

qPref::load() calls qPref::doSync(false)
qPref::sync() calls qPref::doSync(true)

qPrefDoSync()

qPref::doSync() calls qPref::doSync() for all qPref* classes Meaning qPref knows which classes exist, but not which variables

qPref*::doSync() calls

disk_<variable name>() for each variable

EXCEPTION:

some variables are not in struct preferences, but local static variables which can only be accessed through the set/get functions, therefore there are no need to sync them

	if (!doSync) // meaining load
		load_<variable_name>()

qPref*::disk_*()

qPref*::disk_*() calls qPrefPrivate::propSetValue to save a property, and qPrefPrivate::propValue() to read a property. The function also keeps struct preferences in sync.

qPrefPrivate::propSetValue()

qPrefPrivate::propSetValue() is static and calls QSettings to write property

qPrefPrivate::propValue()

qPrefPrivate::propValue() is static and calls QSettings to read property

macros

the macros are defined in qPrefPrivate.h

the macros are used in qPref*cpp

Reading properties

Reading a property is done through an inline function, and thus no more expensive than accessing the variable directly.

qPref*::<variable_name>()

Setting properties

Setting a property is done through a dedicated set function which are static to simplify the call:

qPref<class>::set_<variable_name>(value)

like:

qPrefDisplay::animation_speed(500);

the set function updates struct preferences (if not a local variable), and saves the property to disk, however save is only done if the variable is changed.

Updating struct preferences

When a program part updates struct preferences directly, changes are NOT saved to disk if the programm crashes, otherwise all variables are saved to disk with the program exists.