digiKam
maintenancethread.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 : 2013-08-09
7  * Description : Thread actions manager for maintenance tools.
8  *
9  * Copyright (C) 2013-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2017-2018 by Mario Frank <mario dot frank at uni minus potsdam dot de>
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_MAINTENANCE_THREAD_H
26 #define DIGIKAM_MAINTENANCE_THREAD_H
27 
28 // Qt includes
29 
30 #include <QList>
31 
32 // Local includes
33 
34 #include "actionthreadbase.h"
35 #include "metadatasynchronizer.h"
36 #include "iteminfo.h"
37 #include "identity.h"
38 
39 class QImage;
40 
41 namespace Digikam
42 {
43 
44 class ImageQualityContainer;
45 class MaintenanceData;
46 
48 {
49  Q_OBJECT
50 
51 public:
52 
53  explicit MaintenanceThread(QObject* const parent);
54  ~MaintenanceThread() override;
55 
56  void setUseMultiCore(const bool b);
57 
58  void syncMetadata(const ItemInfoList& items, MetadataSynchronizer::SyncDirection dir, bool tagsOnly);
59  void generateThumbs(const QStringList& paths);
60  void generateFingerprints(const QList<qlonglong>& itemIds, bool rebuildAll);
61  void sortByImageQuality(const QStringList& paths, const ImageQualityContainer& quality);
62 
63  void computeDatabaseJunk(bool thumbsDb = false, bool facesDb = false, bool similarityDb = false);
64  void cleanCoreDb(const QList<qlonglong>& imageIds);
65  void cleanThumbsDb(const QList<int>& thumbnailIds);
66  void cleanFacesDb(const QList<Identity>& staleIdentities);
67  void cleanSimilarityDb(const QList<qlonglong>& imageIds);
68  void shrinkDatabases();
69 
70  void cancel();
71 
73 
74 Q_SIGNALS:
75 
78  void signalStarted();
79 
82  void signalAdvance(const QImage&);
83 
86  void signalAdvance();
87 
91 
95 
98  void signalData(const QList<qlonglong>& staleImageIds,
99  const QList<int>& staleThumbIds,
100  const QList<Identity>& staleIdentities,
101  const QList<qlonglong>& staleSimilarityImageIds);
102 
106  void signalAddItemsToProcess(int count);
107 
112  void signalFinished(bool done, bool errorFree);
113 
114 private Q_SLOTS:
115 
116  void slotThreadFinished();
117 
118 private:
119 
128 /*
129  template<typename T>
130  QList<QList<T>> chunkList(const QList<T>& toChunk, int chunkSize=0)
131  {
132  QList<QList<T>> chunks;
133 
134  // Chunk size 0 means all
135 
136  if (chunkSize == 0)
137  {
138  chunks << toChunk;
139  return chunks;
140  }
141 
142  // Buffer the input list
143  QList<T> toChunkList = toChunk;
144  QList<T> currentChunk;
145 
146  while (!toChunkList.isEmpty())
147  {
148  // Set the current chunk to the first n elements
149  currentChunk = toChunkList.mid(0,chunkSize);
150  // Set the buffer list to the rest, i.e.
151  // start at position n and take all from this position
152  // If n is bigger than the size, an empty list is returned.
153  // see qarraydata.cpp in Qt implementation.
154  toChunkList = toChunkList.mid(chunkSize);
155  chunks << currentChunk;
156  }
157 
158  return chunks;
159  }
160 
161  int getChunkSize(int elementCount);
162 */
163 
164  MaintenanceData* const data;
165 };
166 
167 } // namespace Digikam
168 
169 #endif // DIGIKAM_MAINTENANCE_THREAD_H
Definition: actionthreadbase.h:102
Definition: imagequalitycontainer.h:39
Definition: iteminfolist.h:47
Definition: maintenancedata.h:42
Definition: maintenancethread.h:48
void signalFinished(bool done, bool errorFree)
void cleanSimilarityDb(const QList< qlonglong > &imageIds)
Definition: maintenancethread.cpp:267
void generateThumbs(const QStringList &paths)
Definition: maintenancethread.cpp:100
void cleanCoreDb(const QList< qlonglong > &imageIds)
Definition: maintenancethread.cpp:195
void cleanThumbsDb(const QList< int > &thumbnailIds)
Definition: maintenancethread.cpp:219
void cleanFacesDb(const QList< Identity > &staleIdentities)
Definition: maintenancethread.cpp:243
void signalData(const QList< qlonglong > &staleImageIds, const QList< int > &staleThumbIds, const QList< Identity > &staleIdentities, const QList< qlonglong > &staleSimilarityImageIds)
void generateFingerprints(const QList< qlonglong > &itemIds, bool rebuildAll)
Definition: maintenancethread.cpp:123
void shrinkDatabases()
Definition: maintenancethread.cpp:291
void computeDatabaseJunk(bool thumbsDb=false, bool facesDb=false, bool similarityDb=false)
Definition: maintenancethread.cpp:173
void syncMetadata(const ItemInfoList &items, MetadataSynchronizer::SyncDirection dir, bool tagsOnly)
Definition: maintenancethread.cpp:76
void signalAdvance(const QImage &)
void setUseMultiCore(const bool b)
Definition: maintenancethread.cpp:63
MaintenanceThread(QObject *const parent)
Definition: maintenancethread.cpp:46
void cancel()
Definition: maintenancethread.cpp:309
void signalAddItemsToProcess(int count)
~MaintenanceThread() override
Definition: maintenancethread.cpp:56
void sortByImageQuality(const QStringList &paths, const ImageQualityContainer &quality)
Definition: maintenancethread.cpp:147
SyncDirection
Definition: metadatasynchronizer.h:47
Definition: datefolderview.cpp:43