Make tooltips works

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-05-08 16:21:49 -03:00 committed by Dirk Hohndel
parent 2089c124a5
commit ce8d30b938
2 changed files with 12 additions and 0 deletions

View file

@ -11,6 +11,7 @@
#include <QIcon> #include <QIcon>
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QGraphicsSceneHoverEvent> #include <QGraphicsSceneHoverEvent>
#include <QMouseEvent>
#include "../color.h" #include "../color.h"
#include "../display.h" #include "../display.h"
@ -136,6 +137,16 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
fill_profile_color(); fill_profile_color();
} }
void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
{
toolTip->clear();
QList<QGraphicsItem*> items = scene()->items( mapToScene(event->pos() ), Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
Q_FOREACH(QGraphicsItem *item, items){
if (!item->toolTip().isEmpty())
toolTip->addToolTip(item->toolTip());
}
}
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event) bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
{ {
// This will "Eat" the default tooltip behavior. // This will "Eat" the default tooltip behavior.

View file

@ -87,6 +87,7 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent* event);
private: private:
void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi); void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi);