File indexing completed on 2025-01-19 03:53:20

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2004-06-15
0007  * Description : Albums manager interface - private containers.
0008  *
0009  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0011  * SPDX-FileCopyrightText: 2015      by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_ALBUM_MANAGER_P_H
0018 #define DIGIKAM_ALBUM_MANAGER_P_H
0019 
0020 #include "albummanager.h"
0021 
0022 // C ANSI includes
0023 
0024 extern "C"
0025 {
0026 #ifndef Q_CC_MSVC
0027 #   include <unistd.h>
0028 #endif
0029 #include <sys/types.h>
0030 #include <sys/stat.h>
0031 }
0032 
0033 // C++ includes
0034 
0035 #include <cerrno>
0036 #include <clocale>
0037 #include <cstdio>
0038 #include <cstdlib>
0039 
0040 // Qt includes
0041 
0042 #include <QApplication>
0043 #include <QByteArray>
0044 #include <QDir>
0045 #include <QFile>
0046 #include <QGroupBox>
0047 #include <QHash>
0048 #include <QLabel>
0049 #include <QList>
0050 #include <QMultiHash>
0051 #include <QRadioButton>
0052 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
0053 #include <QTextCodec>
0054 #endif
0055 #include <QTimer>
0056 #include <QComboBox>
0057 #include <QIcon>
0058 #include <QPointer>
0059 #include <QDialog>
0060 #include <QDialogButtonBox>
0061 #include <QVBoxLayout>
0062 #include <QMessageBox>
0063 #include <QCheckBox>
0064 #include <QSet>
0065 
0066 // KDE includes
0067 
0068 #include <klocalizedstring.h>
0069 
0070 // Local includes
0071 
0072 #include "digikam_debug.h"
0073 #include "coredb.h"
0074 #include "album.h"
0075 #include "albumpointer.h"
0076 #include "applicationsettings.h"
0077 #include "metaenginesettings.h"
0078 #include "metadatasynchronizer.h"
0079 #include "metadatahubmngr.h"
0080 #include "albumwatch.h"
0081 #include "itemattributeswatch.h"
0082 #include "collectionlocation.h"
0083 #include "collectionmanager.h"
0084 #include "digikam_config.h"
0085 #include "coredbaccess.h"
0086 #include "coredboperationgroup.h"
0087 #include "dbengineguierrorhandler.h"
0088 #include "dbengineparameters.h"
0089 #include "dbsettingswidget.h"
0090 #include "databaseserverstarter.h"
0091 #include "coredbthumbinfoprovider.h"
0092 #include "coredburl.h"
0093 #include "coredbsearchxml.h"
0094 #include "coredbwatch.h"
0095 #include "dio.h"
0096 #include "facetags.h"
0097 #include "facetagseditor.h"
0098 #include "itemlister.h"
0099 #include "scancontroller.h"
0100 #include "setupcollections.h"
0101 #include "setup.h"
0102 #include "tagscache.h"
0103 #include "thumbsdbaccess.h"
0104 #include "thumbnailloadthread.h"
0105 #include "dnotificationwrapper.h"
0106 #include "dbjobinfo.h"
0107 #include "dbjobsmanager.h"
0108 #include "dbjobsthread.h"
0109 #include "similaritydb.h"
0110 #include "similaritydbaccess.h"
0111 
0112 namespace Digikam
0113 {
0114 
0115 class Q_DECL_HIDDEN PAlbumPath
0116 {
0117 public:
0118 
0119     PAlbumPath();
0120     PAlbumPath(int albumRootId, const QString& albumPath);
0121     explicit PAlbumPath(PAlbum* const album);
0122 
0123     bool operator==(const PAlbumPath& other) const;
0124 
0125 public:
0126 
0127     int     albumRootId;
0128     QString albumPath;
0129 };
0130 
0131 // -----------------------------------------------------------------------------------
0132 
0133 inline uint qHash(const PAlbumPath& id)
0134 {
0135     return (::qHash(id.albumRootId) ^ ::qHash(id.albumPath));
0136 }
0137 
0138 // -----------------------------------------------------------------------------------
0139 
0140 class Q_DECL_HIDDEN AlbumManager::Private
0141 {
0142 public:
0143 
0144     explicit Private();
0145 
0146     bool                        changed;
0147     bool                        hasPriorizedDbPath;
0148 
0149     bool                        showOnlyAvailableAlbums;
0150 
0151     int                         longTimeMessageBoxResult;
0152     int                         askMergeMessageBoxResult;
0153 
0154     AlbumsDBJobsThread*         albumListJob;
0155     DatesDBJobsThread*          dateListJob;
0156     TagsDBJobsThread*           tagListJob;
0157     TagsDBJobsThread*           personListJob;
0158 
0159 
0160     AlbumWatch*                 albumWatch;
0161 
0162     PAlbum*                     rootPAlbum;
0163     TAlbum*                     rootTAlbum;
0164     DAlbum*                     rootDAlbum;
0165     SAlbum*                     rootSAlbum;
0166 
0167     QHash<int, Album*>          allAlbumsIdHash;
0168     QHash<PAlbumPath, PAlbum*>  albumPathHash;
0169     QHash<int, PAlbum*>         albumRootAlbumHash;
0170     Album*                      currentlyMovingAlbum;
0171 
0172     QMultiHash<Album*, Album**> guardedPointers;
0173 
0174     /**
0175      * For multiple selection support
0176      */
0177     QList<Album*>               currentAlbums;
0178 
0179     bool                        changingDB;
0180     QTimer*                     scanPAlbumsTimer;
0181     QTimer*                     scanTAlbumsTimer;
0182     QTimer*                     scanSAlbumsTimer;
0183     QTimer*                     scanDAlbumsTimer;
0184     QTimer*                     updatePAlbumsTimer;
0185     QTimer*                     albumItemCountTimer;
0186     QTimer*                     tagItemCountTimer;
0187     QSet<int>                   changedPAlbums;
0188 
0189     QHash<int, int>             pAlbumsCount;
0190     QHash<int, int>             tAlbumsCount;
0191     QHash<int, int>             fAlbumsCount;
0192     QMap<YearMonth, int>        dAlbumsCount;
0193     /// Unconfirmed face counts
0194     QHash<int, int>             uAlbumsCount;
0195     QList<int>                  toUpdatedFaces;
0196 
0197 public:
0198 
0199     QString labelForAlbumRootAlbum(const CollectionLocation& location);
0200 };
0201 
0202 // -----------------------------------------------------------------------------------
0203 
0204 class Q_DECL_HIDDEN ChangingDB
0205 {
0206 public:
0207 
0208     explicit ChangingDB(AlbumManager::Private* const dd);
0209     ~ChangingDB();
0210 
0211     AlbumManager::Private* const d;
0212 };
0213 
0214 // -----------------------------------------------------------------------------------
0215 
0216 class Q_DECL_HIDDEN AlbumManagerCreator
0217 {
0218 public:
0219 
0220     AlbumManager object;
0221 };
0222 
0223 } // namespace Digikam
0224 
0225 #endif // DIGIKAM_ALBUM_MANAGER_P_H