digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
Digikam::ManagedLoadSaveThread Class Reference
+ Inheritance diagram for Digikam::ManagedLoadSaveThread:

Public Types

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 Member Functions

 ManagedLoadSaveThread (QObject *const parent=nullptr)
 Termination is controlled by setting the TerminationPolicy Default is TerminationPolicyTerminateLoading.
 
void load (const LoadingDescription &description)
 Append a task to load the given file to the task list.
 
void load (const LoadingDescription &description, LoadingPolicy policy)
 
LoadingPolicy loadingPolicy () const
 
void save (const DImg &image, const QString &filePath, const QString &format)
 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 load (const LoadingDescription &description)
 Append a task to load the given file to the task list.
 
void loadingProgress (const LoadingDescription &loadingDescription, float progress) override
 
void moreCompleteLoadingAvailable (const LoadingDescription &oldLoadingDescription, const LoadingDescription &newLoadingDescription) override
 
virtual bool querySendNotifyEvent () const
 
void save (const DImg &image, const QString &filePath, const QString &format)
 Append a task to save the image to the task list.
 
void savingProgress (const QString &filePath, float progress) override
 
void setNotificationPolicy (NotificationPolicy notificationPolicy)
 
virtual void taskHasFinished ()
 
void thumbnailLoaded (const LoadingDescription &loadingDescription, const QImage &img) override
 
- 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
 

Protected Member Functions

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 ()
 
- 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 shutDown ()
 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.
 
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)
 

Protected Attributes

LoadingPolicy m_loadingPolicy = LoadingPolicyAppend
 
TerminationPolicy m_terminationPolicy = TerminationPolicyTerminateLoading
 
- Protected Attributes inherited from Digikam::LoadSaveThread
LoadSaveTaskm_currentTask = nullptr
 
QMutex m_mutex
 
NotificationPolicy m_notificationPolicy = NotificationPolicyTimeLimited
 
QList< LoadSaveTask * > m_todo
 

Additional Inherited Members

- 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.
 
- 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 signalSavingProgress (const QString &filePath, float progress)
 
void signalThumbnailLoaded (const LoadingDescription &loadingDescription, const QImage &img)
 
- Signals inherited from Digikam::DynamicThread
void finished ()
 
void starting ()
 Emitted if emitSignals is enabled.
 
- 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 LoadSaveFileInfoProviderinfoProvider ()
 
static void setInfoProvider (LoadSaveFileInfoProvider *const infoProvider)
 

Member Enumeration Documentation

◆ LoadingMode

Enumerator
LoadingModeNormal 

no sharing of loading process, no caching of image

LoadingModeShared 

loading process is shared, image is cached

◆ LoadingPolicy

Enumerator
LoadingPolicyFirstRemovePrevious 

Load image immediately, remove and stop all previous loading tasks.

LoadingPolicyPrepend 

Prepend loading in front of all other tasks, but wait for the current task to finish.

No other tasks will be removed, preloading tasks will be stopped and postponed.

LoadingPolicySimplePrepend 

Prepend in front of all other tasks (not touching the current task).

Do not check for duplicate tasks, do not check for preloading tasks.

LoadingPolicyAppend 

Append loading task to the end of the list, but in front of all preloading tasks.

No other tasks will be removed, preloading tasks will be stopped and postponed. This is similar to the simple load() operation from LoadSaveThread, except for the special care taken for preloading.

LoadingPolicySimpleAppend 

Append to the lists of tasks.

Do not check for duplicate tasks, do not check for preloading tasks.

LoadingPolicyPreload 

Preload image, i.e.

load it with low priority when no other tasks are scheduled. All other tasks will take precedence, and preloading tasks will be stopped and postponed when another task is added. No progress info will be sent for preloaded images

◆ LoadingTaskFilter

Enumerator
LoadingTaskFilterAll 

filter all loading tasks

LoadingTaskFilterPreloading 

filter only tasks with preloading policy

◆ TerminationPolicy

Enumerator
TerminationPolicyTerminateLoading 

Wait for saving tasks, stop and remove loading tasks This is the default.

TerminationPolicyTerminatePreloading 

Wait for loading and saving tasks, stop and remove preloading tasks.

TerminationPolicyWait 

Wait for all pending tasks.

TerminationPolicyTerminateAll 

Stop all pending tasks.

Member Function Documentation

◆ load()

void Digikam::ManagedLoadSaveThread::load ( const LoadingDescription description)

If there is already a task for the given file, it will possibly be rescheduled, but no second task will be added. Only loading tasks will - if required by the policy - be stopped or removed, saving tasks will not be touched.

◆ setLoadingPolicy()

void Digikam::ManagedLoadSaveThread::setLoadingPolicy ( LoadingPolicy  policy)

Default is LoadingPolicyAppend. You can override the default value for each operation.

◆ stopLoading()

void Digikam::ManagedLoadSaveThread::stopLoading ( const QString &  filePath = QString(),
LoadingTaskFilter  filter = LoadingTaskFilterAll 
)

If filePath isNull, applies to all file paths.

◆ stopSaving()

void Digikam::ManagedLoadSaveThread::stopSaving ( const QString &  filePath = QString())

If filePath isNull, applies to all file paths.