aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-25 15:51:37 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-04-02 13:53:23 -0700
commit91136b2c510f4a63d451678deadc2f5c131136aa (patch)
tree5699ecca004ced6e4491907f585149317b739a73 /profile-widget
parentb9673df60bcc7f3135abc6dd866c3b412be46f92 (diff)
downloadsubsurface-91136b2c510f4a63d451678deadc2f5c131136aa.tar.gz
profile: remove special casing of handle moving
When moving the handle with the mouse, the old code tried to be smart about changing the active handle when crossing handles. To me this always felt weird and it was inconsistent with mouse-move. Theregore, simply do nothing special at all. The user should hopefully get an intiutive grasp of what's going on when moving one handler across another. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/profilewidget2.cpp38
-rw-r--r--profile-widget/profilewidget2.h2
2 files changed, 6 insertions, 34 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 0058eecdf..38bbfdd00 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1712,7 +1712,7 @@ DiveHandler *ProfileWidget2::createHandle()
{
DiveHandler *item = new DiveHandler(&displayed_dive);
scene()->addItem(item);
- connect(item, &DiveHandler::moved, this, &ProfileWidget2::recreatePlannedDive);
+ connect(item, &DiveHandler::moved, this, &ProfileWidget2::divePlannerHandlerMoved);
connect(item, &DiveHandler::clicked, this, &ProfileWidget2::divePlannerHandlerClicked);
connect(item, &DiveHandler::released, this, &ProfileWidget2::divePlannerHandlerReleased);
return item;
@@ -1798,49 +1798,21 @@ void ProfileWidget2::repositionDiveHandlers()
}
}
-int ProfileWidget2::fixHandlerIndex(DiveHandler *activeHandler)
-{
- int index = handleIndex(activeHandler);
- if (index > 0 && index < (int)handles.size() - 1) {
- DiveHandler *before = handles[index - 1].get();
- if (before->pos().x() > activeHandler->pos().x()) {
- std::swap(handles[index], handles[index - 1]);
- return index - 1;
- }
- DiveHandler *after = handles[index + 1].get();
- if (after->pos().x() < activeHandler->pos().x()) {
- std::swap(handles[index], handles[index + 1]);
- return index + 1;
- }
- }
- return index;
-}
-
-void ProfileWidget2::recreatePlannedDive()
+void ProfileWidget2::divePlannerHandlerMoved()
{
DiveHandler *activeHandler = qobject_cast<DiveHandler *>(sender());
- int index = fixHandlerIndex(activeHandler);
- int mintime = 0;
- int maxtime = plannerModel->at(plannerModel->size() - 1).time * 3 / 2;
- if (index > 0)
- mintime = plannerModel->at(index - 1).time;
- if (index < plannerModel->size() - 1)
- maxtime = plannerModel->at(index + 1).time;
+ int index = handleIndex(activeHandler);
+ // Grow the time axis if necessary.
int minutes = lrint(timeAxis->valueAt(activeHandler->pos()) / 60);
- if (minutes * 60 <= mintime || minutes * 60 >= maxtime)
- return;
if (minutes * 60 > timeAxis->maximum() * 0.9)
timeAxis->setMaximum(timeAxis->maximum() * 1.02);
divedatapoint data = plannerModel->at(index);
- depth_t oldDepth = data.depth;
- int oldtime = data.time;
data.depth.mm = lrint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
data.time = lrint(timeAxis->valueAt(activeHandler->pos()));
- if (data.depth.mm != oldDepth.mm || data.time != oldtime)
- plannerModel->editStop(index, data);
+ plannerModel->editStop(index, data);
}
void ProfileWidget2::keyDownAction()
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h
index 2437574a1..db9949d7b 100644
--- a/profile-widget/profilewidget2.h
+++ b/profile-widget/profilewidget2.h
@@ -124,7 +124,7 @@ slots: // Necessary to call from QAction's signals.
void removePicture(const QString &fileUrl);
/* this is called for every move on the handlers. maybe we can speed up this a bit? */
- void recreatePlannedDive();
+ void divePlannerHandlerMoved();
/* key press handlers */
void keyEscAction();