class KThemeCache

A very simple pixmap cache for theme plugins. More...

Definition#include <kthemebase.h>
InheritsQObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Protected Slots

Protected Members


Detailed Description

A very simple pixmap cache for theme plugins. QPixmapCache is not used since it uses QString keys which are not needed. All the information we need can be encoded in a numeric key. Using QIntCache instead allows us to skip the string operations.

This class is mostly just inline methods that do bit operations on a key composed of the widget ID, width and/or height, and then calls QIntCache::find().

One other thing to note is that full, horizontal, and vertically scaled pixmaps are not used interchangeably. For example, if you insert a fully scaled pixmap that is 32x32 then request a horizontally scaled pixmap with a width of 32, they will not match. This is because a pixmap that has been inserted into the cache has already been scaled at some point and it is very likely the vertical height was not originally 32. Thus the pixmap will be wrong when drawn, even though the horizontal width matches.

enum ScaleHint {FullScale, HorizontalScale, VerticalScale}

ScaleHint

The scale hints supported by the cache. Note that Tiled is not here since tiled pixmaps are kept only once in KThemeBase.

 KThemeCache (int maxSize, QObject *parent=0, const char *name=0)

KThemeCache

The constructor.

Parameters:
maxSizeThe maximum size of the cache in kilobytes.

bool  insert (KThemePixmap *pixmap, ScaleHint scale, int widgetID, bool border=false, bool mask=false)

insert

Inserts a new pixmap into the cache.

Parameters:
pixmapThe pixmap to insert.
scaleThe scaling type of the pixmap.
widgetIDThe widget ID of the pixmap, usually from KThemeBase's WidgetType enum.

Returns: True if the insert was successful, false otherwise.

KThemePixmap*  pixmap (int w, int h, int widgetID, bool border=false, bool mask=false)

pixmap

Returns a fully scaled pixmap.

Parameters:
wThe pixmap width to search for.
hThe pixmap height to search for.
widgetIDThe widget ID to search for.

Returns: True if a pixmap matching the width, height, and widget ID of the pixmap exists, NULL otherwise.

KThemePixmap*  horizontalPixmap (int w, int widgetID)

horizontalPixmap

Returns a horizontally scaled pixmap.

Parameters:
wThe pixmap width to search for.
widgetIDThe widget ID to search for.

Returns: True if a pixmap matching the width and widget ID of the pixmap exists, NULL otherwise.

KThemePixmap*  verticalPixmap (int h, int widgetID)

verticalPixmap

Returns a vertically scaled pixmap.

Parameters:
hThe pixmap height to search for.
widgetIDThe widget ID to search for.

Returns: True if a pixmap matching the height and widget ID of the pixmap exists, NULL otherwise.

void  flushTimeout ()

flushTimeout

[protected slots slot]

QIntCache<KThemePixmap> cache

cache

[protected]

QTimer flushTimer

flushTimer

[protected]