diff options
-rw-r--r-- | qt-ui/diveplanner.cpp | 34 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 4 |
2 files changed, 33 insertions, 5 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index a250b08ad..09320cafe 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -412,6 +412,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) connect(ui.decoStopSAC, SIGNAL(valueChanged(int)), this, SLOT(decoSacChanged(int))); connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int))); connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int))); + connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh())); + connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow())); connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool))); ui.bottomSAC->setValue(prefs.bottomsac / 1000.0); @@ -667,7 +669,10 @@ int DivePlannerPointsModel::rowCount(const QModelIndex &parent) const return divepoints.count(); } -DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent), mode(NOTHING) +DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent), + mode(NOTHING), + tempGFHigh(100), + tempGFLow(100) { memset(&diveplan, 0, sizeof(diveplan)); } @@ -699,14 +704,33 @@ void DivePlannerPointsModel::setDecoSac(int sac) void DivePlannerPointsModel::setGFHigh(const int gfhigh) { - diveplan.gfhigh = gfhigh; - plannerModel->emitDataChanged(); + tempGFHigh = gfhigh; + // GFHigh <= 34 can cause infinite deco at 6m - don't trigger a recalculation + // for smaller GFHigh unless the user explicitly leaves the field + if (tempGFHigh > 34) + triggerGFHigh(); +} + +void DivePlannerPointsModel::triggerGFHigh() +{ + if (diveplan.gfhigh != tempGFHigh) { + diveplan.gfhigh = tempGFHigh; + plannerModel->emitDataChanged(); + } } void DivePlannerPointsModel::setGFLow(const int ghflow) { - diveplan.gflow = ghflow; - plannerModel->emitDataChanged(); + tempGFLow = ghflow; + triggerGFLow(); +} + +void DivePlannerPointsModel::triggerGFLow() +{ + if (diveplan.gflow != tempGFLow) { + diveplan.gflow = tempGFLow; + plannerModel->emitDataChanged(); + } } void DivePlannerPointsModel::setSurfacePressure(int pressure) diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 26e2943fc..22c599ab1 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -65,7 +65,9 @@ slots: int addStop(int millimeters = 0, int seconds = 0, struct gasmix *gas = 0, int ccpoint = 0, bool entered = true); void addCylinder_clicked(); void setGFHigh(const int gfhigh); + void triggerGFHigh(); void setGFLow(const int ghflow); + void triggerGFLow(); void setSurfacePressure(int pressure); int getSurfacePressure(); void setBottomSac(int sac); @@ -103,6 +105,8 @@ private: QVector<sample> backupSamples; // For editing added dives. QVector<QPair<int, int> > oldGases; QDateTime startTime; + int tempGFHigh; + int tempGFLow; }; class DiveHandler : public QObject, public QGraphicsEllipseItem { |