* debug output when an absolute path is provided and the file doesn't exist

* provide an isValid() method

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=691142
This commit is contained in:
Aaron J. Seigo 2007-07-23 00:50:10 +00:00
parent 0491b8b112
commit 201afe2033
2 changed files with 17 additions and 0 deletions

10
svg.cpp
View File

@ -66,6 +66,10 @@ class Svg::Private
if (QDir::isAbsolutePath(imagePath)) {
path = imagePath;
themed = false;
if (!QFile::exists(path)) {
kDebug() << "Plasma::Svg: file '" << path << "' does not exist!" << endl;
}
} else {
themePath = imagePath;
themed = true;
@ -240,6 +244,12 @@ bool Svg::elementExists(const QString& elementId) const
return d->renderer->elementExists(elementId);
}
bool Svg::isValid() const
{
d->createRenderer();
return d->renderer->isValid();
}
QSize Svg::size() const
{
return d->size.toSize();

7
svg.h
View File

@ -149,6 +149,13 @@ class PLASMA_EXPORT Svg : public QObject
**/
Q_INVOKABLE bool elementExists( 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
* causes disk access.
**/
Q_INVOKABLE bool isValid() const;
/**
* Currently set size of the SVG
* @return the current size of a given element