summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2018-03-28 22:50:28 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-05-14 23:47:00 +0300
commit69de9d8f988aecc59b53c5bf1a1ec55d6529c59e (patch)
tree2b6e11f2bc362f6dbfc2160a9f1241cc5aa99851 /qt-models
parent6b0ecb012dcfe1945bedf38fe25f67a1d2c3c400 (diff)
downloadsubsurface-69de9d8f988aecc59b53c5bf1a1ec55d6529c59e.tar.gz
Add planner infra structure for bailout
Add a divemode column to the planner model and a corresponding field to struct divepoint and fill it in the corresponding functions. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveplannermodel.cpp22
-rw-r--r--qt-models/diveplannermodel.h1
2 files changed, 20 insertions, 3 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index deb3afe82..8103d4d1b 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -252,6 +252,8 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
return (p.time - divepoints.at(index.row() - 1).time) / 60;
else
return p.time / 60;
+ case DIVEMODE:
+ return QString(divemode_text[p.divemode]);
case GAS:
/* Check if we have the same gasmix two or more times
* If yes return more verbose string */
@@ -330,6 +332,12 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
CylindersModel::instance()->moveAtFirst(value.toInt());
CylindersModel::instance()->updateTrashIcon();
break;
+ case DIVEMODE:
+ if (value.toInt() < FREEDIVE) // FIXME: I want to be a combo box and translate strings to enum values
+ p.divemode = (enum dive_comp_type) value.toInt();
+ if (index.row() == 0)
+ displayed_dive.dc.divemode = (enum dive_comp_type) value.toInt();
+ break;
}
editStop(index.row(), p);
}
@@ -367,6 +375,8 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta
return tr("Used gas");
case CCSETPOINT:
return tr("CC setpoint");
+ case DIVEMODE:
+ return tr("Dive mode");
}
} else if (role == Qt::FontRole) {
return defaultModelFont();
@@ -457,8 +467,10 @@ void DivePlannerPointsModel::setRebreatherMode(int mode)
{
int i;
displayed_dive.dc.divemode = (dive_comp_type) mode;
- for (i=0; i < rowCount(); i++)
+ for (i=0; i < rowCount(); i++) {
divepoints[i].setpoint = mode == CCR ? prefs.defaultsetpoint : 0;
+ divepoints[i].divemode = (enum dive_comp_type) mode;
+ }
emitDataChanged();
}
@@ -661,6 +673,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
{
int cylinderid = 0;
bool usePrevious = false;
+ enum dive_comp_type divemode = displayed_dive.dc.divemode;
if (cylinderid_in >= 0)
cylinderid = cylinderid_in;
else
@@ -703,8 +716,10 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
if (usePrevious) {
if (row < divepoints.count()) {
cylinderid = divepoints.at(row).cylinderid;
+ divemode = divepoints.at(row).divemode;
} else if (row > 0) {
cylinderid = divepoints.at(row - 1).cylinderid;
+ divemode = divepoints.at(row - 1).divemode;
}
}
@@ -716,6 +731,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
point.cylinderid = cylinderid;
point.setpoint = ccpoint;
point.entered = entered;
+ point.divemode = divemode;
point.next = NULL;
divepoints.append(point);
std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
@@ -864,11 +880,11 @@ void DivePlannerPointsModel::createTemporaryPlan()
lastIndex = i;
if (i == 0 && mode == PLAN && prefs.drop_stone_mode) {
/* Okay, we add a first segment where we go down to depth */
- plan_add_segment(&diveplan, p.depth.mm / prefs.descrate, p.depth.mm, p.cylinderid, p.setpoint, true);
+ plan_add_segment(&diveplan, p.depth.mm / prefs.descrate, p.depth.mm, p.cylinderid, p.setpoint, true, p.divemode);
deltaT -= p.depth.mm / prefs.descrate;
}
if (p.entered)
- plan_add_segment(&diveplan, deltaT, p.depth.mm, p.cylinderid, p.setpoint, true);
+ plan_add_segment(&diveplan, deltaT, p.depth.mm, p.cylinderid, p.setpoint, true, p.divemode);
}
// what does the cache do???
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index dfafe2b27..371afb30c 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -18,6 +18,7 @@ public:
RUNTIME,
GAS,
CCSETPOINT,
+ DIVEMODE,
COLUMNS
};
enum Mode {