Added a new useful overload.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=872636
This commit is contained in:
Davide Bettio 2008-10-17 17:45:18 +00:00
parent 7f51dcbf62
commit 69155230cd
2 changed files with 19 additions and 0 deletions

View File

@ -376,6 +376,12 @@ void Svg::paint(QPainter *painter, const QRectF &rect, const QString &elementID)
painter->drawPixmap(rect, pix, QRectF(QPointF(0, 0), pix.size()));
}
void Svg::paint(QPainter *painter, int x, int y, int width, int height, const QString &elementID)
{
QPixmap pix(d->findInCache(elementID, QSizeF(width, height)));
painter->drawPixmap(x, y, pix, 0, 0, pix.size().width(), pix.size().height());
}
QSize Svg::size() const
{
return d->size.toSize();

13
svg.h
View File

@ -120,6 +120,19 @@ class PLASMA_EXPORT Svg : public QObject
Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect,
const QString &elementID = QString());
/**
* Paints the SVG represented by this object
* @arg painter the QPainter to use
* @arg x the horizontal coordinate to start painting from
* @arg y the vertical coordinate to start painting from
* @arg width the width of the element to draw
* @arg height the height of the element do draw
* @arg elelementId the ID string of the element to render, or an empty
* string for the whole SVG (the default)
*/
Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width,
int height, const QString &elementID = QString());
/**
* Currently set size of the SVG
* @return the current size of a given element