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); diff --git a/profile-widget/diveeventitem.h b/profile-widget/diveeventitem.h index 2039da616..0c065e131 100644 --- a/profile-widget/diveeventitem.h +++ b/profile-widget/diveeventitem.h @@ -16,13 +16,13 @@ public: void setEvent(struct event *ev, struct gasmix lastgasmix); struct event *getEvent(); void eventVisibilityChanged(const QString &eventName, bool visible); - void setVerticalAxis(DiveCartesianAxis *axis); + void setVerticalAxis(DiveCartesianAxis *axis, int speed); void setHorizontalAxis(DiveCartesianAxis *axis); void setModel(DivePlotDataModel *model); bool shouldBeHidden(); public slots: - void recalculatePos(bool instant = false); + void recalculatePos(int animationSpeed); private: void setupToolTipString(struct gasmix lastgasmix); diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index ca6ce3950..9eefb0fc1 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -788,7 +788,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict #endif DiveEventItem *item = new DiveEventItem(); item->setHorizontalAxis(timeAxis); - item->setVerticalAxis(profileYAxis); + item->setVerticalAxis(profileYAxis, qPrefDisplay::animation_speed()); item->setModel(dataModel); item->setEvent(event, lastgasmix); item->setZValue(2);