diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-05-31 13:53:18 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-31 06:26:55 -0700 |
commit | eb26823b3476dca68200017948b73cb405ef803a (patch) | |
tree | 8ee51c37c7a887b574cd00c3d183fd4275486cff /qt-ui/diveplanner.cpp | |
parent | 6f1e071a54224700de8f96d0eefa0ee807f886b0 (diff) | |
download | subsurface-eb26823b3476dca68200017948b73cb405ef803a.tar.gz |
Allow editing segment duration. This shifts all following waypoints.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 21559a65a..c73487048 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -388,6 +388,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v { int o2 = 0; int he = 0; + int i, shift; if (role == Qt::EditRole) { divedatapoint &p = divepoints[index.row()]; switch (index.column()) { @@ -398,10 +399,13 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v p.time = value.toInt() * 60; break; case DURATION: - if (index.row()) - p.time = value.toInt() * 60 + divepoints[index.row() - 1].time; + i = index.row(); + if (i) + shift = divepoints[i].time - divepoints[i - 1].time - value.toInt() * 60; else - p.time = value.toInt() * 60; + shift = divepoints[i].time - value.toInt() * 60; + while (i < divepoints.size()) + divepoints[i++].time -= shift; break; case CCSETPOINT: { int po2 = 0; @@ -445,7 +449,7 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta Qt::ItemFlags DivePlannerPointsModel::flags(const QModelIndex &index) const { - if (index.column() != DURATION && index.column() != REMOVE) + if (index.column() != REMOVE) return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; else return QAbstractItemModel::flags(index); |