Added svgwidget.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=873133
This commit is contained in:
Davide Bettio 2008-10-18 21:30:02 +00:00
parent 62c417fe46
commit dd9445d885
4 changed files with 151 additions and 0 deletions

View File

@ -81,6 +81,7 @@ set(plasma_LIB_SRCS
widgets/scrollbar.cpp widgets/scrollbar.cpp
widgets/signalplotter.cpp widgets/signalplotter.cpp
widgets/slider.cpp widgets/slider.cpp
widgets/svgwidget.cpp
widgets/tabbar.cpp widgets/tabbar.cpp
widgets/treeview.cpp widgets/treeview.cpp
widgets/textedit.cpp widgets/textedit.cpp
@ -194,6 +195,7 @@ install(FILES
widgets/scrollbar.h widgets/scrollbar.h
widgets/signalplotter.h widgets/signalplotter.h
widgets/slider.h widgets/slider.h
widgets/svgwidget.h
widgets/tabbar.h widgets/tabbar.h
widgets/treeview.h widgets/treeview.h
widgets/textedit.h widgets/textedit.h
@ -255,6 +257,7 @@ includes/ServiceJob
includes/SignalPlotter includes/SignalPlotter
includes/Slider includes/Slider
includes/Svg includes/Svg
includes/SvgWidget
includes/TabBar includes/TabBar
includes/TextEdit includes/TextEdit
includes/ToolTipManager includes/ToolTipManager

1
includes/SvgWidget Normal file
View File

@ -0,0 +1 @@
#include "../../plasma/widgets/svgwidget.h"

89
widgets/svgwidget.cpp Normal file
View File

@ -0,0 +1,89 @@
/*
* Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "svgwidget.h"
#include <QtGui/QPainter>
#include <Plasma/Svg>
namespace Plasma
{
class SvgWidgetPrivate
{
public:
SvgWidgetPrivate(Svg *s, const QString &element)
: svg(s), elementID(element)
{
}
Svg *svg;
QString elementID;
};
SvgWidget::SvgWidget( QGraphicsItem * parent, Qt::WindowFlags wFlags)
: QGraphicsWidget(parent, wFlags),
d(new SvgWidgetPrivate(0, QString()))
{
}
SvgWidget::SvgWidget(Svg *svg, const QString &elementID, QGraphicsItem * parent, Qt::WindowFlags wFlags)
: QGraphicsWidget(parent, wFlags),
d(new SvgWidgetPrivate(svg, elementID))
{
}
SvgWidget::~SvgWidget()
{
delete d;
}
void SvgWidget::setSvg(Svg *svg)
{
d->svg = svg;
}
Svg *SvgWidget::svg() const
{
return d->svg;
}
void SvgWidget::setElementID(const QString &elementID)
{
d->elementID = elementID;
}
QString SvgWidget::elementID() const
{
return d->elementID;
}
void SvgWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
if (d->svg){
d->svg->paint(painter, boundingRect(), d->elementID);
}
}
} // Plasma namespace
#include "svgwidget.moc"

58
widgets/svgwidget.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_GRAPHICSSVGITEM_H
#define PLASMA_GRAPHICSSVGITEM_H
#include <QtCore/QObject>
#include <QtGui/QGraphicsWidget>
#include <plasma/plasma_export.h>
#include <plasma/plasma.h>
namespace Plasma
{
class Svg;
class SvgWidgetPrivate;
class PLASMA_EXPORT SvgWidget : public QGraphicsWidget
{
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();
void setSvg(Svg *svg);
Svg *svg() const;
void setElementID(const QString &elementID);
QString elementID() const;
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
SvgWidgetPrivate * const d;
};
} // Plasma namespace
#endif // multiple inclusion guard