digiKam Developer Documentation: Digikam::ThumbnailLoadThread Class Reference

| digiKam Developer Documentation Professional Photo Management with the Power of Open Source

Loading...
Searching...
No Matches
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Digikam::ThumbnailLoadThread Class Reference
Inheritance diagram for Digikam::ThumbnailLoadThread:

## Signals
void | signalThumbnailLoaded (const LoadingDescription &loadingDescription, const QPixmap &pix)
void | ThumbnailLoaded (const LoadingDescription &, const QImage &)
void | thumbnailsAvailable ()
Signals inherited from Digikam::LoadSaveThread
void | signalImageLoaded (const LoadingDescription &loadingDescription, const DImg &img)
| This signal is emitted when the loading process has finished.
void | signalImageSaved (const QString &filePath, bool success)
void | signalImageStartedLoading (const LoadingDescription &loadingDescription)
| All signals are delivered to the thread from where the LoadSaveThread object has been created.
void | signalImageStartedSaving (const QString &filePath)
void | signalLoadingProgress (const LoadingDescription &loadingDescription, float progress)
| This signal is emitted whenever new progress info is available and the notification policy allows emitting the signal.
void | signalMoreCompleteLoadingAvailable (const LoadingDescription &oldLoadingDescription, const LoadingDescription &newLoadingDescription)
| This signal is emitted if.
void | signalQImageThumbnailLoaded (const LoadingDescription &loadingDescription, const QImage &img)
void | signalSavingProgress (const QString &filePath, float progress)
Signals inherited from Digikam::DynamicThread
void | finished ()
void | starting ()
| Emitted if emitSignals is enabled.

## Public Member Functions
| ThumbnailLoadThread (QObject *const parent=nullptr)
void | find (const ThumbnailIdentifier &identifier)
| Find a thumbnail.
void | find (const ThumbnailIdentifier &identifier, const QRect &rect)
void | find (const ThumbnailIdentifier &identifier, const QRect &rect, int size)
bool | find (const ThumbnailIdentifier &identifier, const QRect &rect, QPixmap &pixmap)
| All tastes of find() methods, for loading the thumbnail of a detail.
bool | find (const ThumbnailIdentifier &identifier, const QRect &rect, QPixmap &pixmap, int size, bool onlyStorage=false)
void | find (const ThumbnailIdentifier &identifier, int size)
| Same as above, but does not use the global size, but an extra specified size.
bool | find (const ThumbnailIdentifier &identifier, QPixmap &pixmap)
| Find a thumbnail.
bool | find (const ThumbnailIdentifier &identifier, QPixmap &pixmap, int size, bool onlyStorage=false)
| Same as above, but does not use the global size, but an extra specified size.
bool | findBuffered (const ThumbnailIdentifier &identifier, const QRect &rect, QPixmap &pixmap, int size)
| Find the thumbnail pixmap in the buffered cache to avoid flickering while loading a new thumbnail.
void | findGroup (const QList< QPair< ThumbnailIdentifier, QRect > > &filePathAndRects)
void | findGroup (const QList< QPair< ThumbnailIdentifier, QRect > > &filePathsAndRects, int size)
void | findGroup (QList< ThumbnailIdentifier > &identifiers)
| Find a group of thumbnails.
void | findGroup (QList< ThumbnailIdentifier > &identifiers, int size)
QList< LoadingDescription > | lastDescriptions () const
| Returns the descriptions used by the last call to any of the above methods.
void | load (const LoadingDescription &description) override
| Load a thumbnail.
int | pixmapToThumbnailSize (int size) const
| Computes the thumbnail size for the give pixmap size.
void | pregenerateGroup (const QList< ThumbnailIdentifier > &identifiers)
| Pregenerate the thumbnail group.
void | pregenerateGroup (const QList< ThumbnailIdentifier > &identifiers, int size)
void | preload (const ThumbnailIdentifier &identifier)
| Preload the thumbnail or thumbnail group.
void | preload (const ThumbnailIdentifier &identifier, int size)
void | preloadGroup (QList< ThumbnailIdentifier > &identifiers)
void | preloadGroup (QList< ThumbnailIdentifier > &identifiers, int size)
void | setHighlightPixmap (bool highlight)
| If you enable this, a highlighting border will be drawn around the pixmap.
void | setPixmapRequested (bool wantPixmap)
| If you enable this, the signal thumbnailLoaded(LoadingDescription, QPixmap) will be emitted.
void | setSendSurrogatePixmap (bool send)
| If you enable this, the thread will try hard to send a pixmap if thumbnail loading failed.
void | setThumbnailSize (int size, bool forFace=false)
| Set the requested thumbnail size.
void | storeDetailThumbnail (const QString &filePath, const QRect &detailRect, const QImage &image, bool isFace=false)
| Stores the given detail thumbnail on disk.
int | storedSize () const
ThumbnailCreator * | thumbnailCreator () const
int | thumbnailToPixmapSize (int size) const
| Computes the pixmap size for the give thumbnail size.
Public Member Functions inherited from Digikam::ManagedLoadSaveThread
| ManagedLoadSaveThread (QObject *const parent=nullptr)
void | load (const LoadingDescription &description, LoadingPolicy policy)
LoadingPolicy | loadingPolicy () const
virtual void | save (const DImg &image, const QString &filePath, const QString &format) override
| Append a task to save the image to the task list.
void | setLoadingPolicy (LoadingPolicy policy)
| Set the loading policy.
void | setTerminationPolicy (TerminationPolicy terminationPolicy)
void | stopAllTasks ()
void | stopLoading (const LoadingDescription &desc, LoadingTaskFilter filter=LoadingTaskFilterAll)
| Same than previous method, but Stop and remove tasks filtered by LoadingDescription.
void | stopLoading (const QString &filePath=QString(), LoadingTaskFilter filter=LoadingTaskFilterAll)
| Stop and remove tasks filtered by filePath and policy.
void | stopSaving (const QString &filePath=QString())
| Stop and remove saving tasks filtered by filePath.
TerminationPolicy | terminationPolicy () const
Public Member Functions inherited from Digikam::LoadSaveThread
| LoadSaveThread (QObject *const parent=nullptr)
| ~LoadSaveThread () override
| Destructor: The thread will execute all pending tasks and wait for this upon destruction.
void | imageLoaded (const LoadingDescription &loadingDescription, const DImg &img) override
void | imageSaved (const QString &filePath, bool success) override
void | imageStartedLoading (const LoadingDescription &loadingDescription) override
void | imageStartedSaving (const QString &filePath) override
void | loadingProgress (const LoadingDescription &loadingDescription, float progress) override
void | moreCompleteLoadingAvailable (const LoadingDescription &oldLoadingDescription, const LoadingDescription &newLoadingDescription) override
virtual bool | querySendNotifyEvent () const
void | savingProgress (const QString &filePath, float progress) override
void | setNotificationPolicy (NotificationPolicy notificationPolicy)
virtual void | taskHasFinished ()
Public Member Functions inherited from Digikam::DynamicThread
| DynamicThread (QObject *const parent=nullptr)
| This class extends QRunnable, so you have to reimplement virtual void run().
| ~DynamicThread () override
| The destructor calls stop() and wait(), but if you, in your destructor, delete any data that is accessed by your run() method, you must call stop() and wait() before yourself.
bool | isFinished () const
bool | isRunning () const
QThread::Priority | priority () const
void | setEmitSignals (bool emitThem)
void | setPriority (QThread::Priority priority)
| Sets the priority for this dynamic thread.
State | state () const

## Static Public Member Functions
static void | cleanUp ()
static ThumbnailLoadThread * | defaultIconViewThread ()
static ThumbnailLoadThread * | defaultThread ()
| Return application-wide default thumbnail threads.
static void | deleteThumbnail (const QString &filePath)
| This is a tool to force regeneration of thumbnails.
static void | initializeNoThumbnailStorage ()
| Disable storing thumbnails in the disk cache.
static void | initializeThumbnailDatabase (const DbEngineParameters &params, ThumbnailInfoProvider *const provider=nullptr)
| Enable loading of thumbnails from a thumbnail database.
static int | maximumThumbnailPixmapSize (bool withHighlighting)
static int | maximumThumbnailSize ()
| Returns the maximum possible size of a thumbnail.
static void | setDisplayingWidget (QWidget *const widget)
| For color management, this sets the widget the thumbnails will be color managed for.
static int | thumbnailToPixmapSize (bool withHighlight, int size)
Static Public Member Functions inherited from Digikam::LoadSaveThread
static int | exifOrientation (const QString &filePath, const DMetadata &metadata, bool isRaw, bool fromRawEmbeddedPreview)
| Retrieves the Exif orientation, either from the info provider if available, or from the metadata.
static LoadSaveFileInfoProvider * | infoProvider ()
static void | setInfoProvider (LoadSaveFileInfoProvider *const infoProvider)

## Protected Member Functions
void | thumbnailLoaded (const LoadingDescription &loadingDescription, const QImage &img) override
| virtual method overridden from LoadSaveNotifier, implemented first by LoadSaveThread called by ThumbnailTask from working thread
Protected Member Functions inherited from Digikam::ManagedLoadSaveThread
void | load (const LoadingDescription &description, LoadingMode loadingMode, AccessMode mode=AccessModeReadWrite)
void | load (const LoadingDescription &description, LoadingMode loadingMode, LoadingPolicy policy, AccessMode mode=AccessModeReadWrite)
void | loadPreview (const LoadingDescription &description, LoadingPolicy policy)
void | loadThumbnail (const LoadingDescription &description)
void | preloadThumbnail (const LoadingDescription &description)
void | preloadThumbnailGroup (const QList< LoadingDescription > &descriptions)
void | prependThumbnailGroup (const QList< LoadingDescription > &descriptions)
void | shutDown () override
| If you are deleting data in your destructor which is accessed from the thread, do one of the following from your destructor to guarantee a safe shutdown: 1) Call this method 2) Call stop() and wait(), knowing that nothing will call start() anymore after this 3) Be sure the thread will never be running at destruction.
Protected Member Functions inherited from Digikam::LoadSaveThread
void | notificationReceived ()
void | run () override
| Implement this pure virtual function in your subclass.
Protected Member Functions inherited from Digikam::DynamicThread
bool | runningFlag () const volatile
| In you run() method, you shall regularly check for runningFlag() and cleanup and return if false.
void | start (QMutexLocker< QMutex > &locker)
| Doing the same as start(), stop() and wait above, provide it with a locked QMutexLocker on mutex().
void | stop (const QMutexLocker< QMutex > &locker)
QMutex * | threadMutex () const
| This is the non-recursive mutex used to protect state variables and waiting in this class.
void | wait (QMutexLocker< QMutex > &locker)

## Additional Inherited Members
Public Types inherited from Digikam::ManagedLoadSaveThread
enum | LoadingMode { LoadingModeNormal , LoadingModeShared }
| used by SharedLoadSaveThread only More...
enum | LoadingPolicy { LoadingPolicyFirstRemovePrevious , LoadingPolicyPrepend , LoadingPolicySimplePrepend , LoadingPolicyAppend , LoadingPolicySimpleAppend , LoadingPolicyPreload }
enum | LoadingTaskFilter { LoadingTaskFilterAll , LoadingTaskFilterPreloading }
enum | TerminationPolicy { TerminationPolicyTerminateLoading , TerminationPolicyTerminatePreloading , TerminationPolicyWait , TerminationPolicyTerminateAll }
Public Types inherited from Digikam::LoadSaveThread
enum | AccessMode { AccessModeRead , AccessModeReadWrite }
| used by SharedLoadSaveThread only More...
enum | NotificationPolicy { NotificationPolicyDirect , NotificationPolicyTimeLimited }
Public Types inherited from Digikam::DynamicThread
enum | State { Inactive , Scheduled , Running , Deactivating }
Public Slots inherited from Digikam::DynamicThread
void | start ()
void | stop ()
| Stop computation, sets the running flag to false.
void | wait ()
| Waits until the thread finishes.
Protected Attributes inherited from Digikam::ManagedLoadSaveThread
LoadingPolicy | m_loadingPolicy = LoadingPolicyAppend
TerminationPolicy | m_terminationPolicy = TerminationPolicyTerminateLoading
Protected Attributes inherited from Digikam::LoadSaveThread
LoadSaveTask * | m_currentTask = nullptr
QMutex | m_mutex
NotificationPolicy | m_notificationPolicy = NotificationPolicyTimeLimited
QList< LoadSaveTask * > | m_todo

## Member Function Documentation

## ◆ defaultThread()

ThumbnailLoadThread * Digikam::ThumbnailLoadThread::defaultThread | ( |  | ) |
| static

It is perfectly all right to create an extra object of the class, but it is useful to have default object

## ◆ deleteThumbnail()

void Digikam::ThumbnailLoadThread::deleteThumbnail | ( | const QString & | filePath | ) |
| static

All thumbnail files for the given file will be removed from disk, and the cached instances will be removed as well. Use this method if you know that the contents of the file has changed. This method works independently from the multithreaded thumbnail loading.

## ◆ find() [1/2]

void Digikam::ThumbnailLoadThread::find | ( | const ThumbnailIdentifier & | identifier | ) |

This method sends the signals and does not return values like the method above. If you certainly need asynchronous return, connect with Qt::QueuedConnection to the signals. If you connect directly, the signals may be sent from within the method call.

## ◆ find() [2/2]

bool Digikam::ThumbnailLoadThread::find | ( | const ThumbnailIdentifier & | identifier,
|  | QPixmap & | pixmap
| ) |  |

If the pixmap is found in the cache, returns true and sets pixmap to the found QPixmap. If the pixmap is not found in the cache, load() is called to start the loading process, false is returned and pixmap is not touched.

## ◆ findGroup()

void Digikam::ThumbnailLoadThread::findGroup | ( | QList< ThumbnailIdentifier > & | identifiers | ) |

The items will be loaded in order and signals will be sent. Can be used to ensure that thumbnails are loaded in a particular order.

Note
  : the signal signalThumbnailLoaded() is only fired once, after it has been loaded, this behavior is intentional. On all subsequent attempts, during the conversion from ThumbnailIdentifier to LoadingDescription, it checks whether the thumbnail is already in the cache. The load request is then discarded.

## ◆ initializeNoThumbnailStorage()

void Digikam::ThumbnailLoadThread::initializeNoThumbnailStorage | ( |  | ) |
| static

This shall be called once at application startup. This need not be called, then the FreeDesktop standard is used.

## ◆ initializeThumbnailDatabase()

void Digikam::ThumbnailLoadThread::initializeThumbnailDatabase | ( | const DbEngineParameters & | params,
|  | ThumbnailInfoProvider *const | provider = `nullptr`
| ) |  |
| static

This shall be called once at application startup. This need not be called, then the FreeDesktop standard is used. You can optionally provide a thumbnail info provider.

## ◆ lastDescriptions()

QList< LoadingDescription > Digikam::ThumbnailLoadThread::lastDescriptions | ( |  | ) | const

After calling single-thumbnail methods (find, preload) the list will have size 1, after the group methods (findGroup, preloadGroup, pregenerateGroup) the list can be larger than 1. There is no information if the description was ever scheduled in the thread, already processed, skipped or canceled.

## ◆ load()

void Digikam::ThumbnailLoadThread::load | ( | const LoadingDescription & | description | ) |
| overridevirtual

You do not need to use this method directly, it will not access the pixmap cache. Use find(). The LoadingDescription shall be constructed with the constructor for preview/thumbnail jobs. (in the description constructor, you need to specify file path, thumbnail size and Exif rotation)

Reimplemented from Digikam::ManagedLoadSaveThread.

## ◆ maximumThumbnailSize()

int Digikam::ThumbnailLoadThread::maximumThumbnailSize | ( |  | ) |
| static

If you request a larger size, the thumbnail will not load. The size of the pixmap can slightly differ, especially when highlighting.

## ◆ pregenerateGroup()

void Digikam::ThumbnailLoadThread::pregenerateGroup | ( | const QList< ThumbnailIdentifier > & | identifiers | ) |

No signals will be emitted when these are loaded.

## ◆ preload()

void Digikam::ThumbnailLoadThread::preload | ( | const ThumbnailIdentifier & | identifier | ) |

This is essentially the same as loading, but with a lower priority.

## ◆ setDisplayingWidget()

void Digikam::ThumbnailLoadThread::setDisplayingWidget | ( | QWidget *const | widget | ) |
| static

(currently it is only possible to set one global widget)

## ◆ setHighlightPixmap()

void Digikam::ThumbnailLoadThread::setHighlightPixmap | ( | bool | highlight | ) |

This option has only an effect if pixmapRequested is true. Default value: Enabled.

## ◆ setPixmapRequested()

void Digikam::ThumbnailLoadThread::setPixmapRequested | ( | bool | wantPixmap | ) |

If you do not enable this, only the QImage-based signal (see LoadSaveThread) will be emitted.

If you disable this, pay attention to the (global) setting of the LoadingCache, which per default does not cache the images !!

Default value: Enabled.

## ◆ setSendSurrogatePixmap()

void Digikam::ThumbnailLoadThread::setSendSurrogatePixmap | ( | bool | send | ) |

It will use standard system icons to replace the real thumbnail. If you disable this, a null QPixmap will be sent. This does not influence the QImage-based signal; this signal will be emitted with a null QImage regardless of this setting here, if the loading failed. Default value: Enabled.

## ◆ setThumbnailSize()

void Digikam::ThumbnailLoadThread::setThumbnailSize | ( | int | size,
|  | bool | forFace = `false`
| ) |  |

Note
  If the thread is currently loading thumbnails, there is no guarantee as to when the property change by one of the following methods takes effect. Default value: 128

## ◆ signalThumbnailLoaded

void Digikam::ThumbnailLoadThread::signalThumbnailLoaded | ( | const LoadingDescription & | loadingDescription,
|  | const QPixmap & | pix
| ) |  |
| signal

Note
  See LoadSaveThread for a QImage-based thumbnailLoaded() signal.

## ◆ storeDetailThumbnail()

void Digikam::ThumbnailLoadThread::storeDetailThumbnail | ( | const QString & | filePath,
|  | const QRect & | detailRect,
|  | const QImage & | image,
|  | bool | isFace = `false`
| ) |  |

Use this if possible because generation of detail thumbnails is potentially slower. The image should at least have storedSize().

## ◆ thumbnailCreator()

ThumbnailCreator * Digikam::ThumbnailLoadThread::thumbnailCreator | ( |  | ) | const

Note
  For internal use - may only be used from the thread

## ◆ thumbnailLoaded()

void Digikam::ThumbnailLoadThread::thumbnailLoaded | ( | const LoadingDescription & | loadingDescription,
|  | const QImage & | img
| ) |  |
| overrideprotectedvirtual

Reimplemented from Digikam::LoadSaveThread.

## ◆ thumbnailsAvailable

void Digikam::ThumbnailLoadThread::thumbnailsAvailable | ( |  | ) |
| signal

Note
  For internal use only.

## ◆ thumbnailToPixmapSize()

int Digikam::ThumbnailLoadThread::thumbnailToPixmapSize | ( | int | size | ) | const

These can differ when highlighting is turned on.