summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/diveplanner.cpp40
-rw-r--r--desktop-widgets/diveplanner.h10
-rw-r--r--qt-models/diveplannermodel.cpp37
-rw-r--r--qt-models/diveplannermodel.h5
4 files changed, 67 insertions, 25 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index b90772f39..0660b6631 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -359,16 +359,16 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.display_variations, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayVariations(bool)));
connect(ui.safetystop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSafetyStop(bool)));
connect(ui.reserve_gas, SIGNAL(valueChanged(int)), plannerModel, SLOT(setReserveGas(int)));
- connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRate50, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRateStops, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
- connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRate75, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRate50, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRateStops, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged()));
- connect(ui.ascRateLast6m, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged()));
- connect(ui.descRate, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged()));
+ connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscrate75(int)));
+ connect(ui.ascRate50, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscrate50(int)));
+ connect(ui.ascRateStops, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscratestops(int)));
+ connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), plannerModel, SLOT(setAscratelast6m(int)));
+ connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(setDescrate(int)));
+ connect(ui.ascRate75, SIGNAL(editingFinished()), plannerModel, SLOT(setAscrate75(int)));
+ connect(ui.ascRate50, SIGNAL(editingFinished()), plannerModel, SLOT(setAscrate50(int)));
+ connect(ui.ascRateStops, SIGNAL(editingFinished()), plannerModel, SLOT(setAscratestops(int)));
+ connect(ui.ascRateLast6m, SIGNAL(editingFinished()), plannerModel, SLOT(setAscratelast6m(int)));
+ connect(ui.descRate, SIGNAL(editingFinished()), plannerModel, SLOT(setDescrate(int)));
connect(ui.drop_stone_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setDropStoneMode(bool)));
connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int)));
connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
@@ -384,11 +384,11 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.bestmixEND, SIGNAL(valueChanged(int)), CylindersModel::instance(), SLOT(updateBestMixes()));
connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(disableDecoElements(int)));
- connect(ui.ascRate75, SIGNAL(valueChanged(int)), this, SLOT(setAscRate75(int)));
- connect(ui.ascRate50, SIGNAL(valueChanged(int)), this, SLOT(setAscRate50(int)));
- connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescRate(int)));
- connect(ui.ascRateStops, SIGNAL(valueChanged(int)), this, SLOT(setAscRateStops(int)));
- connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), this, SLOT(setAscRateLast6m(int)));
+ connect(ui.ascRate75, SIGNAL(valueChanged(int)), this, SLOT(setAscrate75(int)));
+ connect(ui.ascRate50, SIGNAL(valueChanged(int)), this, SLOT(setAscrate50(int)));
+ connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescrate(int)));
+ connect(ui.ascRateStops, SIGNAL(valueChanged(int)), this, SLOT(setAscratestops(int)));
+ connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), this, SLOT(setAscratelast6m(int)));
connect(ui.sacfactor, SIGNAL(valueChanged(double)), this, SLOT(sacFactorChanged(double)));
connect(ui.problemsolvingtime, SIGNAL(valueChanged(int)), this, SLOT(problemSolvingTimeChanged(int)));
connect(ui.bottompo2, SIGNAL(valueChanged(double)), this, SLOT(setBottomPo2(double)));
@@ -484,27 +484,27 @@ void PlannerSettingsWidget::printDecoPlan()
{
}
-void PlannerSettingsWidget::setAscRate75(int rate)
+void PlannerSettingsWidget::setAscrate75(int rate)
{
SettingsObjectWrapper::instance()->planner_settings->setAscrate75(lrint(rate * UNIT_FACTOR));
}
-void PlannerSettingsWidget::setAscRate50(int rate)
+void PlannerSettingsWidget::setAscrate50(int rate)
{
SettingsObjectWrapper::instance()->planner_settings->setAscrate50(lrint(rate * UNIT_FACTOR));
}
-void PlannerSettingsWidget::setAscRateStops(int rate)
+void PlannerSettingsWidget::setAscratestops(int rate)
{
SettingsObjectWrapper::instance()->planner_settings->setAscratestops(lrint(rate * UNIT_FACTOR));
}
-void PlannerSettingsWidget::setAscRateLast6m(int rate)
+void PlannerSettingsWidget::setAscratelast6m(int rate)
{
SettingsObjectWrapper::instance()->planner_settings->setAscratelast6m(lrint(rate * UNIT_FACTOR));
}
-void PlannerSettingsWidget::setDescRate(int rate)
+void PlannerSettingsWidget::setDescrate(int rate)
{
SettingsObjectWrapper::instance()->planner_settings->setDescrate(lrint(rate * UNIT_FACTOR));
}
diff --git a/desktop-widgets/diveplanner.h b/desktop-widgets/diveplanner.h
index ee757abd2..59884534c 100644
--- a/desktop-widgets/diveplanner.h
+++ b/desktop-widgets/diveplanner.h
@@ -74,11 +74,11 @@ slots:
void bottomSacChanged(const double bottomSac);
void decoSacChanged(const double decosac);
void printDecoPlan();
- void setAscRate75(int rate);
- void setAscRate50(int rate);
- void setAscRateStops(int rate);
- void setAscRateLast6m(int rate);
- void setDescRate(int rate);
+ void setAscrate75(int rate);
+ void setAscrate50(int rate);
+ void setAscratestops(int rate);
+ void setAscratelast6m(int rate);
+ void setDescrate(int rate);
void sacFactorChanged(const double factor);
void problemSolvingTimeChanged(const int min);
void setBottomPo2(double po2);
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 4c60e6736..482647575 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -10,6 +10,8 @@
#include <QApplication>
#include <QTextDocument>
+#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0)
+
/* TODO: Port this to CleanerTableModel to remove a bit of boilerplate and
* use the signal warningMessage() to communicate errors to the MainWindow.
*/
@@ -494,6 +496,41 @@ void DivePlannerPointsModel::setLastStop6m(bool value)
emitDataChanged();
}
+void DivePlannerPointsModel::setAscrate75(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscrate75(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setAscrate50(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscrate50(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setAscratestops(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscratestops(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setAscratelast6m(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscratelast6m(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setDescrate(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDescrate(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
void DivePlannerPointsModel::setVerbatim(bool value)
{
auto planner = SettingsObjectWrapper::instance()->planner_settings;
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index aebeef766..43a1186d4 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -95,6 +95,11 @@ slots:
void setMinSwitchDuration(int duration);
void setSacFactor(double factor);
void setProblemSolvingTime(int minutes);
+ void setAscrate75(int rate);
+ void setAscrate50(int rate);
+ void setAscratestops(int rate);
+ void setAscratelast6m(int rate);
+ void setDescrate(int rate);
signals:
void planCreated();