• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Plasma

  • Plasma
  • Svg
Signals | Public Member Functions | Properties | Related Functions

Plasma::Svg Class Reference

A theme aware image-centric SVG class. More...

#include <Plasma/Svg>

Inheritance diagram for Plasma::Svg:
Inheritance graph
[legend]

List of all members.

Signals

void repaintNeeded ()
void sizeChanged ()

Public Member Functions

 ~Svg ()
bool containsMultipleImages () const
Q_INVOKABLE QString elementAtPoint (const QPoint &point) const
Q_INVOKABLE QRectF elementRect (const QString &elementId) const
Q_INVOKABLE QSize elementSize (const QString &elementId) const
Q_INVOKABLE bool hasElement (const QString &elementId) const
QString imagePath () const
bool isUsingRenderingCache () const
Q_INVOKABLE bool isValid () const
Q_INVOKABLE void paint (QPainter *painter, int x, int y, const QString &elementID=QString())
Q_INVOKABLE void paint (QPainter *painter, const QRectF &rect, const QString &elementID=QString())
Q_INVOKABLE void paint (QPainter *painter, int x, int y, int width, int height, const QString &elementID=QString())
Q_INVOKABLE void paint (QPainter *painter, const QPointF &point, const QString &elementID=QString())
Q_INVOKABLE QPixmap pixmap (const QString &elementID=QString())
Q_INVOKABLE void resize (qreal width, qreal height)
Q_INVOKABLE void resize (const QSizeF &size)
Q_INVOKABLE void resize ()
void setContainsMultipleImages (bool multiple)
void setImagePath (const QString &svgFilePath)
void setTheme (Plasma::Theme *theme)
void setUsingRenderingCache (bool useCache)
QSize size () const
Theme * theme () const

Properties

QString imagePath
bool multipleImages
QSize size
bool usingRenderingCache

Related Functions

(Note that these are not member functions.)
 Svg (QObject *parent=0)

Detailed Description

A theme aware image-centric SVG class.

Plasma::Svg provides a class for rendering SVG images to a QPainter in a convenient manner. Unless an absolute path to a file is provided, it loads the SVG document using Plasma::Theme. It also provides a number of internal optimizations to help lower the cost of painting SVGs, such as caching.

See also:
Plasma::FrameSvg

Definition at line 56 of file svg.h.


Constructor & Destructor Documentation

Plasma::Svg::~Svg ( )

Definition at line 638 of file svg.cpp.


Member Function Documentation

bool Plasma::Svg::containsMultipleImages ( ) const
Returns:
whether or not the svg contains multiple images or not

Definition at line 771 of file svg.cpp.

QString Plasma::Svg::elementAtPoint ( const QPoint &  point) const

Returns the element (by id) at the given point.

An empty string is returned if no element is at that point.

Definition at line 738 of file svg.cpp.

QRectF Plasma::Svg::elementRect ( const QString &  elementId) const

The bounding rect of a given element.

  • elementId the id of the element to check
    Returns:
    the current rect of a given element, given the current size of the Svg

Definition at line 724 of file svg.cpp.

QSize Plasma::Svg::elementSize ( const QString &  elementId) const

Size of a given element.

  • elementId the id of the element to check
    Returns:
    the current size of a given element, given the current size of the Svg

Definition at line 719 of file svg.cpp.

bool Plasma::Svg::hasElement ( const QString &  elementId) const

Check when an element exists in the loaded Svg.

  • elementId the id of the element to check
    Returns:
    true if the element is defined in the Svg, otherwise false

Definition at line 729 of file svg.cpp.

QString Plasma::Svg::imagePath ( ) const

Convenience method to get the svg filepath and name of svg.

Returns:
the svg's filepath including name of the svg.
bool Plasma::Svg::isUsingRenderingCache ( ) const
Returns:
true if the Svg is using caching for rendering results
Since:
4.3

Definition at line 799 of file svg.cpp.

bool Plasma::Svg::isValid ( ) const
Returns:
true if the SVG file exists and the document is valid, otherwise false. This method can be expensive as it causes disk access.

Definition at line 756 of file svg.cpp.

void Plasma::Svg::paint ( QPainter *  painter,
int  x,
int  y,
int  width,
int  height,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • x the horizontal coordinate to start painting from
  • y the vertical coordinate to start painting from
  • width the width of the element to draw
  • height the height of the element do draw
  • elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)

Definition at line 675 of file svg.cpp.

void Plasma::Svg::paint ( QPainter *  painter,
const QPointF &  point,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • point the position to start drawing; the entire svg will be drawn starting at this point.
  • elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)

Definition at line 652 of file svg.cpp.

void Plasma::Svg::paint ( QPainter *  painter,
const QRectF &  rect,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • rect the rect to draw into; if smaller than the current size the drawing is starting at this point.
  • elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)

Definition at line 669 of file svg.cpp.

void Plasma::Svg::paint ( QPainter *  painter,
int  x,
int  y,
const QString &  elementID = QString() 
)

Paints the SVG represented by this object.

  • painter the QPainter to use
  • x the horizontal coordinate to start painting from
  • y the vertical coordinate to start painting from
  • elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)

Definition at line 664 of file svg.cpp.

QPixmap Plasma::Svg::pixmap ( const QString &  elementID = QString())

Returns a pixmap of the SVG represented by this object.

  • elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
    Returns:
    a QPixmap of the rendered SVG

Definition at line 643 of file svg.cpp.

void Plasma::Svg::repaintNeeded ( ) [signal]
void Plasma::Svg::resize ( const QSizeF &  size)

Resizes the rendered image.

Rendering will actually take place on the next call to paint.

  • size the new size of the image

Definition at line 695 of file svg.cpp.

void Plasma::Svg::resize ( )

Resizes the rendered image to the natural size of the SVG.

Rendering will actually take place on the next call to paint.

Definition at line 707 of file svg.cpp.

void Plasma::Svg::resize ( qreal  width,
qreal  height 
)

Resizes the rendered image.

Rendering will actually take place on the next call to paint.

  • width the new width
  • height the new height

Definition at line 690 of file svg.cpp.

void Plasma::Svg::setContainsMultipleImages ( bool  multiple)

Set if the svg contains a single image or multiple ones.

  • multiple true if the svg contains multiple images

Definition at line 766 of file svg.cpp.

void Plasma::Svg::setImagePath ( const QString &  svgFilePath)

Convenience method for setting the svg file to use for the Svg.

  • svgFilePath the filepath including name of the svg.

Reimplemented in Plasma::FrameSvg.

Definition at line 776 of file svg.cpp.

void Plasma::Svg::setTheme ( Plasma::Theme *  theme)

Sets the Plasma::Theme to use with this Svg object.

By default, Svg objects use Plasma::Theme::default()

  • theme the theme object to use
    Since:
    4.3

Definition at line 804 of file svg.cpp.

void Plasma::Svg::setUsingRenderingCache ( bool  useCache)

Sets whether or not to cache the results of rendering to pixmaps.

If the Svg is resized and re-rendered often without pattern to the resulting pixmap dimensions, then it may be less efficient to do disk caching. A good example might be a progress meter that uses an Svg object to paint itself: the meter will be changing often enoughi, with enough unpredictability and without re-use of the previous pixmaps to not get a gain from caching.

Most Svg objects should use the caching feature, however. Therefore, the default is to use the render cache.

Parameters:
useCachetrue to cache rendered pixmaps
Since:
4.3

Definition at line 794 of file svg.cpp.

QSize Plasma::Svg::size ( ) const

Currently set size of the SVG.

Returns:
the current size of the SVG
void Plasma::Svg::sizeChanged ( ) [signal]
Theme * Plasma::Svg::theme ( ) const
Returns:
the theme used by this Svg

Definition at line 819 of file svg.cpp.


Friends And Related Function Documentation

Plasma::Svg::Svg ( QObject *  parent = 0) [related]

Constructs an SVG object that implicitly shares and caches rendering As opposed to QSvgRenderer, which this class uses internally, Plasma::Svg represents an image generated from an SVG.

As such, it has a related size and transform matrix (the latter being provided by the painter used to paint the image).

The size is initialized to be the SVG's native size.

  • parent options QObject to parent this to

Definition at line 632 of file svg.cpp.


Property Documentation

QString Plasma::Svg::imagePath [read, write]

Definition at line 62 of file svg.h.

bool Plasma::Svg::multipleImages [read, write]

Definition at line 61 of file svg.h.

QSize Plasma::Svg::size [read, write]

Definition at line 60 of file svg.h.

bool Plasma::Svg::usingRenderingCache [read, write]

Definition at line 63 of file svg.h.


The documentation for this class was generated from the following files:
  • svg.h
  • svg.cpp

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal