mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Planner: enforce minimal segement duration
You cannot be at two depths at the same time (and it confuses the planner). So give yourself at least 10 seconds. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6ad55cd63b
commit
e946ce98fe
1 changed files with 27 additions and 9 deletions
|
@ -339,17 +339,35 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RUNTIME:
|
case RUNTIME:
|
||||||
p.time = value.toInt() * 60;
|
{
|
||||||
|
int secs = value.toInt() * 60;
|
||||||
|
i = index.row();
|
||||||
|
int duration = secs;
|
||||||
|
if (i)
|
||||||
|
duration -= divepoints[i-1].time;
|
||||||
|
// Make sure segments have a minimal duration
|
||||||
|
if (duration <= 0)
|
||||||
|
secs += 10 - duration;
|
||||||
|
p.time = secs;
|
||||||
|
while (++i < divepoints.size())
|
||||||
|
if (divepoints[i].time < divepoints[i - 1].time + 10)
|
||||||
|
divepoints[i].time = divepoints[i - 1].time + 10;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DURATION:
|
case DURATION:
|
||||||
i = index.row();
|
{
|
||||||
if (i)
|
int secs = value.toInt() * 60;
|
||||||
shift = divepoints[i].time - divepoints[i - 1].time - value.toInt() * 60;
|
if (!secs)
|
||||||
else
|
secs = 10;
|
||||||
shift = divepoints[i].time - value.toInt() * 60;
|
i = index.row();
|
||||||
while (i < divepoints.size())
|
if (i)
|
||||||
divepoints[i++].time -= shift;
|
shift = divepoints[i].time - divepoints[i - 1].time - secs;
|
||||||
break;
|
else
|
||||||
|
shift = divepoints[i].time - secs;
|
||||||
|
while (i < divepoints.size())
|
||||||
|
divepoints[i++].time -= shift;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CCSETPOINT: {
|
case CCSETPOINT: {
|
||||||
int po2 = 0;
|
int po2 = 0;
|
||||||
QByteArray gasv = value.toByteArray();
|
QByteArray gasv = value.toByteArray();
|
||||||
|
|
Loading…
Reference in a new issue