From ce090faab8c9ebf785cbe62a921782d87526a86a Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Thu, 2 Aug 2007 16:14:35 +0000 Subject: [PATCH] add matrixForElement(const QString& elementId) const as discussed on panel-devel svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=695665 --- svg.cpp | 14 +++++++++++++- svg.h | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/svg.cpp b/svg.cpp index dc4b18002..d4eb587d1 100644 --- a/svg.cpp +++ b/svg.cpp @@ -177,10 +177,16 @@ class Svg::Private QSizeF naturalSize = renderer->defaultSize(); qreal dx = size.width() / naturalSize.width(); qreal dy = size.height() / naturalSize.height(); - + return QRect(elementRect.x() * dx, elementRect.y() * dy, elementRect.width() * dx, elementRect.height() * dy); } + + QMatrix matrixForElement(const QString& elementId) + { + createRenderer(); + return renderer->matrixForElement(elementId); + } static QHash renderers; SharedSvgRenderer::Ptr renderer; @@ -261,6 +267,12 @@ bool Svg::elementExists(const QString& elementId) const return d->renderer->elementExists(elementId); } +QMatrix Svg::matrixForElement(const QString& elementId) const +{ + d->createRenderer(); + return d->renderer->matrixForElement(elementId); +} + bool Svg::isValid() const { d->createRenderer(); diff --git a/svg.h b/svg.h index 3e82fd0b7..46bf05c67 100644 --- a/svg.h +++ b/svg.h @@ -30,6 +30,7 @@ class QRect; class QRectF; class QSize; class QSizeF; +class QMatrix; namespace Plasma { @@ -156,6 +157,14 @@ class PLASMA_EXPORT Svg : public QObject **/ Q_INVOKABLE bool elementExists( const QString& elementId ) const; + /** + * The transformation matrix of the element. That includes the + * transformation on the element itself. + * @arg elementId the id of the element + * @return the matrix for the element + **/ + Q_INVOKABLE QMatrix matrixForElement(const QString& elementId) const; + /** * @return true if the SVG file exists and the document is valid, * otherwise false. This method can be expensive as it