digiKam
collectionscanner_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 : 2007-03-21
7  * Description : Collection scanning to database - private containers.
8  *
9  * Copyright (C) 2005-2006 by Tom Albers <tomalbers at kde dot nl>
10  * Copyright (C) 2007-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_COLLECTION_SCANNER_P_H
27 #define DIGIKAM_COLLECTION_SCANNER_P_H
28 
29 #include "collectionscanner.h"
30 
31 // C++ includes
32 
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #ifndef Q_CC_MSVC
36 # include <unistd.h>
37 #endif
38 
39 // Qt includes
40 
41 #include <QDir>
42 #include <QFileInfo>
43 #include <QDirIterator>
44 #include <QWriteLocker>
45 #include <QReadWriteLock>
46 #include <QReadLocker>
47 #include <QStringList>
48 #include <QSet>
49 #include <QElapsedTimer>
50 #include <QScopedPointer>
51 
52 // Local includes
53 
54 #include "drawfiles.h"
55 #include "digikam_debug.h"
56 #include "coredb.h"
57 #include "collectionmanager.h"
58 #include "collectionlocation.h"
60 #include "coredbaccess.h"
61 #include "coredbbackend.h"
62 #include "coredbtransaction.h"
63 #include "coredboperationgroup.h"
64 #include "itemcomments.h"
65 #include "itemcopyright.h"
66 #include "iteminfo.h"
67 #include "itemscanner.h"
68 #include "metaenginesettings.h"
69 #include "tagscache.h"
70 #include "thumbsdbaccess.h"
71 #include "thumbsdb.h"
72 
73 namespace Digikam
74 {
75 
76 bool s_modificationDateEquals(const QDateTime& a, const QDateTime& b);
77 
78 // --------------------------------------------------------------------
79 
80 class Q_DECL_HIDDEN NewlyAppearedFile
81 {
82 
83 public:
84 
86  NewlyAppearedFile(int albumId, const QString& fileName);
87 
88  bool operator==(const NewlyAppearedFile& other) const;
89 
90 public:
91 
92  int albumId;
93  QString fileName;
94 };
95 
96 // --------------------------------------------------------------------
97 
98 inline uint qHash(const NewlyAppearedFile& file)
99 {
100  return ::qHash(file.albumId) ^ ::qHash(file.fileName);
101 }
102 
103 // --------------------------------------------------------------------
104 
106 {
107 public:
108 
109  void recordHints(const QList<AlbumCopyMoveHint>& hints) override;
110  void recordHints(const QList<ItemCopyMoveHint>& hints) override;
111  void recordHints(const QList<ItemChangeHint>& hints) override;
112  void recordHint(const ItemMetadataAdjustmentHint& hint) override;
113 
114  void clear() override;
115 
116  bool hasAnyNormalHint(qlonglong id);
117  bool hasAlbumHints();
118  bool hasModificationHint(qlonglong id);
119  bool hasRescanHint(qlonglong id);
120  bool hasMetadataAboutToAdjustHint(qlonglong id);
121  bool hasMetadataAdjustedHint(qlonglong id);
122 
123 public:
124 
125  QReadWriteLock lock;
126 
127  QHash<CollectionScannerHints::DstPath, CollectionScannerHints::Album> albumHints;
128  QHash<NewlyAppearedFile, qlonglong> itemHints;
129  QSet<qlonglong> modifiedItemHints;
130  QSet<qlonglong> rescanItemHints;
131  QHash<qlonglong, QDateTime> metadataAboutToAdjustHints;
132  QHash<qlonglong, QDateTime> metadataAdjustedHints;
133 };
134 
135 // --------------------------------------------------------------------
136 
137 class Q_DECL_HIDDEN CollectionScanner::Private
138 {
139 
140 public:
141 
142  explicit Private();
143 
144 public:
145 
146  void resetRemovedItemsTime();
147  void removedItems();
148 
149  bool checkObserver();
150  bool checkDeferred(const QFileInfo& info);
151 
152  void finishScanner(ItemScanner& scanner);
153 
154 public:
155 
156  QSet<QString> nameFilters;
157  QSet<QString> imageFilterSet;
158  QSet<QString> videoFilterSet;
159  QSet<QString> audioFilterSet;
160  QSet<QString> ignoreDirectory;
161 
166 
167  QDateTime removedItemsTime;
168 
170  QHash<int, int> establishedSourceAlbums;
172 
174  QSet<qlonglong> needResolveHistorySet;
175  QSet<qlonglong> needTaggingHistorySet;
176 
178  QSet<QString> deferredAlbumPaths;
179 
180  QHash<QString, QDateTime> albumDateCache;
182 
184 };
185 
186 } // namespace Digikam
187 
188 #endif // DIGIKAM_COLLECTION_SCANNER_P_H
uint qHash(const QList< Digikam::Album * > &key)
Definition: albumhistory.cpp:44
Definition: collectionscanner_p.h:106
QSet< qlonglong > modifiedItemHints
Definition: collectionscanner_p.h:129
QHash< CollectionScannerHints::DstPath, CollectionScannerHints::Album > albumHints
Definition: collectionscanner_p.h:127
QReadWriteLock lock
Definition: collectionscanner_p.h:125
QHash< NewlyAppearedFile, qlonglong > itemHints
Definition: collectionscanner_p.h:128
QHash< qlonglong, QDateTime > metadataAboutToAdjustHints
Definition: collectionscanner_p.h:131
QHash< qlonglong, QDateTime > metadataAdjustedHints
Definition: collectionscanner_p.h:132
QSet< qlonglong > rescanItemHints
Definition: collectionscanner_p.h:130
Definition: collectionscannerhints.h:56
Definition: collectionscannerobserver.h:41
Definition: collectionscanner_p.h:138
QSet< QString > ignoreDirectory
Definition: collectionscanner_p.h:160
QSet< QString > videoFilterSet
Definition: collectionscanner_p.h:158
QHash< int, int > establishedSourceAlbums
Definition: collectionscanner_p.h:170
QList< qlonglong > newIdsList
Definition: collectionscanner_p.h:181
bool recordHistoryIds
Definition: collectionscanner_p.h:173
QList< int > scannedAlbums
Definition: collectionscanner_p.h:162
QSet< qlonglong > needResolveHistorySet
Definition: collectionscanner_p.h:174
QSet< QString > deferredAlbumPaths
Definition: collectionscanner_p.h:178
QSet< QString > imageFilterSet
Definition: collectionscanner_p.h:157
CollectionScannerObserver * observer
Definition: collectionscanner_p.h:183
bool deferredFileScanning
Definition: collectionscanner_p.h:177
QSet< QString > nameFilters
Definition: collectionscanner_p.h:156
bool performFastScan
Definition: collectionscanner_p.h:165
QSet< QString > audioFilterSet
Definition: collectionscanner_p.h:159
QDateTime removedItemsTime
Definition: collectionscanner_p.h:167
QSet< qlonglong > needTaggingHistorySet
Definition: collectionscanner_p.h:175
bool needTotalFiles
Definition: collectionscanner_p.h:164
bool updatingHashHint
Definition: collectionscanner_p.h:171
QHash< QString, QDateTime > albumDateCache
Definition: collectionscanner_p.h:180
bool wantSignals
Definition: collectionscanner_p.h:163
CollectionScannerHintContainerImplementation * hints
Definition: collectionscanner_p.h:169
Definition: collectionscanner.h:50
Definition: collectionscannerhints.h:329
Definition: itemscanner.h:44
Definition: collectionscanner_p.h:81
int albumId
Definition: collectionscanner_p.h:92
QString fileName
Definition: collectionscanner_p.h:93
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49
bool s_modificationDateEquals(const QDateTime &a, const QDateTime &b)
Definition: collectionscanner_p.cpp:31
uint qHash(const PAlbumPath &id)
Definition: albummanager_p.h:141