mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-26 00:14:24 +02:00
Added tooltip event triggers for info messages
This commit is contained in:
36
src/GUI/graphicsscene.h
Normal file
36
src/GUI/graphicsscene.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef GRAPHICSSCENE_H
|
||||
#define GRAPHICSSCENE_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsSceneHelpEvent>
|
||||
#include <QWidget>
|
||||
#include "popup.h"
|
||||
|
||||
class GraphicsItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
GraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) {}
|
||||
|
||||
virtual QString info() const = 0;
|
||||
int type() const {return QGraphicsItem::UserType + 1;}
|
||||
};
|
||||
|
||||
class GraphicsScene : public QGraphicsScene
|
||||
{
|
||||
public:
|
||||
GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
||||
|
||||
protected:
|
||||
void helpEvent(QGraphicsSceneHelpEvent *event)
|
||||
{
|
||||
QGraphicsItem *item = itemAt(event->scenePos(), QTransform());
|
||||
if (item && item->type() == QGraphicsItem::UserType + 1) {
|
||||
GraphicsItem *mi = static_cast<GraphicsItem*>(item);
|
||||
Popup::show(event->screenPos(), mi->info(),
|
||||
static_cast<QWidget*>(parent()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GRAPHICSSCENE_H
|
Reference in New Issue
Block a user