Qt 4.8
Classes | Public Types | Public Functions | List of all members
QIconEngineV2 Class Reference

The QIconEngineV2 class provides an abstract base class for QIcon renderers. More...

#include <qiconengine.h>

Inheritance diagram for QIconEngineV2:
QIconEngine QIconLoaderEngine QPixmapIconEngine QSvgIconEngine

Classes

class  AvailableSizesArgument
 This struct represents arguments to virtual_hook() function when id parameter is QIconEngineV2::AvailableSizesHook. More...
 

Public Types

enum  IconEngineHook { AvailableSizesHook = 1, IconNameHook }
 These enum values are used for virtual_hook() to allow additional queries to icon engine without breaking binary compatibility. More...
 

Public Functions

QList< QSizeavailableSizes (QIcon::Mode mode=QIcon::Normal, QIcon::State state=QIcon::Off)
 Returns sizes of all images that are contained in the engine for the specific mode and state. More...
 
virtual QIconEngineV2clone () const
 Returns a clone of this icon engine. More...
 
QString iconName ()
 Returns the name used to create the engine, if available. More...
 
virtual QString key () const
 Returns a key that identifies this icon engine. More...
 
virtual bool read (QDataStream &in)
 Reads icon engine contents from the QDataStream in. More...
 
virtual void virtual_hook (int id, void *data)
 Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without breaking binary compatibility). More...
 
virtual bool write (QDataStream &out) const
 Writes the contents of this engine to the QDataStream out. More...
 
- Public Functions inherited from QIconEngine
virtual QSize actualSize (const QSize &size, QIcon::Mode mode, QIcon::State state)
 Returns the actual size of the icon the engine provides for the requested size, mode and state. More...
 
virtual void addFile (const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
 Called by QIcon::addFile(). More...
 
virtual void addPixmap (const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
 Called by QIcon::addPixmap(). More...
 
virtual void paint (QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)=0
 Uses the given painter to paint the icon with the required mode and state into the rectangle rect. More...
 
virtual QPixmap pixmap (const QSize &size, QIcon::Mode mode, QIcon::State state)
 Returns the icon as a pixmap with the required size, mode, and state. More...
 
virtual ~QIconEngine ()
 Destroys the icon engine. More...
 

Detailed Description

The QIconEngineV2 class provides an abstract base class for QIcon renderers.

Since
4.3

An icon engine renders QIcon. With icon engines, you can customize icons. Qt provides a default engine that makes icons adhere to the current style by scaling the icons and providing a disabled appearance.

An engine is installed on an icon either through a QIcon constructor or through a QIconEnginePluginV2. The plugins are used by Qt if a specific engine is not given when the icon is created. See the QIconEngineV2 class description to learn how to create icon engine plugins.

An icon engine provides the rendering functions for a QIcon. Each icon has a corresponding icon engine that is responsible for drawing the icon with a requested size, mode and state.

QIconEngineV2 extends the API of QIconEngine to allow streaming of the icon engine contents, and should be used instead of QIconEngine for implementing new icon engines.

See also
QIconEnginePluginV2

Definition at line 73 of file qiconengine.h.

Enumerations

◆ IconEngineHook

These enum values are used for virtual_hook() to allow additional queries to icon engine without breaking binary compatibility.

Since
4.5
  • AvailableSizesHook Allows to query the sizes of the contained pixmaps for pixmap-based engines. The data argument of the virtual_hook() function is a AvailableSizesArgument pointer that should be filled with icon sizes. Engines that work in terms of a scalable, vectorial format normally return an empty list.
  • IconNameHook Allows to query the name used to create the icon, for example when instantiating an icon using QIcon::fromTheme().
See also
virtual_hook()
Enumerator
AvailableSizesHook 
IconNameHook 

Definition at line 83 of file qiconengine.h.

Functions

◆ availableSizes()

QList< QSize > QIconEngineV2::availableSizes ( QIcon::Mode  mode = QIcon::Normal,
QIcon::State  state = QIcon::Off 
)

Returns sizes of all images that are contained in the engine for the specific mode and state.

Since
4.5
Note
This is a helper method and the actual work is done by virtual_hook() method, hence this method depends on icon engine support and may not work with all icon engines.

Definition at line 326 of file qiconengine.cpp.

327 {
328  AvailableSizesArgument arg;
329  arg.mode = mode;
330  arg.state = state;
331  virtual_hook(QIconEngineV2::AvailableSizesHook, reinterpret_cast<void*>(&arg));
332  return arg.sizes;
333 }
virtual void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...

◆ clone()

QIconEngineV2 * QIconEngineV2::clone ( ) const
virtual

Returns a clone of this icon engine.

Reimplemented in QPixmapIconEngine, QIconLoaderEngine, and QSvgIconEngine.

Definition at line 259 of file qiconengine.cpp.

Referenced by QIcon::detach().

260 {
261  return 0;
262 }

◆ iconName()

QString QIconEngineV2::iconName ( )

Returns the name used to create the engine, if available.

Since
4.7
Note
This is a helper method and the actual work is done by virtual_hook() method, hence this method depends on icon engine support and may not work with all icon engines.

Definition at line 347 of file qiconengine.cpp.

Referenced by QIcon::name().

348 {
349  QString name;
350  virtual_hook(QIconEngineV2::IconNameHook, reinterpret_cast<void*>(&name));
351  return name;
352 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
const char * name
virtual void virtual_hook(int id, void *data)
Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without br...

◆ key()

QString QIconEngineV2::key ( ) const
virtual

Returns a key that identifies this icon engine.

Reimplemented in QIconLoaderEngine, QPixmapIconEngine, and QSvgIconEngine.

Definition at line 251 of file qiconengine.cpp.

Referenced by operator<<().

252 {
253  return QString();
254 }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ read()

bool QIconEngineV2::read ( QDataStream in)
virtual

Reads icon engine contents from the QDataStream in.

Returns true if the contents were read; otherwise returns false.

QIconEngineV2's default implementation always return false.

Reimplemented in QPixmapIconEngine, QIconLoaderEngine, and QSvgIconEngine.

Definition at line 270 of file qiconengine.cpp.

Referenced by operator>>().

271 {
272  return false;
273 }

◆ virtual_hook()

void QIconEngineV2::virtual_hook ( int  id,
void *  data 
)
virtual

Additional method to allow extending QIconEngineV2 without adding new virtual methods (and without breaking binary compatibility).

Since
4.5

The actual action and format of data depends on id argument which is in fact a constant from IconEngineHook enum.

See also
IconEngineHook

Reimplemented in QIconLoaderEngine, and QPixmapIconEngine.

Definition at line 299 of file qiconengine.cpp.

Referenced by QPixmapIconEngine::virtual_hook(), and QIconLoaderEngine::virtual_hook().

300 {
301  switch (id) {
304  *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
305  arg.sizes.clear();
306  break;
307  }
308  default:
309  break;
310  }
311 }
This struct represents arguments to virtual_hook() function when id parameter is QIconEngineV2::Avail...
Definition: qiconengine.h:85
QList< QSize > sizes
image sizes that are available with specified mode and
Definition: qiconengine.h:89
static const char * data(const QByteArray &arr)
void clear()
Removes all items from the list.
Definition: qlist.h:764

◆ write()

bool QIconEngineV2::write ( QDataStream out) const
virtual

Writes the contents of this engine to the QDataStream out.

Returns true if the contents were written; otherwise returns false.

QIconEngineV2's default implementation always return false.

Reimplemented in QPixmapIconEngine, QIconLoaderEngine, and QSvgIconEngine.

Definition at line 281 of file qiconengine.cpp.

Referenced by operator<<().

282 {
283  return false;
284 }

The documentation for this class was generated from the following files: