summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/diveeventitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/profile/diveeventitem.cpp')
-rw-r--r--qt-ui/profile/diveeventitem.cpp53
1 files changed, 23 insertions, 30 deletions
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index fc852da64..f3740ef08 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -2,6 +2,7 @@
#include "diveplotdatamodel.h"
#include "divecartesianaxis.h"
#include "animationfunctions.h"
+#include "libdivecomputer.h"
#include "dive.h"
#include <QDebug>
@@ -31,6 +32,11 @@ void DiveEventItem::setVerticalAxis(DiveCartesianAxis* axis)
connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(recalculatePos()));
}
+struct event *DiveEventItem::getEvent()
+{
+ return internalEvent;
+}
+
void DiveEventItem::setEvent(struct event* ev)
{
if (!ev)
@@ -62,47 +68,34 @@ void DiveEventItem::setupPixmap()
void DiveEventItem::setupToolTipString()
{
- //TODO Fix this. :)
-#if 0
- This needs to be redone, but right now the events are being plotted and I liked pretty much the code.
-
- struct dive *dive = getDiveById(diveId);
- Q_ASSERT(dive != NULL);
- EventItem *item = new EventItem(ev, 0, isGrayscale);
- item->setPos(x, y);
- scene()->addItem(item);
-
- /* we display the event on screen - so translate (with the correct context for events) */
- QString name = gettextFromC::instance()->tr(ev->name);
- if (ev->value) {
- if (ev->name && strcmp(ev->name, "gaschange") == 0) {
- int he = get_he(&dive->cylinder[entry->cylinderindex].gasmix);
- int o2 = get_o2(&dive->cylinder[entry->cylinderindex].gasmix);
+ // we display the event on screen - so translate
+ QString name = tr(internalEvent->name);
+ int value = internalEvent->value;
+ if (value) {
+ if (name == "gaschange") {
+ int he = value >> 16;
+ int o2 = value & 0xffff;
name += ": ";
if (he)
- name += QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10);
+ name += QString("%1/%2").arg(o2).arg(he);
else if (is_air(o2, he))
name += tr("air");
else
- name += QString(tr("EAN%1")).arg((o2 + 5) / 10);
-
- } else if (ev->name && !strcmp(ev->name, "SP change")) {
- name += QString(":%1").arg((double) ev->value / 1000);
+ name += QString(tr("EAN%1")).arg(o2);
+ } else if (name == "SP change") {
+ name += QString(":%1").arg((double) value / 1000);
} else {
- name += QString(":%1").arg(ev->value);
+ name += QString(":%1").arg(value);
}
- } else if (ev->name && name == "SP change") {
+ } else if (name == "SP change") {
name += "\n" + tr("Bailing out to OC");
} else {
- name += ev->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") :
- ev->flags == SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : "";
+ name += internalEvent->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") :
+ internalEvent->flags == SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : "";
}
-
- //item->setToolTipController(toolTip);
- //item->addToolTip(name);
- item->setToolTip(name);
-#endif
+ // qDebug() << name;
+ setToolTip(name);
}
void DiveEventItem::eventVisibilityChanged(const QString& eventName, bool visible)