summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/cylindermodel.cpp34
-rw-r--r--qt-models/diveplannermodel.cpp49
2 files changed, 41 insertions, 42 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 9a093112c..11d4595ee 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -100,7 +100,7 @@ static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
if (!vol)
return QVariant();
- Z = gas_compressibility_factor(&cyl->gasmix, p.mbar / 1000.0);
+ Z = gas_compressibility_factor(cyl->gasmix, p.mbar / 1000.0);
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
}
@@ -212,14 +212,14 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
} else {
pressure_t modpO2;
modpO2.mbar = prefs.bottompo2;
- ret = get_depth_string(gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true);
+ ret = get_depth_string(gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(1,1)), true);
}
break;
case MND:
if (cyl->bestmix_he)
ret = QString("*");
else
- ret = get_depth_string(gas_mnd(&cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
+ ret = get_depth_string(gas_mnd(cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
break;
case USE:
ret = gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]);
@@ -353,15 +353,15 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
if (CHANGED()) {
cyl->gasmix.o2 = string_to_fraction(qPrintable(vString));
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
pressure_t modpO2;
if (displayed_dive.dc.divemode == PSCR)
- modpO2.mbar = prefs.decopo2 + (1000 - get_o2(&cyl->gasmix)) * SURFACE_PRESSURE *
+ modpO2.mbar = prefs.decopo2 + (1000 - get_o2(cyl->gasmix)) * SURFACE_PRESSURE *
prefs.o2consumption / prefs.decosac / prefs.pscr_ratio;
else
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
+ cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
cyl->bestmix_o2 = false;
changed = true;
}
@@ -370,8 +370,8 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
if (CHANGED()) {
cyl->gasmix.he = string_to_fraction(qPrintable(vString));
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.o2.permille = 1000 - get_he(cyl->gasmix);
cyl->bestmix_he = false;
changed = true;
}
@@ -395,7 +395,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
}
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
+ cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
changed = true;
}
break;
@@ -588,8 +588,8 @@ void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
cylinder_t *cyl = &displayed_dive.cylinder[i];
/* If the gas's deco MOD matches the old pO2, it will have been automatically calculated and should be updated.
* If they don't match, we should leave the user entered depth as it is */
- if (cyl->depth.mm == gas_mod(&cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) {
- cyl->depth = gas_mod(&cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10));
+ if (cyl->depth.mm == gas_mod(cyl->gasmix, olddecopo2, &displayed_dive, M_OR_FT(3, 10)).mm) {
+ cyl->depth = gas_mod(cyl->gasmix, decopo2, &displayed_dive, M_OR_FT(3, 10));
}
}
emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
@@ -609,18 +609,18 @@ bool CylindersModel::updateBestMixes()
if (cyl->bestmix_o2) {
cyl->gasmix.o2 = best_o2(displayed_dive.maxdepth, &displayed_dive);
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.he.permille = 1000 - get_o2(cyl->gasmix);
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
+ cyl->depth = gas_mod(cyl->gasmix, modpO2, &displayed_dive, M_OR_FT(3, 10));
gasUpdated = true;
}
if (cyl->bestmix_he) {
cyl->gasmix.he = best_he(displayed_dive.maxdepth, &displayed_dive);
// fO2 + fHe must not be greater than 1
- if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
- cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
+ if (get_o2(cyl->gasmix) + get_he(cyl->gasmix) > 1000)
+ cyl->gasmix.o2.permille = 1000 - get_he(cyl->gasmix);
gasUpdated = true;
}
}
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index c26cac76a..32231ecca 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -6,7 +6,7 @@
#include "qt-models/models.h"
#include "core/device.h"
#include "core/qthelper.h"
-#include "core/subsurface-qt/SettingsObjectWrapper.h"
+#include "core/settings/qPrefDivePlanner.h"
#include "core/gettextfromc.h"
#include <QApplication>
#include <QTextDocument>
@@ -81,7 +81,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
o2pressure_t last_sp;
bool oldRec = recalc;
struct divecomputer *dc = &(d->dc);
- struct event *evd = NULL;
+ const struct event *evd = NULL;
enum divemode_t current_divemode = UNDEF_COMP_TYPE;
recalc = false;
CylindersModel::instance()->updateDive();
@@ -427,26 +427,26 @@ void DivePlannerPointsModel::emitDataChanged()
void DivePlannerPointsModel::setBottomSac(double sac)
{
diveplan.bottomsac = units_to_sac(sac);
- qPrefDivePlanner::instance()->set_bottomsac(diveplan.bottomsac);
+ qPrefDivePlanner::set_bottomsac(diveplan.bottomsac);
emitDataChanged();
}
void DivePlannerPointsModel::setDecoSac(double sac)
{
diveplan.decosac = units_to_sac(sac);
- qPrefDivePlanner::instance()->set_decosac(diveplan.decosac);
+ qPrefDivePlanner::set_decosac(diveplan.decosac);
emitDataChanged();
}
void DivePlannerPointsModel::setSacFactor(double factor)
{
- qPrefDivePlanner::instance()->set_sacfactor((int) round(factor * 100));
+ qPrefDivePlanner::set_sacfactor((int) round(factor * 100));
emitDataChanged();
}
void DivePlannerPointsModel::setProblemSolvingTime(int minutes)
{
- qPrefDivePlanner::instance()->set_problemsolvingtime(minutes);
+ qPrefDivePlanner::set_problemsolvingtime(minutes);
emitDataChanged();
}
@@ -504,96 +504,95 @@ int DivePlannerPointsModel::getSurfacePressure()
void DivePlannerPointsModel::setLastStop6m(bool value)
{
- qPrefDivePlanner::instance()->set_last_stop(value);
+ qPrefDivePlanner::set_last_stop(value);
emitDataChanged();
}
void DivePlannerPointsModel::setAscrate75(int rate)
{
- qPrefDivePlanner::instance()->set_ascrate75(lrint(rate * UNIT_FACTOR));
+ qPrefDivePlanner::set_ascrate75(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
void DivePlannerPointsModel::setAscrate50(int rate)
{
- qPrefDivePlanner::instance()->set_ascrate50(lrint(rate * UNIT_FACTOR));
+ qPrefDivePlanner::set_ascrate50(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
void DivePlannerPointsModel::setAscratestops(int rate)
{
- qPrefDivePlanner::instance()->set_ascratestops(lrint(rate * UNIT_FACTOR));
+ qPrefDivePlanner::set_ascratestops(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
void DivePlannerPointsModel::setAscratelast6m(int rate)
{
- qPrefDivePlanner::instance()->set_ascratelast6m(lrint(rate * UNIT_FACTOR));
+ qPrefDivePlanner::set_ascratelast6m(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
void DivePlannerPointsModel::setDescrate(int rate)
{
- qPrefDivePlanner::instance()->set_descrate(lrint(rate * UNIT_FACTOR));
+ qPrefDivePlanner::set_descrate(lrint(rate * UNIT_FACTOR));
emitDataChanged();
}
void DivePlannerPointsModel::setVerbatim(bool value)
{
- qPrefDivePlanner::instance()->set_verbatim_plan(value);
+ qPrefDivePlanner::set_verbatim_plan(value);
emitDataChanged();
}
void DivePlannerPointsModel::setDisplayRuntime(bool value)
{
- qPrefDivePlanner::instance()->set_display_runtime(value);
+ qPrefDivePlanner::set_display_runtime(value);
emitDataChanged();
}
void DivePlannerPointsModel::setDisplayDuration(bool value)
{
- qPrefDivePlanner::instance()->set_display_duration(value);
+ qPrefDivePlanner::set_display_duration(value);
emitDataChanged();
}
void DivePlannerPointsModel::setDisplayTransitions(bool value)
{
- qPrefDivePlanner::instance()->set_display_transitions(value);
+ qPrefDivePlanner::set_display_transitions(value);
emitDataChanged();
}
void DivePlannerPointsModel::setDisplayVariations(bool value)
{
- qPrefDivePlanner::instance()->set_display_variations(value);
+ qPrefDivePlanner::set_display_variations(value);
emitDataChanged();
}
void DivePlannerPointsModel::setDecoMode(int mode)
{
- qPrefDivePlanner::instance()->set_planner_deco_mode(deco_mode(mode));
+ qPrefDivePlanner::set_planner_deco_mode(deco_mode(mode));
emit recreationChanged(mode == int(prefs.planner_deco_mode));
emitDataChanged();
}
void DivePlannerPointsModel::setSafetyStop(bool value)
{
- qPrefDivePlanner::instance()->set_safetystop(value);
+ qPrefDivePlanner::set_safetystop(value);
emitDataChanged();
}
void DivePlannerPointsModel::setReserveGas(int reserve)
{
- auto planner = qPrefDivePlanner::instance();
if (prefs.units.pressure == units::BAR)
- planner->set_reserve_gas(reserve * 1000);
+ qPrefDivePlanner::set_reserve_gas(reserve * 1000);
else
- planner->set_reserve_gas(psi_to_mbar(reserve));
+ qPrefDivePlanner::set_reserve_gas(psi_to_mbar(reserve));
emitDataChanged();
}
void DivePlannerPointsModel::setDropStoneMode(bool value)
{
- qPrefDivePlanner::instance()->set_drop_stone_mode(value);
+ qPrefDivePlanner::set_drop_stone_mode(value);
if (prefs.drop_stone_mode) {
/* Remove the first entry if we enable drop_stone_mode */
if (rowCount() >= 2) {
@@ -615,13 +614,13 @@ void DivePlannerPointsModel::setDropStoneMode(bool value)
void DivePlannerPointsModel::setSwitchAtReqStop(bool value)
{
- qPrefDivePlanner::instance()->set_switch_at_req_stop(value);
+ qPrefDivePlanner::set_switch_at_req_stop(value);
emitDataChanged();
}
void DivePlannerPointsModel::setMinSwitchDuration(int duration)
{
- qPrefDivePlanner::instance()->set_min_switch_duration(duration * 60);
+ qPrefDivePlanner::set_min_switch_duration(duration * 60);
emitDataChanged();
}