Plasma Engine  2.0
Loading...
Searching...
No Matches
plQtImageCache Class Reference

A singleton class that caches Qt images that are typically used for thumbnails. More...

#include <ImageCache.moc.h>

Inheritance diagram for plQtImageCache:

Signals

void ImageLoaded (QString sPath, QModelIndex index, QVariant userData1, QVariant userData2)
 
void ImageInvalidated (QString sPath, unsigned int uiImageID)
 

Public Member Functions

void SetFallbackImages (const char *szLoading, const char *szUnavailable)
 Specifies which images to return when a requested image is currently not available (loading) or could not be found (unavailable).
 
const QPixmap * QueryPixmap (const char *szAbsolutePath, QModelIndex index=QModelIndex(), QVariant userData1=QVariant(), QVariant userData2=QVariant(), plUInt32 *out_pImageID=nullptr)
 Queries an image by an absolute path. If the image is cached, it is returned right away.
 
const QPixmap * QueryPixmapForType (const char *szType, const char *szAbsolutePath, QModelIndex index=QModelIndex(), QVariant userData1=QVariant(), QVariant userData2=QVariant(), plUInt32 *out_pImageID=nullptr)
 Same as QueryPixmap(), but first szType is used to call QueryTypeImage() and check whether a type specific image was registerd. If yes, that is used instead of szAbsolutePath.
 
void InvalidateCache (const char *szAbsolutePath)
 Invalidate the cached image with the given path. This is typically done when a thumbnail was just written to disk, to inform this system to reload the latest image from disk.
 
void SetMemoryUsageThreshold (plUInt64 uiMemoryThreshold)
 When this threshold is reached, images that haven't been requested in a while are being evicted from the cache.
 
void StopRequestProcessing (bool bPurgeExistingCache)
 Called whenever the application should stop or pause further image loading, e.g. before shutdown or during project loading.
 
void EnableRequestProcessing ()
 Re-enables image loading if it was previously stopped.
 
void RegisterTypeImage (const char *szType, QPixmap pixmap)
 Registers a pixmap to be used when an image for a certain type is requested. See QueryPixmapForType.
 
const QPixmap * QueryTypeImage (const char *szType) const
 Returns a pixmap or nullptr that was registered with RegisterTypeImage()
 

Detailed Description

A singleton class that caches Qt images that are typically used for thumbnails.

When an image is not available right away, a fallback is returned and the requested image goes into a loading queue. When an image was finished loading, a signal is emitted to inform users to update their UI.

Member Function Documentation

◆ QueryPixmap()

const QPixmap * plQtImageCache::QueryPixmap ( const char * szAbsolutePath,
QModelIndex index = QModelIndex(),
QVariant userData1 = QVariant(),
QVariant userData2 = QVariant(),
plUInt32 * out_pImageID = nullptr )

Queries an image by an absolute path. If the image is cached, it is returned right away.

If the image is not cached, a temporary image is returned and it is queued for loading. Once it is finished loading, the ImageLoaded() signal is emitted and index, UserData1 and UserData2 are passed through. Additionally an ImageID may be returned through out_pImageID. This can be used to identify an image when it is invalidated through the ImageInvalidated() signal.


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