New profile: add event info to tooltip

This appears to correctly add the tooltip to the event item, but for some
reason the tooltip isn't displayed for most events.

Still needs more work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-02-25 12:27:12 -08:00
parent b5a02e50aa
commit c0e489c1ea
3 changed files with 25 additions and 30 deletions

View file

@ -2,6 +2,7 @@
#include "diveplotdatamodel.h" #include "diveplotdatamodel.h"
#include "divecartesianaxis.h" #include "divecartesianaxis.h"
#include "animationfunctions.h" #include "animationfunctions.h"
#include "libdivecomputer.h"
#include "dive.h" #include "dive.h"
#include <QDebug> #include <QDebug>
@ -31,6 +32,11 @@ void DiveEventItem::setVerticalAxis(DiveCartesianAxis* axis)
connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(recalculatePos())); connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(recalculatePos()));
} }
struct event *DiveEventItem::getEvent()
{
return internalEvent;
}
void DiveEventItem::setEvent(struct event* ev) void DiveEventItem::setEvent(struct event* ev)
{ {
if (!ev) if (!ev)
@ -62,47 +68,34 @@ void DiveEventItem::setupPixmap()
void DiveEventItem::setupToolTipString() void DiveEventItem::setupToolTipString()
{ {
//TODO Fix this. :) // we display the event on screen - so translate
#if 0 QString name = tr(internalEvent->name);
This needs to be redone, but right now the events are being plotted and I liked pretty much the code. int value = internalEvent->value;
if (value) {
struct dive *dive = getDiveById(diveId); if (name == "gaschange") {
Q_ASSERT(dive != NULL); int he = value >> 16;
EventItem *item = new EventItem(ev, 0, isGrayscale); int o2 = value & 0xffff;
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);
name += ": "; name += ": ";
if (he) 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)) else if (is_air(o2, he))
name += tr("air"); name += tr("air");
else else
name += QString(tr("EAN%1")).arg((o2 + 5) / 10); name += QString(tr("EAN%1")).arg(o2);
} else if (name == "SP change") {
} else if (ev->name && !strcmp(ev->name, "SP change")) { name += QString(":%1").arg((double) value / 1000);
name += QString(":%1").arg((double) ev->value / 1000);
} else { } 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"); name += "\n" + tr("Bailing out to OC");
} else { } else {
name += ev->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") : name += internalEvent->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") :
ev->flags == SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : ""; internalEvent->flags == SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : "";
} }
// qDebug() << name;
//item->setToolTipController(toolTip); setToolTip(name);
//item->addToolTip(name);
item->setToolTip(name);
#endif
} }
void DiveEventItem::eventVisibilityChanged(const QString& eventName, bool visible) void DiveEventItem::eventVisibilityChanged(const QString& eventName, bool visible)

View file

@ -12,6 +12,7 @@ class DiveEventItem : public DivePixmapItem {
public: public:
DiveEventItem(QObject* parent = 0); DiveEventItem(QObject* parent = 0);
void setEvent(struct event *ev); void setEvent(struct event *ev);
struct event *getEvent();
void eventVisibilityChanged(const QString& eventName, bool visible); void eventVisibilityChanged(const QString& eventName, bool visible);
void setVerticalAxis(DiveCartesianAxis *axis); void setVerticalAxis(DiveCartesianAxis *axis);
void setHorizontalAxis(DiveCartesianAxis *axis); void setHorizontalAxis(DiveCartesianAxis *axis);

View file

@ -399,6 +399,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
// Only set visible the ones that should be visible, but how? // Only set visible the ones that should be visible, but how?
Q_FOREACH(DiveEventItem *event, eventItems){ Q_FOREACH(DiveEventItem *event, eventItems){
event->setVisible(true); event->setVisible(true);
// qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds;
} }
diveComputerText->setText(currentdc->model); diveComputerText->setText(currentdc->model);
} }