diff options
author | Robert C. Helling <helling@atdotde.de> | 2017-01-23 17:35:27 +0100 |
---|---|---|
committer | Subsurface <dirk@subsurface-divelog.org> | 2017-01-23 22:11:51 -0800 |
commit | c1dc0c9ce0c0b8482dffba0b7becdec44d6f6bec (patch) | |
tree | fb2a6b4adacc0b80cad35d3688ec344dfc3532f6 /qt-models/cylindermodel.cpp | |
parent | 79bba04fd4e6472679e51c4210fd16a2f5292763 (diff) | |
download | subsurface-c1dc0c9ce0c0b8482dffba0b7becdec44d6f6bec.tar.gz |
Allow user to disable a cylinder in planner
In the cylinder table, the last column ("use") always showed
OC-GAS. Editing was enabled, but the user had to guess to enter
a small integer meaning dilluent or CCR oxygen cylingder. I guess,
nobody has ever done that.
This patch makes this column clickable. A click toggles if the cylinder
is used for planning or not. This wait it is much easier to investigate
the consequences of gas loss on a plan.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'qt-models/cylindermodel.cpp')
-rw-r--r-- | qt-models/cylindermodel.cpp | 13 |
1 files changed, 12 insertions, 1 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; } |