File indexing completed on 2025-01-05 03:56:23
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-06-20 0007 * Description : Template information 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 #include "template.h" 0016 0017 namespace Digikam 0018 { 0019 0020 Template::Template() 0021 { 0022 } 0023 0024 Template::~Template() 0025 { 0026 } 0027 0028 bool Template::isNull() const 0029 { 0030 return m_templateTitle.isNull(); 0031 } 0032 0033 bool Template::operator==(const Template& t) const 0034 { 0035 bool b1 = (m_authors == t.m_authors); 0036 bool b2 = (m_authorsPosition == t.m_authorsPosition); 0037 bool b3 = (m_credit == t.m_credit); 0038 bool b4 = (m_copyright == t.m_copyright); 0039 bool b5 = (m_rightUsageTerms == t.m_rightUsageTerms); 0040 bool b6 = (m_source == t.m_source); 0041 bool b7 = (m_instructions == t.m_instructions); 0042 bool b8 = (m_locationInfo == t.m_locationInfo); 0043 bool b9 = (m_contactInfo == t.m_contactInfo); 0044 bool b10 = (m_subjects == t.m_subjects); 0045 /* 0046 qCDebug(DIGIKAM_METAENGINE_LOG) << t.authors() << m_authors << b1; 0047 qCDebug(DIGIKAM_METAENGINE_LOG) << t.authorsPosition() << m_authorsPosition << b2; 0048 qCDebug(DIGIKAM_METAENGINE_LOG) << t.credit() << m_credit << b3; 0049 qCDebug(DIGIKAM_METAENGINE_LOG) << t.copyright() << m_copyright << b4; 0050 qCDebug(DIGIKAM_METAENGINE_LOG) << t.rightUsageTerms() << m_rightUsageTerms << b5; 0051 qCDebug(DIGIKAM_METAENGINE_LOG) << t.source() << m_source << b6; 0052 qCDebug(DIGIKAM_METAENGINE_LOG) << t.instructions() << m_instructions << b7; 0053 qCDebug(DIGIKAM_METAENGINE_LOG) << t.locationInfo() << m_locationInfo << b8; 0054 qCDebug(DIGIKAM_METAENGINE_LOG) << t.contactInfo() << m_contactInfo << b9; 0055 qCDebug(DIGIKAM_METAENGINE_LOG) << t.IptcSubjects() << m_subjects << b10; 0056 */ 0057 return (b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10); 0058 } 0059 0060 bool Template::isEmpty() const 0061 { 0062 return ( 0063 m_authors.isEmpty() && 0064 m_authorsPosition.isEmpty() && 0065 m_credit.isEmpty() && 0066 m_copyright.isEmpty() && 0067 m_rightUsageTerms.isEmpty() && 0068 m_source.isEmpty() && 0069 m_instructions.isEmpty() && 0070 m_locationInfo.isEmpty() && 0071 m_contactInfo.isEmpty() && 0072 m_subjects.isEmpty() 0073 ); 0074 } 0075 0076 void Template::merge(const Template& t) 0077 { 0078 m_templateTitle = t.templateTitle(); 0079 0080 if (!t.authors().isEmpty()) 0081 { 0082 m_authors = t.authors(); 0083 } 0084 0085 if (!t.authorsPosition().isEmpty()) 0086 { 0087 m_authorsPosition = t.authorsPosition(); 0088 } 0089 0090 if (!t.credit().isEmpty()) 0091 { 0092 m_credit = t.credit(); 0093 } 0094 0095 if (!t.copyright().isEmpty()) 0096 { 0097 m_copyright = t.copyright(); 0098 } 0099 0100 if (!t.rightUsageTerms().isEmpty()) 0101 { 0102 m_rightUsageTerms = t.rightUsageTerms(); 0103 } 0104 0105 if (!t.source().isEmpty()) 0106 { 0107 m_source = t.source(); 0108 } 0109 0110 if (!t.instructions().isEmpty()) 0111 { 0112 m_instructions = t.instructions(); 0113 } 0114 0115 m_locationInfo.merge(t.locationInfo()); 0116 m_contactInfo.merge(t.contactInfo()); 0117 0118 if (!t.IptcSubjects().isEmpty()) 0119 { 0120 m_subjects = t.IptcSubjects(); 0121 } 0122 } 0123 0124 void Template::setTemplateTitle(const QString& title) 0125 { 0126 m_templateTitle = title; 0127 } 0128 0129 QString Template::templateTitle() const 0130 { 0131 return m_templateTitle; 0132 } 0133 0134 void Template::setAuthors(const QStringList& authors) 0135 { 0136 m_authors = authors; 0137 m_authors.sort(); 0138 } 0139 0140 void Template::setAuthorsPosition(const QString& authorsPosition) 0141 { 0142 m_authorsPosition = authorsPosition; 0143 } 0144 0145 void Template::setCredit(const QString& credit) 0146 { 0147 m_credit = credit; 0148 } 0149 0150 void Template::setCopyright(const MetaEngine::AltLangMap& copyright) 0151 { 0152 m_copyright = copyright; 0153 } 0154 0155 void Template::setRightUsageTerms(const MetaEngine::AltLangMap& rightUsageTerms) 0156 { 0157 m_rightUsageTerms = rightUsageTerms; 0158 } 0159 0160 void Template::setSource(const QString& source) 0161 { 0162 m_source = source; 0163 } 0164 0165 void Template::setInstructions(const QString& instructions) 0166 { 0167 m_instructions = instructions; 0168 } 0169 0170 void Template::setLocationInfo(const IptcCoreLocationInfo& inf) 0171 { 0172 m_locationInfo = inf; 0173 } 0174 0175 void Template::setContactInfo(const IptcCoreContactInfo& inf) 0176 { 0177 m_contactInfo = inf; 0178 } 0179 0180 void Template::setIptcSubjects(const QStringList& subjects) 0181 { 0182 m_subjects = subjects; 0183 m_subjects.sort(); 0184 } 0185 0186 QStringList Template::authors() const 0187 { 0188 return m_authors; 0189 } 0190 0191 QString Template::authorsPosition() const 0192 { 0193 return m_authorsPosition; 0194 } 0195 0196 QString Template::credit() const 0197 { 0198 return m_credit; 0199 } 0200 0201 MetaEngine::AltLangMap Template::copyright() const 0202 { 0203 return m_copyright; 0204 } 0205 0206 MetaEngine::AltLangMap Template::rightUsageTerms() const 0207 { 0208 return m_rightUsageTerms; 0209 } 0210 0211 QString Template::source() const 0212 { 0213 return m_source; 0214 } 0215 0216 QString Template::instructions() const 0217 { 0218 return m_instructions; 0219 } 0220 0221 IptcCoreLocationInfo Template::locationInfo() const 0222 { 0223 return m_locationInfo; 0224 } 0225 0226 IptcCoreContactInfo Template::contactInfo() const 0227 { 0228 return m_contactInfo; 0229 } 0230 0231 QStringList Template::IptcSubjects() const 0232 { 0233 return m_subjects; 0234 } 0235 0236 QDebug operator<<(QDebug dbg, const Template& t) 0237 { 0238 dbg.nospace() << "Template::title: " 0239 << t.templateTitle() << ", "; 0240 dbg.nospace() << "Template::authors: " 0241 << t.authors() << ", "; 0242 dbg.nospace() << "Template::authorsPosition: " 0243 << t.authorsPosition() << ", "; 0244 dbg.nospace() << "Template::credit: " 0245 << t.credit() << ", "; 0246 dbg.nospace() << "Template::copyright: " 0247 << t.copyright() << ", "; 0248 dbg.nospace() << "Template::rightUsageTerms: " 0249 << t.rightUsageTerms() << ", "; 0250 dbg.nospace() << "Template::source: " 0251 << t.source() << ", "; 0252 dbg.nospace() << "Template::instructions: " 0253 << t.instructions() << ", "; 0254 dbg.nospace() << "Template::locationinfo: " 0255 << t.locationInfo() << ", "; 0256 dbg.nospace() << "Template::contactinfo: " 0257 << t.contactInfo(); 0258 dbg.nospace() << "Template::IptcSubjects: " 0259 << t.IptcSubjects(); 0260 0261 return dbg.space(); 0262 } 0263 0264 } // namespace Digikam