Add some convenience methods file(), to get the svg image path and setFile, to set the image path

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=750651
This commit is contained in:
Shawn Starr 2007-12-19 20:29:22 +00:00
parent 34bd2b87b2
commit 5e77ba9e70
2 changed files with 35 additions and 6 deletions

28
svg.cpp
View File

@ -79,12 +79,7 @@ class Svg::Private
~Private()
{
if (renderer.count() == 2) {
// this and the cache reference it; and boy is this not thread safe ;)
renderers.erase(renderers.find(themePath));
}
renderer = 0;
eraseRenderer();
}
void removeFromCache()
@ -163,6 +158,16 @@ class Svg::Private
size = renderer->defaultSize();
}
void eraseRenderer()
{
if (renderer.count() == 2) {
// this and the cache reference it; and boy is this not thread safe ;)
renderers.erase(renderers.find(themePath));
}
renderer = 0;
}
QSize elementSize(const QString& elementId)
{
createRenderer();
@ -311,6 +316,17 @@ Svg::ContentType Svg::contentType()
return d->contentType;
}
void Svg::setFile(const QString &svgFilePath)
{
d->themePath = svgFilePath;
d->eraseRenderer();
}
QString Svg::file() const
{
return d->themePath;
}
void Svg::themeChanged()
{
d->removeFromCache();

13
svg.h
View File

@ -50,6 +50,7 @@ class PLASMA_EXPORT Svg : public QObject
Q_ENUMS( ContentType )
Q_PROPERTY( QSize size READ size )
Q_PROPERTY( ContentType contentType READ contentType WRITE setContentType )
Q_PROPERTY( QString file READ file WRITE setFile )
public:
/**
@ -199,6 +200,18 @@ class PLASMA_EXPORT Svg : public QObject
*/
ContentType contentType();
/**
* Convenience method for setting the svg file to use for the Svg.
* @arg svgFilePath the filepath including name of the svg.
*/
void setFile(const QString &svgFilePath);
/**
* Convenience method to get the svg filepath and name of svg.
* @return the svg's filepath including name of the svg.
*/
QString file() const;
Q_SIGNALS:
void repaintNeeded();