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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2015-06-01
0007  * Description : DB Jobs for listing and scanning
0008  *
0009  * SPDX-FileCopyrightText: 2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DB_JOB_H
0016 #define DIGIKAM_DB_JOB_H
0017 
0018 // Local includes
0019 
0020 #include "dbjobinfo.h"
0021 #include "itemlisterrecord.h"
0022 #include "duplicatesprogressobserver.h"
0023 #include "actionthreadbase.h"
0024 #include "digikam_export.h"
0025 
0026 namespace Digikam
0027 {
0028 
0029 class DuplicatesProgressObserver;
0030 
0031 class DIGIKAM_DATABASE_EXPORT DBJob : public ActionJob
0032 {
0033     Q_OBJECT
0034 
0035 protected:
0036 
0037     explicit DBJob();
0038     ~DBJob()        override;
0039 
0040 Q_SIGNALS:
0041 
0042     void data(const QList<ItemListerRecord>& records);
0043     void error(const QString& err);
0044 
0045 private:
0046 
0047     // Disable
0048     explicit DBJob(QObject*) = delete;
0049 };
0050 
0051 // ----------------------------------------------
0052 
0053 class DIGIKAM_DATABASE_EXPORT AlbumsJob : public DBJob
0054 {
0055     Q_OBJECT
0056 
0057 public:
0058 
0059     explicit AlbumsJob(const AlbumsDBJobInfo& jobInfo);
0060     ~AlbumsJob()    override;
0061 
0062 protected:
0063 
0064     void run()      override;
0065 
0066 Q_SIGNALS:
0067 
0068     void foldersData(const QHash<int, int>&);
0069 
0070 private:
0071 
0072     AlbumsDBJobInfo m_jobInfo;
0073 
0074 private:
0075 
0076     // Disable
0077     AlbumsJob(QObject*);
0078 };
0079 
0080 // ----------------------------------------------
0081 
0082 class DIGIKAM_DATABASE_EXPORT DatesJob : public DBJob
0083 {
0084     Q_OBJECT
0085 
0086 public:
0087 
0088     explicit DatesJob(const DatesDBJobInfo& jobInfo);
0089     ~DatesJob()     override;
0090 
0091 protected:
0092 
0093     void run()      override;
0094 
0095 Q_SIGNALS:
0096 
0097     void foldersData(const QHash<QDateTime, int>& datesStatMap);
0098 
0099 private:
0100 
0101     DatesDBJobInfo m_jobInfo;
0102 
0103 private:
0104 
0105     // Disable
0106     DatesJob(QObject*) = delete;
0107 };
0108 
0109 // ----------------------------------------------
0110 
0111 class DIGIKAM_DATABASE_EXPORT GPSJob : public DBJob
0112 {
0113     Q_OBJECT
0114 
0115 public:
0116 
0117     explicit GPSJob(const GPSDBJobInfo& jobInfo);
0118     ~GPSJob()       override;
0119 
0120 protected:
0121 
0122     void run()      override;
0123 
0124 Q_SIGNALS:
0125 
0126     void directQueryData(const QList<QVariant>& data);
0127 
0128 private:
0129 
0130     GPSDBJobInfo m_jobInfo;
0131 
0132 private:
0133 
0134     // Disable
0135     GPSJob(QObject*);
0136 };
0137 
0138 // ----------------------------------------------
0139 
0140 class DIGIKAM_DATABASE_EXPORT TagsJob : public DBJob
0141 {
0142     Q_OBJECT
0143 
0144 public:
0145 
0146     explicit TagsJob(const TagsDBJobInfo& jobInfo);
0147     ~TagsJob()      override;
0148 
0149 protected:
0150 
0151     void run()      override;
0152 
0153 Q_SIGNALS:
0154 
0155     void foldersData(const QHash<int, int>& data);
0156     void faceFoldersData(const QMap<QString, QHash<int, int> >& data);
0157 
0158 private:
0159 
0160     TagsDBJobInfo m_jobInfo;
0161 
0162 private:
0163 
0164     // Disable
0165     TagsJob(QObject*);
0166 };
0167 
0168 // ----------------------------------------------
0169 
0170 class DIGIKAM_DATABASE_EXPORT SearchesJob : public DBJob
0171 {
0172     Q_OBJECT
0173 
0174 public:
0175 
0176     explicit SearchesJob(const SearchesDBJobInfo& jobInfo);
0177     SearchesJob(const SearchesDBJobInfo& jobInfo,
0178                 const QSet<qlonglong>::const_iterator& begin,
0179                 const QSet<qlonglong>::const_iterator& end,
0180                 HaarIface* iface);
0181 
0182     ~SearchesJob()  override;
0183 
0184     bool isCanceled() const;
0185 
0186 Q_SIGNALS:
0187 
0188     void signalImageProcessed();
0189     void signalDuplicatesResults(const HaarIface::DuplicatesResultsMap&);
0190 
0191 protected:
0192 
0193     void run()      override;
0194 
0195 private:
0196 
0197     SearchesDBJobInfo                m_jobInfo;
0198     QSet<qlonglong>::const_iterator  m_begin;
0199     QSet<qlonglong>::const_iterator  m_end;
0200     HaarIface*                       m_iface;
0201 
0202 private:
0203 
0204     // Disable
0205     SearchesJob(QObject*);
0206 
0207     void runSearches();
0208     void runFindDuplicates();
0209 };
0210 
0211 } // namespace Digikam
0212 
0213 #endif // DIGIKAM_DB_JOB_H