aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget/diveeventitem.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-06-05 09:15:51 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-06-05 11:29:00 -0700
commitfd2862042b1aa925bd842f512ee6260865e2f5b1 (patch)
tree4bfd092b0fc2573a53e07b1ff82201e0acc632e8 /profile-widget/diveeventitem.cpp
parentc93fb83edfe4bfab6bd2c01e2c54cfe7b39f0506 (diff)
downloadsubsurface-fd2862042b1aa925bd842f512ee6260865e2f5b1.tar.gz
profile: pass axes and model to DiveEventItem on construction
Firstly, there is no point in supporting DiveEventItems without model and axis. Secondly, this avoid pointless position- recalculations. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/diveeventitem.cpp')
-rw-r--r--profile-widget/diveeventitem.cpp34
1 files changed, 10 insertions, 24 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp
index 3590a35c8..1a0694979 100644
--- a/profile-widget/diveeventitem.cpp
+++ b/profile-widget/diveeventitem.cpp
@@ -14,10 +14,12 @@
#define DEPTH_NOT_FOUND (-2342)
-DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix, QGraphicsItem *parent) : DivePixmapItem(parent),
- vAxis(NULL),
- hAxis(NULL),
- dataModel(NULL),
+DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
+ DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
+ int speed, QGraphicsItem *parent) : DivePixmapItem(parent),
+ vAxis(vAxis),
+ hAxis(hAxis),
+ dataModel(model),
internalEvent(clone_event(ev)),
dive(d)
{
@@ -26,31 +28,15 @@ DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasm
setupPixmap(lastgasmix);
setupToolTipString(lastgasmix);
recalculatePos(0);
-}
-DiveEventItem::~DiveEventItem()
-{
- free(internalEvent);
-}
-
-void DiveEventItem::setHorizontalAxis(DiveCartesianAxis *axis)
-{
- hAxis = axis;
- recalculatePos(0);
-}
-void DiveEventItem::setModel(DivePlotDataModel *model)
-{
- dataModel = model;
- recalculatePos(0);
+ connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
+ [speed, this] { recalculatePos(speed); });
}
-void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis, int speed)
+DiveEventItem::~DiveEventItem()
{
- vAxis = axis;
- recalculatePos(0);
- connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
- [speed, this] { recalculatePos(speed); });
+ free(internalEvent);
}
struct event *DiveEventItem::getEvent()