Work on the tooltips - WIP.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-05-08 07:22:23 -03:00 committed by Dirk Hohndel
parent 76e1436f68
commit 2089c124a5
2 changed files with 15 additions and 29 deletions

View file

@ -123,6 +123,7 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
setScene(new QGraphicsScene());
setBackgroundBrush(QColor("#F3F3E6"));
scene()->setSceneRect(0,0,1000,1000);
scene()->installEventFilter(this);
setRenderHint(QPainter::Antialiasing);
setRenderHint(QPainter::HighQualityAntialiasing);
@ -135,6 +136,16 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
fill_profile_color();
}
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
{
// This will "Eat" the default tooltip behavior.
if (event->type() == QEvent::GraphicsSceneHelp){
event->ignore();
return true;
}
return QGraphicsView::eventFilter(obj, event);
}
static void plot_set_scale(scale_mode_t scale)
{
switch (scale) {
@ -355,8 +366,9 @@ void ProfileGraphicsView::plot_one_event(struct graphics_context *gc, struct plo
ev->flags == SAMPLE_FLAGS_END ? tr("Starts with space!", " end") : "";
}
item->setToolTipController(toolTip);
item->addToolTip(name);
//item->setToolTipController(toolTip);
//item->addToolTip(name);
item->setToolTip(name);
}
void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct plot_info *pi)
@ -809,24 +821,3 @@ EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
ball->setBrush(QBrush(Qt::black));
}
void EventItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
controller->addToolTip(text, icon);
}
void EventItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
{
controller->removeToolTip(text);
}
void EventItem::addToolTip(const QString& t, const QIcon& i)
{
text = t;
icon = i;
}
void EventItem::setToolTipController(ToolTipItem* c)
{
controller = c;
}

View file

@ -70,12 +70,6 @@ class EventItem : public QGraphicsPolygonItem
{
public:
explicit EventItem(QGraphicsItem* parent = 0);
void addToolTip(const QString& text,const QIcon& icon = QIcon());
void setToolTipController(ToolTipItem *controller);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
private:
ToolTipItem *controller;
@ -89,6 +83,7 @@ Q_OBJECT
public:
ProfileGraphicsView(QWidget* parent = 0);
void plot(struct dive *d);
bool eventFilter(QObject* obj, QEvent* event);
protected:
void resizeEvent(QResizeEvent *event);