digiKam
Digikam::LoadingCache Class Reference
+ Inheritance diagram for Digikam::LoadingCache:

Classes

class  CacheLock
 

Signals

void fileChanged (const QString &filePath)
 

Public Member Functions

void addLoadingProcess (LoadingProcess *const process)
 
bool hasThumbnailPixmap (const QString &cacheKey) const
 
QStringList imageFilePathsInCache () const
 
bool isCacheable (const DImg &img) const
 
void notifyFileChanged (const QString &filePath, bool notify=true)
 
void notifyNewLoadingProcess (LoadingProcess *const process, const LoadingDescription &description)
 
bool putImage (const QString &cacheKey, const DImg &img, const QString &filePath) const
 
void putThumbnail (const QString &cacheKey, const QImage &thumb, const QString &filePath)
 
void putThumbnail (const QString &cacheKey, const QPixmap &thumb, const QString &filePath)
 
void removeImage (const QString &cacheKey)
 
void removeImages ()
 
void removeLoadingProcess (LoadingProcess *const process)
 
void removeThumbnail (const QString &cacheKey)
 
void removeThumbnails ()
 
DImgretrieveImage (const QString &cacheKey) const
 
LoadingProcessretrieveLoadingProcess (const QString &cacheKey) const
 
const QImage * retrieveThumbnail (const QString &cacheKey) const
 
const QPixmap * retrieveThumbnailPixmap (const QString &cacheKey) const
 
void setCacheSize (int megabytes)
 
void setFileWatch (LoadingCacheFileWatch *const watch)
 
void setThumbnailCacheSize (int numberOfQImages, int numberOfQPixmaps)
 
QStringList thumbnailFilePathsInCache () const
 

Static Public Member Functions

static LoadingCachecache ()
 
static void cleanUp ()
 

Friends

class CacheLock
 
class LoadingCacheFileWatch
 

Member Function Documentation

◆ addLoadingProcess()

void Digikam::LoadingCache::addLoadingProcess ( LoadingProcess *const  process)

Add a loading process to the list. Only one loading process for the same cache key is registered at a time.

References Digikam::LoadingProcess::cacheKey().

Referenced by Digikam::SharedLoadingTask::execute(), Digikam::PreviewLoadingTask::execute(), and Digikam::ThumbnailLoadingTask::execute().

◆ cache()

◆ cleanUp()

void Digikam::LoadingCache::cleanUp ( )
static

◆ fileChanged

void Digikam::LoadingCache::fileChanged ( const QString &  filePath)
signal

This signal is emitted when the cache is notified that a file was changed. There is no information in this signal if the file was ever contained in the cache. The signal may be emitted under CacheLock. Strongly consider a queued connection.

Referenced by notifyFileChanged().

◆ hasThumbnailPixmap()

bool Digikam::LoadingCache::hasThumbnailPixmap ( const QString &  cacheKey) const

◆ imageFilePathsInCache()

QStringList Digikam::LoadingCache::imageFilePathsInCache ( ) const

Returns a list of all possible file paths in cache.

Referenced by Digikam::LoadingCacheFileWatch::addedImage().

◆ isCacheable()

bool Digikam::LoadingCache::isCacheable ( const DImg img) const

Returns whether the given DImg fits in the cache.

References Digikam::DImg::numBytes().

Referenced by putImage(), and Digikam::LoadingCacheInterface::putImage().

◆ notifyFileChanged()

void Digikam::LoadingCache::notifyFileChanged ( const QString &  filePath,
bool  notify = true 
)

Remove all entries from cache that were loaded from filePath. Emits relevant signals if notify = true.

References fileChanged().

Referenced by Digikam::LoadingCacheFileWatch::checkFileWatch(), Digikam::LoadingCacheInterface::fileChanged(), and Digikam::LoadingCacheFileWatch::notifyFileChanged().

◆ notifyNewLoadingProcess()

void Digikam::LoadingCache::notifyNewLoadingProcess ( LoadingProcess *const  process,
const LoadingDescription description 
)

◆ putImage()

bool Digikam::LoadingCache::putImage ( const QString &  cacheKey,
const DImg img,
const QString &  filePath 
) const

Put image into for given string into the cache. Returns true if image has been put in the cache, false otherwise. Ownership of the DImg instance is passed to the cache. When it cannot be put in the cache it is deleted. The third parameter specifies a file path that will be watched. If this file changes, the object will be removed from the cache.

References isCacheable(), and Digikam::DImg::numBytes().

Referenced by Digikam::SharedLoadingTask::execute(), Digikam::PreviewLoadingTask::execute(), and Digikam::LoadingCacheInterface::putImage().

◆ putThumbnail() [1/2]

void Digikam::LoadingCache::putThumbnail ( const QString &  cacheKey,
const QImage &  thumb,
const QString &  filePath 
)

Puts a thumbnail into the thumbnail cache.

Referenced by Digikam::ThumbnailLoadingTask::execute().

◆ putThumbnail() [2/2]

void Digikam::LoadingCache::putThumbnail ( const QString &  cacheKey,
const QPixmap &  thumb,
const QString &  filePath 
)

◆ removeImage()

void Digikam::LoadingCache::removeImage ( const QString &  cacheKey)

Remove entries for the given cacheKey from the cache

◆ removeImages()

void Digikam::LoadingCache::removeImages ( )

Remove all entries from the cache

Referenced by Digikam::LoadingCacheInterface::cleanCache().

◆ removeLoadingProcess()

void Digikam::LoadingCache::removeLoadingProcess ( LoadingProcess *const  process)

◆ removeThumbnail()

void Digikam::LoadingCache::removeThumbnail ( const QString &  cacheKey)

Remove the thumbnail for the given file path from the thumbnail cache

Referenced by Digikam::ThumbnailLoadThread::deleteThumbnail().

◆ removeThumbnails()

void Digikam::LoadingCache::removeThumbnails ( )

Remove all thumbnails

Referenced by Digikam::LoadingCacheInterface::cleanThumbnailCache().

◆ retrieveImage()

DImg * Digikam::LoadingCache::retrieveImage ( const QString &  cacheKey) const

Retrieves an image for the given string from the cache, or 0 if no image is found.

Referenced by Digikam::SharedLoadingTask::execute(), and Digikam::PreviewLoadingTask::execute().

◆ retrieveLoadingProcess()

LoadingProcess * Digikam::LoadingCache::retrieveLoadingProcess ( const QString &  cacheKey) const

Find the loading process for given cacheKey, or 0 if not found

Referenced by Digikam::SharedLoadingTask::execute(), Digikam::PreviewLoadingTask::execute(), and Digikam::ThumbnailLoadingTask::execute().

◆ retrieveThumbnail()

const QImage * Digikam::LoadingCache::retrieveThumbnail ( const QString &  cacheKey) const

The LoadingCache support both the caching of QImage and QPixmap objects. QPixmaps can only be accessed from the main thread, so the tasks cannot access this cache. Retrieves a thumbnail for the given filePath from the thumbnail cache, or a 0 if the thumbnail is not found.

Referenced by Digikam::ThumbnailLoadingTask::execute().

◆ retrieveThumbnailPixmap()

const QPixmap * Digikam::LoadingCache::retrieveThumbnailPixmap ( const QString &  cacheKey) const

◆ setCacheSize()

void Digikam::LoadingCache::setCacheSize ( int  megabytes)

Sets the cache size in megabytes. The thumbnail cache is not affected and setThumbnailCacheSize takes the maximum number.

Referenced by Digikam::LoadingCacheInterface::setCacheOptions().

◆ setFileWatch()

void Digikam::LoadingCache::setFileWatch ( LoadingCacheFileWatch *const  watch)

Sets a LoadingCacheFileWatch to watch the files contained in this cache. Ownership of this object is transferred to the cache.

Referenced by Digikam::ScanController::databaseInitialization().

◆ setThumbnailCacheSize()

void Digikam::LoadingCache::setThumbnailCacheSize ( int  numberOfQImages,
int  numberOfQPixmaps 
)

Sets the size of the thumbnail cache

Parameters
numberOfQImagesThe maximum number of thumbnails of max possible size in QImage format that will be cached. If the size of the images is smaller, a larger number will be cached.
numberOfQPixmapsThe maximum number of thumbnails of max possible size in QPixmap format that will be cached. If the size of the images is smaller, a larger number will be cached. Note: The main cache is unaffected by this method, and setCacheSize takes megabytes as parameter. Note: A good caching strategy will be to set one of the numbers to 0 Default values: (0, 100)

References Digikam::ThumbnailSize::maxThumbsSize().

◆ thumbnailFilePathsInCache()

QStringList Digikam::LoadingCache::thumbnailFilePathsInCache ( ) const

Friends And Related Function Documentation

◆ CacheLock

friend class CacheLock
friend

◆ LoadingCacheFileWatch

friend class LoadingCacheFileWatch
friend

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