summaryrefslogtreecommitdiffstats
path: root/profile-widget/diveeventitem.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-07-10 21:57:51 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2019-07-12 09:59:28 +0200
commit74244b3cfebb08d60fd32e938b396e8fa90a4774 (patch)
tree6dd3f26c4c9c40a6a77470addb5ebaaa5c9a7b1c /profile-widget/diveeventitem.cpp
parent5886550434e2c2e3c77880a4ee08f9d192d6984a (diff)
downloadsubsurface-74244b3cfebb08d60fd32e938b396e8fa90a4774.tar.gz
Profile: take int instead of bool in DiveEventItem::recalculatePos
The goal here is to slowly make animation speed a variable of the profile widget, not of the global preferences. Currently the code does some trickeries with setting / unsetting the global animation speed. Start by not taking a bool "instant" but a speed in DiveEventItem::recalculatePos(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/diveeventitem.cpp')
-rw-r--r--profile-widget/diveeventitem.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp
index afde2dc92..3e1430330 100644
--- a/profile-widget/diveeventitem.cpp
+++ b/profile-widget/diveeventitem.cpp
@@ -32,20 +32,21 @@ DiveEventItem::~DiveEventItem()
void DiveEventItem::setHorizontalAxis(DiveCartesianAxis *axis)
{
hAxis = axis;
- recalculatePos(true);
+ recalculatePos(0);
}
void DiveEventItem::setModel(DivePlotDataModel *model)
{
dataModel = model;
- recalculatePos(true);
+ recalculatePos(0);
}
-void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis)
+void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis, int speed)
{
vAxis = axis;
- recalculatePos(true);
- connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(recalculatePos()));
+ recalculatePos(0);
+ connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
+ [speed, this] { recalculatePos(speed); });
}
struct event *DiveEventItem::getEvent()
@@ -62,7 +63,7 @@ void DiveEventItem::setEvent(struct event *ev, struct gasmix lastgasmix)
internalEvent = clone_event(ev);
setupPixmap(lastgasmix);
setupToolTipString(lastgasmix);
- recalculatePos(true);
+ recalculatePos(0);
}
void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
@@ -268,7 +269,7 @@ int DiveEventItem::depthAtTime(int time)
return dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
}
-void DiveEventItem::recalculatePos(bool instant)
+void DiveEventItem::recalculatePos(int speed)
{
if (!vAxis || !hAxis || !internalEvent || !dataModel)
return;
@@ -286,7 +287,7 @@ void DiveEventItem::recalculatePos(bool instant)
show();
qreal x = hAxis->posAtValue(internalEvent->time.seconds);
qreal y = vAxis->posAtValue(depth);
- if (!instant)
+ if (speed > 0)
Animations::moveTo(this, x, y);
else
setPos(x, y);