aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget/diveeventitem.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-06-05 09:05:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-06-05 11:29:00 -0700
commitc93fb83edfe4bfab6bd2c01e2c54cfe7b39f0506 (patch)
tree58a72e048d0483734b6552f80a42d558f8235dd3 /profile-widget/diveeventitem.cpp
parente42fc1a1e9a13c77d3474dbcb26b68b8772b8c6d (diff)
downloadsubsurface-c93fb83edfe4bfab6bd2c01e2c54cfe7b39f0506.tar.gz
profile: pass event at construction time to DiveEventItem
There is no point in having a dive event without an event. Let's pass the event at construction time to avoid having to handle "invalid" events. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/diveeventitem.cpp')
-rw-r--r--profile-widget/diveeventitem.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp
index 9cb28e168..3590a35c8 100644
--- a/profile-widget/diveeventitem.cpp
+++ b/profile-widget/diveeventitem.cpp
@@ -14,14 +14,18 @@
#define DEPTH_NOT_FOUND (-2342)
-DiveEventItem::DiveEventItem(QGraphicsItem *parent) : DivePixmapItem(parent),
+DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix, QGraphicsItem *parent) : DivePixmapItem(parent),
vAxis(NULL),
hAxis(NULL),
dataModel(NULL),
- internalEvent(NULL),
- dive(NULL)
+ internalEvent(clone_event(ev)),
+ dive(d)
{
setFlag(ItemIgnoresTransformations);
+
+ setupPixmap(lastgasmix);
+ setupToolTipString(lastgasmix);
+ recalculatePos(0);
}
DiveEventItem::~DiveEventItem()
@@ -54,19 +58,6 @@ struct event *DiveEventItem::getEvent()
return internalEvent;
}
-void DiveEventItem::setEvent(const struct dive *d, struct event *ev, struct gasmix lastgasmix)
-{
- if (!ev)
- return;
-
- dive = d;
- free(internalEvent);
- internalEvent = clone_event(ev);
- setupPixmap(lastgasmix);
- setupToolTipString(lastgasmix);
- recalculatePos(0);
-}
-
void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
{
const IconMetrics& metrics = defaultIconMetrics();