File indexing completed on 2025-01-19 03:51:26
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-10-15 0007 * Description : XMP subjects settings page. 0008 * 0009 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2009 by Andi Clemens <andi dot clemens at googlemail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "xmpsubjects.h" 0017 0018 // Qt includes 0019 0020 #include <QValidator> 0021 0022 // KDE includes 0023 0024 #include <klocalizedstring.h> 0025 0026 namespace DigikamGenericMetadataEditPlugin 0027 { 0028 0029 XMPSubjects::XMPSubjects(QWidget* const parent) 0030 : SubjectWidget(parent) 0031 { 0032 m_iprDefault = QLatin1String("XMP"); 0033 0034 // Subject string do not accept these characters: 0035 // - '*' (\x2A) 0036 // - ':' (\x3A) 0037 // - '?' (\x3F) 0038 0039 QRegularExpression subjectRx(QLatin1String("[^*:?]+$")); 0040 QValidator* const subjectValidator = new QRegularExpressionValidator(subjectRx, this); 0041 0042 // -------------------------------------------------------- 0043 0044 m_iprEdit->setText(m_iprDefault); 0045 m_iprEdit->setValidator(subjectValidator); 0046 m_iprEdit->setWhatsThis(i18n("Enter here the Informative Provider Reference. " 0047 "I.P.R is a name registered with the XMP/NAA, identifying the " 0048 "provider that provides an indicator of the content. " 0049 "The default value for the I.P.R is \"XMP\" if a standard Reference " 0050 "Code is used.")); 0051 0052 m_refEdit->setWhatsThis(i18n("Enter here the Subject Reference Number. " 0053 "Provides a numeric code to indicate the Subject Name plus " 0054 "optional Subject Matter and Subject Detail Names in the " 0055 "language of the service. Subject Reference is a number " 0056 "from the range 01000000 to 17999999 and represent a " 0057 "language independent international reference to " 0058 "a Subject. A Subject is identified by its Reference Number " 0059 "and corresponding Names taken from a standard lists given " 0060 "by XMP/NAA. If a standard reference code is used, these lists " 0061 "are the English language reference versions. " 0062 "This field is limited to 8 digit code.")); 0063 0064 m_nameEdit->setIgnoredCharacters(QLatin1String("*:?")); 0065 m_nameEdit->setWhatsThis(i18n("Enter here the Subject Name. English language is used " 0066 "if you selected a standard XMP/NAA reference code.")); 0067 0068 m_matterEdit->setIgnoredCharacters(QLatin1String("*:?")); 0069 m_matterEdit->setWhatsThis(i18n("Enter here the Subject Matter Name. English language is used " 0070 "if you selected a standard XMP/NAA reference code.")); 0071 0072 m_detailEdit->setIgnoredCharacters(QLatin1String("*:?")); 0073 m_detailEdit->setWhatsThis(i18n("Enter here the Subject Detail Name. English language is used " 0074 "if you selected a standard XMP/NAA reference code.")); 0075 0076 // reset the note label, not used in XMP view 0077 0078 delete m_note; 0079 0080 m_subjectsCheck->setVisible(true); 0081 m_subjectsCheck->setEnabled(true); 0082 } 0083 0084 XMPSubjects::~XMPSubjects() 0085 { 0086 } 0087 0088 void XMPSubjects::readMetadata(const DMetadata& meta) 0089 { 0090 setSubjectsList(meta.getXmpSubjects()); 0091 } 0092 0093 void XMPSubjects::applyMetadata(const DMetadata& meta) 0094 { 0095 QStringList newSubjects = subjectsList(); 0096 0097 // We remove in first all existing subjects. 0098 0099 meta.removeXmpTag("Xmp.iptc.SubjectCode"); 0100 0101 // And add new list if necessary. 0102 0103 if (m_subjectsCheck->isChecked()) 0104 { 0105 meta.setXmpSubjects(newSubjects); 0106 } 0107 } 0108 0109 } // namespace DigikamGenericMetadataEditPlugin 0110 0111 #include "moc_xmpsubjects.cpp"