• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

Plasma::Svg

Plasma::Svg Class Reference

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

#include <Plasma/Svg>

Inheritance diagram for Plasma::Svg:
QObject Plasma::FrameSvg

List of all members.

Signals

void repaintNeeded ()

Public Member Functions

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, int width, int height, 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, 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 ()
Q_INVOKABLE void resize (const QSizeF &size)
Q_INVOKABLE void resize (qreal width, qreal height)
void setContainsMultipleImages (bool multiple)
void setImagePath (const QString &svgFilePath)
void setTheme (Plasma::Theme *theme)
void setUsingRenderingCache (bool useCache)
QSize size () const
Theme * theme () const
 ~Svg ()

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 423 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 554 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 521 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 507 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 502 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 512 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 577 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 539 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 460 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 454 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 449 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 437 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 428 of file svg.cpp.

void Plasma::Svg::repaintNeeded (  )  [signal]
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 491 of file svg.cpp.

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 480 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 475 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 549 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 559 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 582 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:
useCache true to cache rendered pixmaps
Since:
4.3

Definition at line 572 of file svg.cpp.

QSize Plasma::Svg::size (  )  const

Currently set size of the SVG.

Returns:
the current size of the SVG
Theme * Plasma::Svg::theme (  )  const
Returns:
the theme used by this Svg

Definition at line 596 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 417 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]

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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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