Plasma
svgwidget.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "svgwidget.h"
00021
00022 #include <QtGui/QPainter>
00023 #include <QtGui/QGraphicsSceneMouseEvent>
00024
00025 #include "svg.h"
00026
00027 namespace Plasma
00028 {
00029 class SvgWidgetPrivate
00030 {
00031 public:
00032 SvgWidgetPrivate(Svg *s, const QString &element)
00033 : svg(s), elementID(element)
00034 {
00035 }
00036
00037 Svg *svg;
00038 QString elementID;
00039 };
00040
00041 SvgWidget::SvgWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
00042 : QGraphicsWidget(parent, wFlags),
00043 d(new SvgWidgetPrivate(0, QString()))
00044 {
00045 }
00046
00047 SvgWidget::SvgWidget(Svg *svg, const QString &elementID, QGraphicsItem *parent, Qt::WindowFlags wFlags)
00048 : QGraphicsWidget(parent, wFlags),
00049 d(new SvgWidgetPrivate(svg, elementID))
00050 {
00051 }
00052
00053 SvgWidget::~SvgWidget()
00054 {
00055 delete d;
00056 }
00057
00058 void SvgWidget::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
00059 {
00060 if (receivers(SIGNAL(clicked(Qt::MouseButton)))){
00061 emit clicked(event->button());
00062 }else{
00063 event->accept();
00064 }
00065 }
00066
00067 void SvgWidget::setSvg(Svg *svg)
00068 {
00069 d->svg = svg;
00070 }
00071
00072 Svg *SvgWidget::svg() const
00073 {
00074 return d->svg;
00075 }
00076
00077 void SvgWidget::setElementID(const QString &elementID)
00078 {
00079 d->elementID = elementID;
00080 }
00081
00082 QString SvgWidget::elementID() const
00083 {
00084 return d->elementID;
00085 }
00086
00087 void SvgWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
00088 {
00089 Q_UNUSED(option);
00090 Q_UNUSED(widget);
00091
00092 if (d->svg){
00093 d->svg->paint(painter, boundingRect(), d->elementID);
00094 }
00095 }
00096
00097 }
00098
00099 #include "svgwidget.moc"