diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-08-26 17:02:34 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-08-26 17:02:34 -0300 |
commit | 3323fecea86fdf3434d54ebfb88ae37b9812f5c5 (patch) | |
tree | 92da59b316ac374b52495c2c44289b691bc0600b /qt-ui/diveplanner.cpp | |
parent | 760c14ac0cb225ac391b9b9e04a1e9d5f7b3aa3c (diff) | |
download | subsurface-3323fecea86fdf3434d54ebfb88ae37b9812f5c5.tar.gz |
Made possible to add a divepoint between two others.
Made possible to add a divepoint between two others,
this also implemented the last patch in the correct way.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 61f39bc31..4752a9f2b 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -956,13 +956,18 @@ void DivePlannerPointsModel::setStartTime(const QTime& t) diveplan.when = t.msec(); } +bool divePointsLessThan(const divedatapoint& p1, const divedatapoint& p2){ + return p1.time <= p2.time; +} int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, int ccpoint) { int row = divepoints.count(); // check if there's already a new stop before this one: - Q_FOREACH(const divedatapoint& dp, divepoints){ + for(int i = 0; i < divepoints.count(); i++){ + const divedatapoint& dp = divepoints.at(i); if (dp.time > minutes ){ - return -1; + row = i; + break; } } @@ -975,6 +980,7 @@ int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, point.he = 0; point.po2 = 0; divepoints.append( point ); + std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan); endInsertRows(); return row; } |