aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp21
-rw-r--r--qt-ui/profile/profilewidget2.h1
2 files changed, 20 insertions, 2 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index dd4ecca85..b1bf57f9f 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1009,12 +1009,29 @@ void ProfileWidget2::repositionDiveHandlers()
}
}
+int ProfileWidget2::fixHandlerIndex(DiveHandler *activeHandler)
+{
+ int index = handles.indexOf(activeHandler);
+ if (index > 0 && index < handles.count() - 1) {
+ DiveHandler *before = handles[index - 1];
+ if (before->pos().x() > activeHandler->pos().x()) {
+ handles.swap(index, index-1);
+ return index - 1;
+ }
+ DiveHandler *after = handles[index + 1];
+ if (after->pos().x() < activeHandler->pos().x()) {
+ handles.swap(index, index+1);
+ return index + 1;
+ }
+ }
+ return index;
+}
+
void ProfileWidget2::recreatePlannedDive()
{
DiveHandler *activeHandler = qobject_cast<DiveHandler*>(sender());
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
- int index = handles.indexOf(activeHandler);
-
+ int index = fixHandlerIndex(activeHandler);
int mintime = 0, maxtime = (timeAxis->maximum() + 10) * 60;
if (index > 0)
mintime = plannerModel->at(index - 1).time;
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 1c1258de5..4b1d881de 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -149,6 +149,7 @@ private:
QList<DiveHandler *> handles;
QList<QGraphicsSimpleTextItem *> gases;
void repositionDiveHandlers();
+ int fixHandlerIndex(DiveHandler *activeHandler);
};
#endif // PROFILEWIDGET2_H