diff options
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/cylindermodel.cpp | 13 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 767ba7621..fe63cf6f2 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -480,7 +480,7 @@ void CylindersModel::copyFromDive(dive *d) Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const { - if (index.column() == REMOVE) + if (index.column() == REMOVE || index.column() == USE) return Qt::ItemIsEnabled; return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; } @@ -488,6 +488,17 @@ Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const void CylindersModel::remove(const QModelIndex &index) { int mapping[MAX_CYLINDERS]; + + if (index.column() == USE) { + cylinder_t *cyl = cylinderAt(index); + if (cyl->cylinder_use == OC_GAS) + cyl->cylinder_use = NOT_USED; + else if (cyl->cylinder_use == NOT_USED) + cyl->cylinder_use = OC_GAS; + changed = true; + dataChanged(index, index); + return; + } if (index.column() != REMOVE) { return; } diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index d214ebaac..28941e2e9 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -798,7 +798,7 @@ void DivePlannerPointsModel::createTemporaryPlan() struct divedatapoint *dp = NULL; for (int i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = &displayed_dive.cylinder[i]; - if (cyl->depth.mm) { + if (cyl->depth.mm && cyl->cylinder_use != NOT_USED) { dp = create_dp(0, cyl->depth.mm, i, 0); if (diveplan.dp) { dp->next = diveplan.dp; |