File indexing completed on 2025-01-05 03:54:17

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2005-10-28
0007  * Description : scan item controller - private containers.
0008  *
0009  * SPDX-FileCopyrightText: 2005-2006 by Tom Albers <tomalbers at kde dot nl>
0010  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_SCAN_CONTROLLER_P_H
0018 #define DIGIKAM_SCAN_CONTROLLER_P_H
0019 
0020 #include "scancontroller.h"
0021 
0022 // Qt includes
0023 
0024 #include <QStringList>
0025 #include <QFileInfo>
0026 #include <QPixmap>
0027 #include <QIcon>
0028 #include <QTime>
0029 #include <QMutex>
0030 #include <QMutexLocker>
0031 #include <QWaitCondition>
0032 #include <QTimer>
0033 #include <QEventLoop>
0034 #include <QApplication>
0035 #include <QMessageBox>
0036 
0037 // KDE includes
0038 
0039 #include <klocalizedstring.h>
0040 
0041 // Local includes
0042 
0043 #include "digikam_debug.h"
0044 #include "coredbaccess.h"
0045 #include "collectionmanager.h"
0046 #include "collectionlocation.h"
0047 #include "filereadwritelock.h"
0048 #include "coredbwatch.h"
0049 #include "dprogressdlg.h"
0050 #include "dmetadata.h"
0051 #include "coredb.h"
0052 #include "albummanager.h"
0053 #include "album.h"
0054 #include "coredbschemaupdater.h"
0055 #include "iteminfo.h"
0056 
0057 namespace Digikam
0058 {
0059 
0060 /*
0061  * This class is derived from the LoadingCacheFileWatch,
0062  * which means it has the full functionality of the class
0063  * and only extends it by listening to CollectionScanner information
0064  */
0065 class Q_DECL_HIDDEN ScanControllerLoadingCacheFileWatch : public LoadingCacheFileWatch
0066 {
0067     Q_OBJECT
0068 
0069 public:
0070 
0071     ScanControllerLoadingCacheFileWatch();
0072 
0073 private Q_SLOTS:
0074 
0075     void slotImageChanged(const ImageChangeset& changeset);
0076 
0077 private:
0078 
0079     // Disable
0080     explicit ScanControllerLoadingCacheFileWatch(QObject*) = delete;
0081 };
0082 
0083 // ------------------------------------------------------------------------------
0084 
0085 class Q_DECL_HIDDEN SimpleCollectionScannerObserver : public CollectionScannerObserver
0086 {
0087 public:
0088 
0089     explicit SimpleCollectionScannerObserver(bool* const var);
0090 
0091     bool continueQuery() override;
0092 
0093 public:
0094 
0095     bool* m_continue;
0096 };
0097 
0098 // ------------------------------------------------------------------------------
0099 
0100 class Q_DECL_HIDDEN ScanController::Private
0101 {
0102 public:
0103 
0104     explicit Private();
0105 
0106 
0107     QPixmap albumPixmap();
0108     QPixmap rootPixmap();
0109     QPixmap actionPixmap();
0110     QPixmap errorPixmap();
0111     QPixmap restartPixmap();
0112 
0113     void garbageCollectHints(bool setAccessTime);
0114 
0115 public:
0116 
0117     bool                            running;
0118     bool                            needsInitialization;
0119     bool                            needsCompleteScan;
0120     bool                            needsUpdateUniqueHash;
0121     bool                            idle;
0122 
0123     int                             scanSuspended;
0124 
0125     QStringList                     scanTasks;
0126 
0127     QStringList                     completeScanDeferredAlbums;
0128     bool                            deferFileScanning;
0129     bool                            finishScanAllowed;
0130 
0131     QMutex                          mutex;
0132     QWaitCondition                  condVar;
0133 
0134     bool                            continueInitialization;
0135     bool                            continueScan;
0136     bool                            continuePartialScan;
0137 
0138     bool                            fileWatchInstalled;
0139 
0140     QEventLoop*                     eventLoop;
0141 
0142     QTimer*                         showTimer;
0143     QTimer*                         relaxedTimer;
0144     QTimer*                         externalTimer;
0145 
0146     QPixmap                         albumPix;
0147     QPixmap                         rootPix;
0148     QPixmap                         actionPix;
0149     QPixmap                         errorPix;
0150 
0151     CollectionScannerHintContainer* hints;
0152 
0153     QDateTime                       lastHintAdded;
0154 
0155     DProgressDlg*                   progressDialog;
0156 
0157     ScanController::Advice          advice;
0158 
0159     bool                            needTotalFiles;
0160     bool                            performFastScan;
0161     int                             totalFilesToScan;
0162 
0163     QList<qlonglong>                newIdsList;
0164 };
0165 
0166 // ------------------------------------------------------------------------------
0167 
0168 class Q_DECL_HIDDEN ScanControllerCreator
0169 {
0170 public:
0171 
0172     ScanController object;
0173 };
0174 
0175 } // namespace Digikam
0176 
0177 #endif // DIGIKAM_SCAN_CONTROLLER_P_H