File indexing completed on 2025-01-05 03:53:54
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-03-21 0007 * Description : Collection scanning to database - private containers. 0008 * 0009 * SPDX-FileCopyrightText: 2005-2006 by Tom Albers <tomalbers at kde dot nl> 0010 * SPDX-FileCopyrightText: 2007-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0011 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #ifndef DIGIKAM_COLLECTION_SCANNER_P_H 0018 #define DIGIKAM_COLLECTION_SCANNER_P_H 0019 0020 #include "collectionscanner.h" 0021 0022 // C++ includes 0023 0024 #include <sys/types.h> 0025 #include <sys/stat.h> 0026 #ifndef Q_CC_MSVC 0027 # include <unistd.h> 0028 #endif 0029 0030 // Qt includes 0031 0032 #include <QDir> 0033 #include <QFileInfo> 0034 #include <QDirIterator> 0035 #include <QWriteLocker> 0036 #include <QReadWriteLock> 0037 #include <QReadLocker> 0038 #include <QStringList> 0039 #include <QSet> 0040 #include <QElapsedTimer> 0041 #include <QScopedPointer> 0042 0043 // Local includes 0044 0045 #include "drawfiles.h" 0046 #include "digikam_debug.h" 0047 #include "coredb.h" 0048 #include "collectionmanager.h" 0049 #include "collectionlocation.h" 0050 #include "collectionscannerobserver.h" 0051 #include "coredbaccess.h" 0052 #include "coredbbackend.h" 0053 #include "coredbtransaction.h" 0054 #include "coredboperationgroup.h" 0055 #include "itemcomments.h" 0056 #include "itemcopyright.h" 0057 #include "iteminfo.h" 0058 #include "itemscanner.h" 0059 #include "metaenginesettings.h" 0060 #include "tagscache.h" 0061 #include "thumbsdbaccess.h" 0062 #include "thumbsdb.h" 0063 0064 namespace Digikam 0065 { 0066 0067 bool s_modificationDateEquals(const QDateTime& a, const QDateTime& b); 0068 0069 // -------------------------------------------------------------------- 0070 0071 class Q_DECL_HIDDEN NewlyAppearedFile 0072 { 0073 0074 public: 0075 0076 NewlyAppearedFile(); 0077 NewlyAppearedFile(int albumId, const QString& fileName); 0078 0079 bool operator==(const NewlyAppearedFile& other) const; 0080 0081 public: 0082 0083 int albumId; 0084 QString fileName; 0085 }; 0086 0087 // -------------------------------------------------------------------- 0088 0089 inline uint qHash(const NewlyAppearedFile& file) 0090 { 0091 return ::qHash(file.albumId) ^ ::qHash(file.fileName); 0092 } 0093 0094 // -------------------------------------------------------------------- 0095 0096 class Q_DECL_HIDDEN CollectionScannerHintContainerImplementation : public CollectionScannerHintContainer 0097 { 0098 public: 0099 0100 void recordHints(const QList<AlbumCopyMoveHint>& hints) override; 0101 void recordHints(const QList<ItemCopyMoveHint>& hints) override; 0102 void recordHints(const QList<ItemChangeHint>& hints) override; 0103 void recordHint(const ItemMetadataAdjustmentHint& hint) override; 0104 0105 void clear() override; 0106 0107 bool hasAnyNormalHint(qlonglong id); 0108 bool hasAlbumHints(); 0109 bool hasModificationHint(qlonglong id); 0110 bool hasRescanHint(qlonglong id); 0111 bool hasMetadataAboutToAdjustHint(qlonglong id); 0112 bool hasMetadataAdjustedHint(qlonglong id); 0113 0114 public: 0115 0116 QReadWriteLock lock; 0117 0118 QHash<CollectionScannerHints::DstPath, CollectionScannerHints::Album> albumHints; 0119 QHash<NewlyAppearedFile, qlonglong> itemHints; 0120 QSet<qlonglong> modifiedItemHints; 0121 QSet<qlonglong> rescanItemHints; 0122 QHash<qlonglong, QDateTime> metadataAboutToAdjustHints; 0123 QHash<qlonglong, QDateTime> metadataAdjustedHints; 0124 }; 0125 0126 // -------------------------------------------------------------------- 0127 0128 class Q_DECL_HIDDEN CollectionScanner::Private 0129 { 0130 0131 public: 0132 0133 explicit Private(); 0134 0135 public: 0136 0137 void resetRemovedItemsTime(); 0138 void removedItems(); 0139 0140 bool checkObserver(); 0141 bool checkDeferred(const QFileInfo& info); 0142 0143 void finishScanner(ItemScanner& scanner); 0144 0145 public: 0146 0147 QSet<QString> nameFilters; 0148 QSet<QString> imageFilterSet; 0149 QSet<QString> videoFilterSet; 0150 QSet<QString> audioFilterSet; 0151 QSet<QString> ignoreDirectory; 0152 0153 QList<int> scannedAlbums; 0154 bool wantSignals; 0155 bool needTotalFiles; 0156 bool performFastScan; 0157 0158 QDateTime removedItemsTime; 0159 0160 CollectionScannerHintContainerImplementation* hints; 0161 QHash<int, int> establishedSourceAlbums; 0162 bool updatingHashHint; 0163 0164 bool recordHistoryIds; 0165 QSet<qlonglong> needResolveHistorySet; 0166 QSet<qlonglong> needTaggingHistorySet; 0167 0168 bool deferredFileScanning; 0169 QSet<QString> deferredAlbumPaths; 0170 0171 QHash<QString, QDateTime> albumDateCache; 0172 QList<qlonglong> newIdsList; 0173 0174 CollectionScannerObserver* observer; 0175 }; 0176 0177 } // namespace Digikam 0178 0179 #endif // DIGIKAM_COLLECTION_SCANNER_P_H