make setFile actually work

CCMAIL:notmart@gmail.com

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=758400
This commit is contained in:
Aaron J. Seigo 2008-01-07 20:20:02 +00:00
parent 9db2d7e783
commit b03a2588d2

38
svg.cpp
View File

@ -64,17 +64,7 @@ class Svg::Private
: renderer(0), : renderer(0),
contentType(Svg::SingleImage) contentType(Svg::SingleImage)
{ {
if (QDir::isAbsolutePath(imagePath)) { setImagePath(imagePath);
path = imagePath;
themed = false;
if (!QFile::exists(path)) {
kDebug() << "Plasma::Svg: file '" << path << "' does not exist!";
}
} else {
themePath = imagePath;
themed = true;
}
} }
~Private() ~Private()
@ -82,6 +72,22 @@ class Svg::Private
eraseRenderer(); eraseRenderer();
} }
void setImagePath(const QString &imagePath)
{
themed = !QDir::isAbsolutePath(imagePath);
path = themePath = QString();
if (themed) {
themePath = imagePath;
} else {
path = imagePath;
if (!QFile::exists(path)) {
kDebug() << "Plasma::Svg: file '" << path << "' does not exist!";
}
}
}
void removeFromCache() void removeFromCache()
{ {
if ( id.isEmpty() ) { if ( id.isEmpty() ) {
@ -129,11 +135,13 @@ class Svg::Private
} else { } else {
renderer->render(&renderPainter, elementId); renderer->render(&renderPainter, elementId);
} }
renderPainter.end(); renderPainter.end();
bool inserted = QPixmapCache::insert( id, p );
if (!inserted) if (!QPixmapCache::insert( id, p )) {
kDebug() << "pixmap cache is too small for inserting" << id << "of size" << s; kDebug() << "pixmap cache is too small for inserting" << id << "of size" << s;
} }
}
void createRenderer() void createRenderer()
{ {
@ -141,7 +149,7 @@ class Svg::Private
return; return;
} }
if (themed && path.isNull()) { if (themed && path.isEmpty()) {
path = Plasma::Theme::self()->image(themePath); path = Plasma::Theme::self()->image(themePath);
} }
@ -318,7 +326,7 @@ Svg::ContentType Svg::contentType()
void Svg::setFile(const QString &svgFilePath) void Svg::setFile(const QString &svgFilePath)
{ {
d->themePath = svgFilePath; d->setImagePath(svgFilePath);
d->eraseRenderer(); d->eraseRenderer();
} }