File indexing completed on 2025-01-05 03:56:22
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-07-13 0007 * Description : caption values container 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_CAPTION_VALUES_H 0016 #define DIGIKAM_CAPTION_VALUES_H 0017 0018 // Qt includes 0019 0020 #include <QMap> 0021 #include <QString> 0022 #include <QDateTime> 0023 #include <QDebug> 0024 0025 // Local includes 0026 0027 #include "digikam_export.h" 0028 #include "metaengine.h" 0029 0030 namespace Digikam 0031 { 0032 0033 class DIGIKAM_EXPORT CaptionValues 0034 { 0035 public: 0036 0037 explicit CaptionValues(); 0038 ~CaptionValues(); 0039 0040 bool operator==(const CaptionValues& val) const; 0041 0042 public: 0043 0044 QString caption; 0045 QString author; 0046 QDateTime date; 0047 }; 0048 0049 //! qDebug() stream operator. Writes values @a val to the debug output in a nicely formatted way. 0050 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const CaptionValues& val); 0051 0052 // -------------------------------------------------------------------- 0053 0054 /** 0055 * A map used to store a list of Alternative Language values + author and date properties 0056 * The map key is the language code following RFC3066 notation 0057 * (like "fr-FR" for French), and the CaptionsMap value all caption properties. 0058 */ 0059 class DIGIKAM_EXPORT CaptionsMap : public QMap<QString, CaptionValues> 0060 { 0061 public: 0062 0063 explicit CaptionsMap(); 0064 ~CaptionsMap(); 0065 0066 void setData(const MetaEngine::AltLangMap& comments, 0067 const MetaEngine::AltLangMap& authors, 0068 const QString& commonAuthor, 0069 const MetaEngine::AltLangMap& dates); 0070 0071 void fromAltLangMap(const MetaEngine::AltLangMap& map); 0072 MetaEngine::AltLangMap toAltLangMap() const; 0073 0074 /** 0075 * Sets the author for the comments in the specified languages. 0076 * If commonAuthor is not null, it will be used to set the author of all comments 0077 * for which the author is not specified in the map. 0078 */ 0079 void setAuthorsList(const MetaEngine::AltLangMap& map, const QString& commonAuthor = QString()); 0080 MetaEngine::AltLangMap authorsList() const; 0081 0082 void setDatesList(const MetaEngine::AltLangMap& map); 0083 MetaEngine::AltLangMap datesList() const; 0084 }; 0085 0086 } // namespace Digikam 0087 0088 Q_DECLARE_METATYPE(Digikam::CaptionValues) 0089 Q_DECLARE_METATYPE(Digikam::CaptionsMap) 0090 0091 #endif // DIGIKAM_CAPTION_VALUES_H