1
/* ============================================================
3
* This file is a part of kipi-plugins project
4
* http://www.kipi-plugins.org
7
* Description : XMP subjects settings page.
9
* Copyright (C) 2006-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
* Copyright (C) 2009 by Andi Clemens <andi dot clemens at gmx dot net>
12
* This program is free software; you can redistribute it
13
* and/or modify it under the terms of the GNU General
14
* Public License as published by the Free Software Foundation;
15
* either version 2, or (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#include "xmpsubjects.moc"
36
#include <libkexiv2/kexiv2.h>
38
namespace KIPIMetadataEditPlugin
41
XMPSubjects::XMPSubjects(QWidget* parent)
42
: SubjectWidget(parent)
44
// Subject string do not accept these characters:
48
QRegExp subjectRx("[^*:?]+$");
49
QValidator* subjectValidator = new QRegExpValidator(subjectRx, this);
51
// --------------------------------------------------------
53
m_iprEdit->setText(QString("XMP"));
54
m_iprEdit->setValidator(subjectValidator);
55
m_iprEdit->setWhatsThis(i18n("Enter here the Informative Provider Reference. "
56
"I.P.R is a name registered with the XMP/NAA, identifying the "
57
"provider that provides an indicator of the content. "
58
"The default value for the I.P.R is \"XMP\" if a standard Reference "
61
m_refEdit->setWhatsThis(i18n("Enter here the Subject Reference Number. "
62
"Provides a numeric code to indicate the Subject Name plus "
63
"optional Subject Matter and Subject Detail Names in the "
64
"language of the service. Subject Reference is a number "
65
"from the range 01000000 to 17999999 and represent a "
66
"language independent international reference to "
67
"a Subject. A Subject is identified by its Reference Number "
68
"and corresponding Names taken from a standard lists given "
69
"by XMP/NAA. If a standard reference code is used, these lists "
70
"are the English language reference versions. "
71
"This field is limited to 8 digit code."));
73
m_nameEdit->setValidator(subjectValidator);
74
m_nameEdit->setWhatsThis(i18n("Enter here the Subject Name. English language is used "
75
"if you selected a standard XMP/NAA reference code."));
77
m_matterEdit->setValidator(subjectValidator);
78
m_matterEdit->setWhatsThis(i18n("Enter here the Subject Matter Name. English language is used "
79
"if you selected a standard XMP/NAA reference code."));
81
m_detailEdit->setValidator(subjectValidator);
82
m_detailEdit->setWhatsThis(i18n("Enter here the Subject Detail Name. English language is used "
83
"if you selected a standard XMP/NAA reference code."));
85
// reset the note label, not used in XMP view
88
m_subjectsCheck->setVisible(true);
91
XMPSubjects::~XMPSubjects()
95
void XMPSubjects::readMetadata(QByteArray& xmpData)
98
exiv2Iface.setXmp(xmpData);
99
setSubjectsList(exiv2Iface.getXmpSubjects());
102
void XMPSubjects::applyMetadata(QByteArray& xmpData)
105
exiv2Iface.setXmp(xmpData);
106
QStringList newSubjects = subjectsList();
108
// We remove in first all existing subjects.
109
exiv2Iface.removeXmpTag("Xmp.iptc.SubjectCode");
111
// And add new list if necessary.
112
if (m_subjectsCheck->isChecked())
113
exiv2Iface.setXmpSubjects(newSubjects);
115
xmpData = exiv2Iface.getXmp();
118
} // namespace KIPIMetadataEditPlugin