• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

svgwidget.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
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     update();
00071 }
00072 
00073 Svg *SvgWidget::svg() const
00074 {
00075     return d->svg;
00076 }
00077 
00078 void SvgWidget::setElementID(const QString &elementID)
00079 {
00080     d->elementID = elementID;
00081     update();
00082 }
00083 
00084 QString SvgWidget::elementID() const
00085 {
00086     return d->elementID;
00087 }
00088 
00089 void SvgWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
00090 {
00091     Q_UNUSED(option);
00092     Q_UNUSED(widget);
00093 
00094     if (d->svg){
00095         d->svg->paint(painter, boundingRect(), d->elementID);
00096     }
00097 }
00098 
00099 } // Plasma namespace
00100 
00101 #include "svgwidget.moc"

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal