Added click signal to SvgWidget.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=874074
This commit is contained in:
Davide Bettio 2008-10-20 18:26:25 +00:00
parent 1dc982c466
commit 9ed5641257
2 changed files with 18 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include "svgwidget.h"
#include <QtGui/QPainter>
#include <QtGui/QGraphicsSceneMouseEvent>
#include "svg.h"
@ -54,6 +55,15 @@ SvgWidget::~SvgWidget()
delete d;
}
void SvgWidget::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
{
if (receivers(SIGNAL(clicked(Qt::MouseButton)))){
emit clicked(event->button());
}else{
event->accept();
}
}
void SvgWidget::setSvg(Svg *svg)
{
d->svg = svg;

View File

@ -20,7 +20,6 @@
#ifndef PLASMA_GRAPHICSSVGITEM_H
#define PLASMA_GRAPHICSSVGITEM_H
#include <QtCore/QObject>
#include <QtGui/QGraphicsWidget>
#include <plasma/plasma_export.h>
@ -37,18 +36,26 @@ class PLASMA_EXPORT SvgWidget : public QGraphicsWidget
{
Q_OBJECT
Q_PROPERTY(Svg *svg READ svg WRITE setSvg)
Q_PROPERTY(QString elementID READ elementID WRITE setElementID)
public:
SvgWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
SvgWidget(Svg *svg, const QString & elementID = QString(),
QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
virtual ~SvgWidget();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
void setSvg(Svg *svg);
Svg *svg() const;
void setElementID(const QString &elementID);
QString elementID() const;
signals:
void clicked(Qt::MouseButton);
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);