begin of api changes, as in
http://techbase.kde.org/index.php?title=Projects/Plasma/Tokamak1#Plasma::Svg elementRect() returns a QRectF elementExisits() became hasElement() matrixForElement is only private svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=797610
This commit is contained in:
parent
ef4d4863ca
commit
4a5df9c733
24
svg.cpp
24
svg.cpp
@ -272,7 +272,7 @@ class Svg::Private
|
||||
return elementSize.toSize();
|
||||
}
|
||||
|
||||
QRect elementRect(const QString& elementId)
|
||||
QRectF elementRect(const QString& elementId)
|
||||
{
|
||||
createRenderer();
|
||||
QRectF elementRect = renderer->boundsOnElement(elementId);
|
||||
@ -280,7 +280,7 @@ class Svg::Private
|
||||
qreal dx = size.width() / naturalSize.width();
|
||||
qreal dy = size.height() / naturalSize.height();
|
||||
|
||||
return QRect(elementRect.x() * dx, elementRect.y() * dy,
|
||||
return QRectF(elementRect.x() * dx, elementRect.y() * dy,
|
||||
elementRect.width() * dx, elementRect.height() * dy);
|
||||
}
|
||||
|
||||
@ -356,6 +356,11 @@ void Svg::paint(QPainter* painter, const QRectF& rect, const QString& elementID)
|
||||
#endif
|
||||
}
|
||||
|
||||
QSize Svg::size() const
|
||||
{
|
||||
return d->size.toSize();
|
||||
}
|
||||
|
||||
void Svg::resize( int width, int height )
|
||||
{
|
||||
resize( QSize( width, height ) );
|
||||
@ -378,12 +383,12 @@ QSize Svg::elementSize(const QString& elementId) const
|
||||
return d->elementSize(elementId);
|
||||
}
|
||||
|
||||
QRect Svg::elementRect(const QString& elementId) const
|
||||
QRectF Svg::elementRect(const QString& elementId) const
|
||||
{
|
||||
return d->elementRect(elementId);
|
||||
}
|
||||
|
||||
bool Svg::elementExists(const QString& elementId) const
|
||||
bool Svg::hasElement(const QString& elementId) const
|
||||
{
|
||||
d->createRenderer();
|
||||
return d->renderer->elementExists(elementId);
|
||||
@ -400,23 +405,12 @@ QString Svg::elementAtPoint(const QPoint &point) const
|
||||
return QString(); // d->renderer->elementAtPoint(QPoint(point.x() *dx, naturalSize.height() - point.y() * dy));
|
||||
}
|
||||
|
||||
QMatrix Svg::matrixForElement(const QString& elementId) const
|
||||
{
|
||||
d->createRenderer();
|
||||
return d->renderer->matrixForElement(elementId);
|
||||
}
|
||||
|
||||
bool Svg::isValid() const
|
||||
{
|
||||
d->createRenderer();
|
||||
return d->renderer->isValid();
|
||||
}
|
||||
|
||||
QSize Svg::size() const
|
||||
{
|
||||
return d->size.toSize();
|
||||
}
|
||||
|
||||
void Svg::setContentType(ContentType contentType)
|
||||
{
|
||||
d->contentType = contentType;
|
||||
|
24
svg.h
24
svg.h
@ -117,6 +117,12 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
Q_INVOKABLE void paint(QPainter* painter, const QRectF& rect,
|
||||
const QString& elementID = QString());
|
||||
|
||||
/**
|
||||
* Currently set size of the SVG
|
||||
* @return the current size of a given element
|
||||
**/
|
||||
QSize size() const;
|
||||
|
||||
/**
|
||||
* Resizes the rendered image. Rendering will actually take place on
|
||||
* the next call to paint.
|
||||
@ -150,14 +156,14 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
* @arg elementId the id of the element to check
|
||||
* @return the current rect of a given element, given the current size of the Svg
|
||||
**/
|
||||
Q_INVOKABLE QRect elementRect(const QString& elementId) const;
|
||||
Q_INVOKABLE QRectF elementRect(const QString& elementId) const;
|
||||
|
||||
/**
|
||||
* Check when an element exists in the loaded Svg
|
||||
* @arg elementId the id of the element to check
|
||||
* @return true if the element is defined in the Svg, otherwise false
|
||||
**/
|
||||
Q_INVOKABLE bool elementExists( const QString& elementId ) const;
|
||||
Q_INVOKABLE bool hasElement( const QString& elementId ) const;
|
||||
|
||||
/**
|
||||
* Returns the element (by id) at the given point. An empty string is
|
||||
@ -165,14 +171,6 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
*/
|
||||
Q_INVOKABLE QString elementAtPoint(const QPoint &point) 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
|
||||
@ -180,12 +178,6 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
**/
|
||||
Q_INVOKABLE bool isValid() const;
|
||||
|
||||
/**
|
||||
* Currently set size of the SVG
|
||||
* @return the current size of a given element
|
||||
**/
|
||||
QSize size() const;
|
||||
|
||||
/**
|
||||
* Sets what sort of content is in the Svg.
|
||||
* @see ContentType
|
||||
|
@ -152,7 +152,7 @@ Plasma::Location SvgPanel::location() const
|
||||
|
||||
void SvgPanel::setPrefix(const QString & prefix)
|
||||
{
|
||||
if (!d->background->elementExists(prefix + "-center")) {
|
||||
if (!d->background->hasElement(prefix + "-center")) {
|
||||
d->prefix.clear();
|
||||
} else {
|
||||
d->prefix = prefix;
|
||||
@ -451,9 +451,9 @@ void SvgPanel::updateSizes()
|
||||
}
|
||||
|
||||
//since it's rectangular, topWidth and bottomWidth must be the same
|
||||
d->tileCenter = d->background->elementExists("hint-tile-center");
|
||||
d->noBorderPadding = d->background->elementExists("hint-no-border-padding");
|
||||
d->stretchBorders = d->background->elementExists("hint-stretch-borders");
|
||||
d->tileCenter = d->background->hasElement("hint-tile-center");
|
||||
d->noBorderPadding = d->background->hasElement("hint-no-border-padding");
|
||||
d->stretchBorders = d->background->hasElement("hint-stretch-borders");
|
||||
emit repaintNeeded();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user