digiKam
fileactionmngr_p.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 : 2009-05-05
7  * Description : file action manager
8  *
9  * Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2011-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_FILE_ACTION_MNGR_PRIVATE_H
26 #define DIGIKAM_FILE_ACTION_MNGR_PRIVATE_H
27 
28 // Qt includes
29 
30 #include <QMutex>
31 #include <QSet>
32 #include <QTimer>
33 
34 // Local includes
35 
36 #include "fileactionmngr.h"
37 #include "fileworkeriface.h"
39 #include "databaseworkeriface.h"
40 #include "metadatahub.h"
41 #include "parallelworkers.h"
42 
43 namespace Digikam
44 {
45 
47 {
50  Ungroup
51 };
52 
53 class Q_DECL_HIDDEN PrivateProgressItemCreator : public QObject, // clazy:exclude=ctor-missing-parent-argument
55 {
56  Q_OBJECT
57 
58 public:
59 
60  ProgressItem* createProgressItem(const QString& action) const override;
61  void addProgressItem(ProgressItem* const item) override;
62 
63  QAtomicInt activeProgressItems;
64 
65 Q_SIGNALS:
66 
68 
69 public Q_SLOTS:
70 
71  void slotProgressItemCompleted();
72  void slotProgressItemCanceled(ProgressItem* item);
73 };
74 
75 // -----------------------------------------------------------------------------------------------------------
76 
77 class Q_DECL_HIDDEN FileActionMngr::Private : public QObject
78 {
79  Q_OBJECT
80 
81 public:
82 
83  explicit Private(FileActionMngr* const qq);
84  ~Private() override;
85 
86 Q_SIGNALS:
87 
89 
90  // Inter-thread signals: connected to database worker slots
91  void signalAddTags(const FileActionItemInfoList& infos, const QList<int>& tagIDs);
92  void signalRemoveTags(const FileActionItemInfoList& infos, const QList<int>& tagIDs);
93  void signalAssignPickLabel(const FileActionItemInfoList& infos, int pickId);
94  void signalAssignColorLabel(const FileActionItemInfoList& infos, int colorId);
95  void signalAssignRating(const FileActionItemInfoList& infos, int rating);
96  void signalSetExifOrientation(const FileActionItemInfoList& infos, int orientation);
98  void signalEditGroup(int groupAction, const ItemInfo& pick, const FileActionItemInfoList& infos);
99  void signalTransform(const FileActionItemInfoList& infos, int orientation);
100  void signalCopyAttributes(const FileActionItemInfoList& infos, const QStringList& derivedPaths);
101 
102 public:
103 
104  // -- Signal-emitter glue code --
105 
106  void assignTags(const FileActionItemInfoList& infos, const QList<int>& tagIDs)
107  {
108  emit signalAddTags(infos, tagIDs);
109  }
110 
111  void removeTags(const FileActionItemInfoList& infos, const QList<int>& tagIDs)
112  {
113  emit signalRemoveTags(infos, tagIDs);
114  }
115 
116  void assignPickLabel(const FileActionItemInfoList& infos, int pickId)
117  {
118  emit signalAssignPickLabel(infos, pickId);
119  }
120 
121  void assignColorLabel(const FileActionItemInfoList& infos, int colorId)
122  {
123  emit signalAssignColorLabel(infos, colorId);
124  }
125 
126  void assignRating(const FileActionItemInfoList& infos, int rating)
127  {
128  emit signalAssignRating(infos, rating);
129  }
130 
131  void editGroup(int groupAction, const ItemInfo& pick, const FileActionItemInfoList& infos)
132  {
133  emit signalEditGroup(groupAction, pick, infos);
134  }
135 
136  void setExifOrientation(const FileActionItemInfoList& infos, int orientation)
137  {
138  emit signalSetExifOrientation(infos, orientation);
139  }
140 
142  {
143  emit signalApplyMetadata(infos, hub);
144  }
145 
146  void transform(const FileActionItemInfoList& infos, int orientation)
147  {
148  emit signalTransform(infos, orientation);
149  }
150 
151  void copyAttributes(const FileActionItemInfoList& infos, const QStringList& derivedPaths)
152  {
153  emit signalCopyAttributes(infos, derivedPaths);
154  }
155 
156 public:
157 
158  // -- Workflow controlling --
159 
160  bool isActive() const;
161 
163  bool shallSendForWriting(qlonglong id);
164 
166  void startingToWrite(const QList<ItemInfo>& infos);
167 
168  void connectToDatabaseWorker();
169  void connectDatabaseToFileWorker();
170 
171  PrivateProgressItemCreator* dbProgressCreator();
172  PrivateProgressItemCreator* fileProgressCreator();
173 
174 public Q_SLOTS:
175 
176  void slotImageDataChanged(const QString& path, bool removeThumbnails, bool notifyCache);
177  void slotSleepTimer();
178  void slotLastProgressItemCompleted();
179 
180 public:
181 
182  QSet<qlonglong> scheduledToWrite;
183  QString dbMessage;
184  QString writerMessage;
185  QMutex mutex;
186 
188 
191 
192  QTimer* sleepTimer;
193 
196 };
197 
198 } // namespace Digikam
199 
200 #endif // DIGIKAM_FILE_ACTION_MNGR_PRIVATE_H
Definition: databaseworkeriface.h:44
Definition: disjointmetadata.h:47
Definition: fileactionimageinfolist.h:104
Definition: fileactionmngr_p.h:78
FileActionMngr * q
Definition: fileactionmngr_p.h:187
void transform(const FileActionItemInfoList &infos, int orientation)
Definition: fileactionmngr_p.h:146
void signalAssignPickLabel(const FileActionItemInfoList &infos, int pickId)
void assignRating(const FileActionItemInfoList &infos, int rating)
Definition: fileactionmngr_p.h:126
void assignTags(const FileActionItemInfoList &infos, const QList< int > &tagIDs)
Definition: fileactionmngr_p.h:106
QString dbMessage
Definition: fileactionmngr_p.h:183
void signalEditGroup(int groupAction, const ItemInfo &pick, const FileActionItemInfoList &infos)
void setExifOrientation(const FileActionItemInfoList &infos, int orientation)
Definition: fileactionmngr_p.h:136
void signalApplyMetadata(const FileActionItemInfoList &infos, DisjointMetadata *hub)
DatabaseWorkerInterface * dbWorker
Definition: fileactionmngr_p.h:189
void assignColorLabel(const FileActionItemInfoList &infos, int colorId)
Definition: fileactionmngr_p.h:121
ParallelAdapter< FileWorkerInterface > * fileWorker
Definition: fileactionmngr_p.h:190
void signalAssignColorLabel(const FileActionItemInfoList &infos, int colorId)
void signalRemoveTags(const FileActionItemInfoList &infos, const QList< int > &tagIDs)
void removeTags(const FileActionItemInfoList &infos, const QList< int > &tagIDs)
Definition: fileactionmngr_p.h:111
QMutex mutex
Definition: fileactionmngr_p.h:185
void signalAssignRating(const FileActionItemInfoList &infos, int rating)
QSet< qlonglong > scheduledToWrite
Definition: fileactionmngr_p.h:182
void signalTransform(const FileActionItemInfoList &infos, int orientation)
PrivateProgressItemCreator dbProgress
Definition: fileactionmngr_p.h:194
void copyAttributes(const FileActionItemInfoList &infos, const QStringList &derivedPaths)
Definition: fileactionmngr_p.h:151
void signalSetExifOrientation(const FileActionItemInfoList &infos, int orientation)
QTimer * sleepTimer
Definition: fileactionmngr_p.h:192
QString writerMessage
Definition: fileactionmngr_p.h:184
void applyMetadata(const FileActionItemInfoList &infos, DisjointMetadata *hub)
Definition: fileactionmngr_p.h:141
void signalAddTags(const FileActionItemInfoList &infos, const QList< int > &tagIDs)
void editGroup(int groupAction, const ItemInfo &pick, const FileActionItemInfoList &infos)
Definition: fileactionmngr_p.h:131
PrivateProgressItemCreator fileProgress
Definition: fileactionmngr_p.h:195
void signalCopyAttributes(const FileActionItemInfoList &infos, const QStringList &derivedPaths)
void assignPickLabel(const FileActionItemInfoList &infos, int pickId)
Definition: fileactionmngr_p.h:116
Definition: fileactionmngr.h:42
Definition: fileactionimageinfolist.h:43
Definition: iteminfo.h:78
Definition: parallelworkers.h:132
Definition: fileactionmngr_p.h:55
QAtomicInt activeProgressItems
Definition: fileactionmngr_p.h:63
Definition: progressmanager.h:45
Definition: datefolderview.cpp:43
GroupAction
Definition: fileactionmngr_p.h:47
@ AddToGroup
Definition: fileactionmngr_p.h:48
@ Ungroup
Definition: fileactionmngr_p.h:50
@ RemoveFromGroup
Definition: fileactionmngr_p.h:49