File indexing completed on 2025-04-27 03:57:26

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2015-08-17
0007  * Description : Helper class for Image Description Editor Tab
0008  *
0009  * SPDX-FileCopyrightText: 2015 by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DISJOINT_METADATA_P_H
0016 #define DIGIKAM_DISJOINT_METADATA_P_H
0017 
0018 #include "disjointmetadata.h"
0019 
0020 // Qt includes
0021 
0022 #include <QMutexLocker>
0023 #include <QtAlgorithms>
0024 
0025 // Local includes
0026 
0027 #include "templatemanager.h"
0028 #include "facetagseditor.h"
0029 #include "tagscache.h"
0030 #include "coredbaccess.h"
0031 #include "itemcomments.h"
0032 #include "iteminfo.h"
0033 #include "coredbwatch.h"
0034 #include "metadatahub.h"
0035 
0036 namespace Digikam
0037 {
0038 
0039 class Q_DECL_HIDDEN DisjointMetadata::Private : public DisjointMetadataDataFields
0040 {
0041 public:
0042 
0043     explicit Private();
0044 
0045     // use the automatic copy constructor
0046 
0047     explicit Private(const DisjointMetadataDataFields& other);
0048     explicit Private(const Private& other);
0049 
0050 public:
0051 
0052     void makeConnections(DisjointMetadata* const q);
0053 
0054     template <class T>
0055     void loadSingleValue(const T& data,
0056                          T& storage,
0057                          DisjointMetadataDataFields::Status& status)
0058     {
0059         switch (status)
0060         {
0061             case DisjointMetadataDataFields::MetadataInvalid:
0062             {
0063                 storage = data;
0064                 status  = DisjointMetadataDataFields::MetadataAvailable;
0065 
0066                 break;
0067             }
0068 
0069             case DisjointMetadataDataFields::MetadataAvailable:
0070             {
0071                 // we have two values. If they are equal, status is unchanged
0072 
0073                 if (data == storage)
0074                 {
0075                     break;
0076                 }
0077 
0078                 // they are not equal. We need to enter the disjoint state.
0079 
0080                 status = DisjointMetadataDataFields::MetadataDisjoint;
0081 
0082                 break;
0083             }
0084 
0085             case DisjointMetadataDataFields::MetadataDisjoint:
0086             {
0087                 break;
0088             }
0089         }
0090     };
0091 
0092 public:
0093 
0094     QMutex mutex;
0095 };
0096 
0097 } // namespace Digikam
0098 
0099 #endif // DIGIKAM_DISJOINT_METADATA_P_H