XII Release 0.1.0
Loading...
Searching...
No Matches
xiiQtImageCache Class Reference

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

#include <ImageCache.moc.h>

Inheritance diagram for xiiQtImageCache:
[legend]

Signals

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

Public Member Functions

void SetFallbackImages (xiiStringView sLoading, xiiStringView sUnavailable)
 Specifies which images to return when a requested image is currently not available (loading) or could not be found (unavailable).
 
const QPixmap * QueryPixmap (xiiStringView sAbsolutePath, QModelIndex index=QModelIndex(), QVariant userData1=QVariant(), QVariant userData2=QVariant(), xiiUInt32 *out_pImageID=nullptr)
 Queries an image by an absolute path. If the image is cached, it is returned right away.
 
const QPixmap * QueryPixmapForType (xiiStringView sType, xiiStringView sAbsolutePath, QModelIndex index=QModelIndex(), QVariant userData1=QVariant(), QVariant userData2=QVariant(), xiiUInt32 *out_pImageID=nullptr)
 Same as QueryPixmap(), but first sType is used to call QueryTypeImage() and check whether a type specific image was registerd. If yes, that is used instead of sAbsolutePath.
 
void InvalidateCache (xiiStringView sAbsolutePath)
 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 (xiiUInt64 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 (xiiStringView sType, QPixmap pixmap)
 Registers a pixmap to be used when an image for a certain type is requested. See QueryPixmapForType.
 
const QPixmap * QueryTypeImage (xiiStringView sType) 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 * xiiQtImageCache::QueryPixmap ( xiiStringView sAbsolutePath,
QModelIndex index = QModelIndex(),
QVariant userData1 = QVariant(),
QVariant userData2 = QVariant(),
xiiUInt32 * 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: