digiKam
managedloadsavethread.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2006-01-16
7  * Description : image file IO threaded interface.
8  *
9  * Copyright (C) 2005-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2005-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_MANAGED_LOAD_SAVE_THREAD_H
26 #define DIGIKAM_MANAGED_LOAD_SAVE_THREAD_H
27 
28 // Local includes
29 
30 #include "loadsavethread.h"
31 
32 namespace Digikam
33 {
34 
35 class LoadingTask;
36 class LoadSaveTask;
37 
38 class DIGIKAM_EXPORT ManagedLoadSaveThread : public LoadSaveThread
39 {
40  Q_OBJECT
41 
42 public:
43 
45  {
78  LoadingPolicyPreload
79  };
80 
82  {
99  TerminationPolicyTerminateAll
100  };
101 
103  {
111  LoadingTaskFilterPreloading
112  };
113 
118  {
126  LoadingModeShared
127  };
128 
129 public:
130 
135  explicit ManagedLoadSaveThread(QObject* const parent = nullptr);
136  ~ManagedLoadSaveThread() override;
137 
145  void load(const LoadingDescription& description);
146  void load(const LoadingDescription& description, LoadingPolicy policy);
147 
152  void stopLoading(const QString& filePath = QString(),
153  LoadingTaskFilter filter = LoadingTaskFilterAll);
154 
158  void stopLoading(const LoadingDescription& desc,
159  LoadingTaskFilter filter = LoadingTaskFilterAll);
160 
165  void stopSaving(const QString& filePath = QString());
166 
167  void stopAllTasks();
168 
172  void save(DImg& image, const QString& filePath, const QString& format);
173 
174  void setTerminationPolicy(TerminationPolicy terminationPolicy);
175  TerminationPolicy terminationPolicy() const;
176 
182  void setLoadingPolicy(LoadingPolicy policy);
183  LoadingPolicy loadingPolicy() const;
184 
185 protected:
186 
187  void shutDown();
188 
189  void load(const LoadingDescription& description, LoadingMode loadingMode,
190  AccessMode mode = AccessModeReadWrite);
191 
192  void load(const LoadingDescription& description, LoadingMode loadingMode,
193  LoadingPolicy policy, AccessMode mode = AccessModeReadWrite);
194 
195  void loadPreview(const LoadingDescription& description, LoadingPolicy policy);
196  void loadThumbnail(const LoadingDescription& description);
197 
198  void preloadThumbnail(const LoadingDescription& description);
199  void preloadThumbnailGroup(const QList<LoadingDescription>& descriptions);
200  void prependThumbnailGroup(const QList<LoadingDescription>& descriptions);
201 
202 protected:
203 
206 
207 private:
208 
209  LoadingTask* checkLoadingTask(LoadSaveTask* const task, LoadingTaskFilter filter) const;
210  LoadingTask* findExistingTask(const LoadingDescription& description) const;
211  LoadingTask* createLoadingTask(const LoadingDescription& description,
212  bool preloading,
213  LoadingMode loadingMode,
214  AccessMode accessMode);
215 
216  void removeLoadingTasks(const LoadingDescription& description, LoadingTaskFilter filter);
217 
218 private:
219 
220  // Disable
222  ManagedLoadSaveThread& operator=(const ManagedLoadSaveThread&) = delete;
223 };
224 
225 } // namespace Digikam
226 
227 #endif // DIGIKAM_MANAGED_LOAD_SAVE_THREAD_H
Definition: dimg.h:62
Definition: loadsavetask.h:46
Definition: loadsavethread.h:103
AccessMode
Definition: loadsavethread.h:127
Definition: loadingdescription.h:45
Definition: loadsavetask.h:83
Definition: managedloadsavethread.h:39
LoadingPolicy m_loadingPolicy
Definition: managedloadsavethread.h:204
TerminationPolicy
Definition: managedloadsavethread.h:82
@ TerminationPolicyWait
Definition: managedloadsavethread.h:95
@ TerminationPolicyTerminateLoading
Definition: managedloadsavethread.h:87
@ TerminationPolicyTerminatePreloading
Definition: managedloadsavethread.h:91
LoadingPolicy
Definition: managedloadsavethread.h:45
@ LoadingPolicySimplePrepend
Definition: managedloadsavethread.h:59
@ LoadingPolicyFirstRemovePrevious
Definition: managedloadsavethread.h:49
@ LoadingPolicyAppend
Definition: managedloadsavethread.h:66
@ LoadingPolicyPrepend
Definition: managedloadsavethread.h:54
@ LoadingPolicySimpleAppend
Definition: managedloadsavethread.h:71
LoadingTaskFilter
Definition: managedloadsavethread.h:103
@ LoadingTaskFilterAll
Definition: managedloadsavethread.h:107
LoadingMode
Definition: managedloadsavethread.h:118
@ LoadingModeNormal
Definition: managedloadsavethread.h:122
TerminationPolicy m_terminationPolicy
Definition: managedloadsavethread.h:205
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43