File indexing completed on 2025-01-19 03:59:30
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2017-02-20 0007 * Description : Synchronized container for maintenance data. 0008 * 0009 * SPDX-FileCopyrightText: 2017-2018 by Mario Frank <mario dot frank at uni minus potsdam dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "maintenancedata.h" 0016 0017 // Qt includes 0018 0019 #include <QRecursiveMutex> 0020 #include <QMutexLocker> 0021 0022 // Local includes 0023 0024 0025 namespace Digikam 0026 { 0027 0028 class Q_DECL_HIDDEN MaintenanceData::Private 0029 { 0030 public: 0031 0032 explicit Private() 0033 : rebuildAllFingerprints(true) 0034 { 0035 } 0036 0037 QList<qlonglong> imageIdList; 0038 QList<int> thumbnailIdList; 0039 QList<QString> imagePathList; 0040 QList<ItemInfo> imageInfoList; 0041 QList<Identity> identitiesList; 0042 QList<qlonglong> similarityImageIdList; 0043 0044 bool rebuildAllFingerprints; 0045 0046 QRecursiveMutex mutex; 0047 }; 0048 0049 MaintenanceData::MaintenanceData() 0050 : d(new Private) 0051 { 0052 } 0053 0054 MaintenanceData::~MaintenanceData() 0055 { 0056 delete d; 0057 } 0058 0059 void MaintenanceData::setImageIds(const QList<qlonglong>& ids) 0060 { 0061 d->imageIdList = ids; 0062 } 0063 0064 void MaintenanceData::setThumbnailIds(const QList<int>& ids) 0065 { 0066 d->thumbnailIdList = ids; 0067 } 0068 0069 void MaintenanceData::setImagePaths(const QList<QString>& paths) 0070 { 0071 d->imagePathList = paths; 0072 } 0073 0074 void MaintenanceData::setItemInfos(const QList<ItemInfo>& infos) 0075 { 0076 d->imageInfoList = infos; 0077 } 0078 0079 void MaintenanceData::setSimilarityImageIds(const QList<qlonglong>& ids) 0080 { 0081 d->similarityImageIdList = ids; 0082 } 0083 0084 void MaintenanceData::setIdentities(const QList<Identity>& identities) 0085 { 0086 d->identitiesList = identities; 0087 } 0088 0089 void MaintenanceData::setRebuildAllFingerprints(bool b) 0090 { 0091 d->rebuildAllFingerprints = b; 0092 } 0093 0094 qlonglong MaintenanceData::getImageId() const 0095 { 0096 QMutexLocker locker(&d->mutex); 0097 0098 qlonglong id = -1; 0099 0100 if (!d->imageIdList.isEmpty()) 0101 { 0102 id = d->imageIdList.takeFirst(); 0103 } 0104 0105 return id; 0106 } 0107 0108 int MaintenanceData::getThumbnailId() const 0109 { 0110 QMutexLocker locker(&d->mutex); 0111 0112 int id = -1; 0113 0114 if (!d->thumbnailIdList.isEmpty()) 0115 { 0116 id = d->thumbnailIdList.takeFirst(); 0117 } 0118 0119 return id; 0120 } 0121 0122 QString MaintenanceData::getImagePath() const 0123 { 0124 QMutexLocker locker(&d->mutex); 0125 0126 QString path; 0127 0128 if (!d->imagePathList.isEmpty()) 0129 { 0130 path = d->imagePathList.takeFirst(); 0131 } 0132 0133 return path; 0134 } 0135 0136 ItemInfo MaintenanceData::getItemInfo() const 0137 { 0138 QMutexLocker locker(&d->mutex); 0139 0140 ItemInfo info; 0141 0142 if (!d->imageInfoList.isEmpty()) 0143 { 0144 info = d->imageInfoList.takeFirst(); 0145 } 0146 0147 return info; 0148 } 0149 0150 Identity MaintenanceData::getIdentity() const 0151 { 0152 QMutexLocker locker(&d->mutex); 0153 0154 Identity identity; 0155 0156 if (!d->identitiesList.isEmpty()) 0157 { 0158 identity = d->identitiesList.takeFirst(); 0159 } 0160 0161 return identity; 0162 } 0163 0164 qlonglong MaintenanceData::getSimilarityImageId() const 0165 { 0166 QMutexLocker locker(&d->mutex); 0167 0168 qlonglong id = -1; 0169 0170 if (!d->similarityImageIdList.isEmpty()) 0171 { 0172 id = d->similarityImageIdList.takeFirst(); 0173 } 0174 0175 return id; 0176 } 0177 0178 bool MaintenanceData::getRebuildAllFingerprints() const 0179 { 0180 return d->rebuildAllFingerprints; 0181 } 0182 0183 } // namespace Digikam