1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2007-10-24
7  * Description : XMP credits settings page.
8  * Modified    : 2014-04-22 Alan Pater
9  *
10  * Copyright (C) 2007-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
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.
16  *
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.
21  *
22  * ============================================================ */
23 
24 #include "xmpcredits.h"
25 
26 // Qt includes
27 
28 #include <QCheckBox>
29 #include <QGroupBox>
30 #include <QPushButton>
31 #include <QGridLayout>
32 #include <QApplication>
33 #include <QStyle>
34 #include <QLineEdit>
35 
36 // KDE includes
37 
38 #include <klocalizedstring.h>
39 
40 // Local includes
41 
42 #include "multistringsedit.h"
43 
44 namespace DigikamGenericMetadataEditPlugin
45 {
46 
47 class Q_DECL_HIDDEN XMPCredits::Private
48 {
49 public:
50 
Private()51     explicit Private()
52       : syncEXIFArtistCheck(nullptr),
53         creatorTitleCheck  (nullptr),
54         creditCheck        (nullptr),
55         sourceCheck        (nullptr),
56         contactCheck       (nullptr),
57         emailCheck         (nullptr),
58         urlCheck           (nullptr),
59         phoneCheck         (nullptr),
60         addressCheck       (nullptr),
61         postalCodeCheck    (nullptr),
62         cityCheck          (nullptr),
63         regionCheck        (nullptr),
64         countryCheck       (nullptr),
65         creatorTitleEdit   (nullptr),
66         creditEdit         (nullptr),
67         sourceEdit         (nullptr),
68         emailEdit          (nullptr),
69         urlEdit            (nullptr),
70         phoneEdit          (nullptr),
71         addressEdit        (nullptr),
72         postalCodeEdit     (nullptr),
73         cityEdit           (nullptr),
74         regionEdit         (nullptr),
75         countryEdit        (nullptr),
76         creatorEdit        (nullptr)
77     {
78     }
79 
80     QCheckBox*        syncEXIFArtistCheck;
81     QCheckBox*        creatorTitleCheck;
82     QCheckBox*        creditCheck;
83     QCheckBox*        sourceCheck;
84     QCheckBox*        contactCheck;
85     QCheckBox*        emailCheck;
86     QCheckBox*        urlCheck;
87     QCheckBox*        phoneCheck;
88     QCheckBox*        addressCheck;
89     QCheckBox*        postalCodeCheck;
90     QCheckBox*        cityCheck;
91     QCheckBox*        regionCheck;
92     QCheckBox*        countryCheck;
93 
94     QLineEdit*        creatorTitleEdit;
95     QLineEdit*        creditEdit;
96     QLineEdit*        sourceEdit;
97     QLineEdit*        emailEdit;
98     QLineEdit*        urlEdit;
99     QLineEdit*        phoneEdit;
100     QLineEdit*        addressEdit;
101     QLineEdit*        postalCodeEdit;
102     QLineEdit*        cityEdit;
103     QLineEdit*        regionEdit;
104     QLineEdit*        countryEdit;
105 
106     MultiStringsEdit* creatorEdit;
107 };
108 
XMPCredits(QWidget * const parent)109 XMPCredits::XMPCredits(QWidget* const parent)
110     : QWidget(parent),
111       d      (new Private)
112 {
113     const int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
114 
115     QGridLayout* const grid = new QGridLayout(this);
116 
117     // --------------------------------------------------------
118 
119     d->creatorEdit         = new MultiStringsEdit(this, i18nc("@option: name of content creator", "Creator:"),
120                                                   i18n("Set here the name of content creator."));
121     d->syncEXIFArtistCheck = new QCheckBox(i18n("Sync Exif Artist"), this);
122 
123     // --------------------------------------------------------
124 
125     d->creatorTitleCheck = new QCheckBox(i18n("Creator Title:"), this);
126     d->creatorTitleEdit  = new QLineEdit(this);
127     d->creatorTitleEdit->setClearButtonEnabled(true);
128     d->creatorTitleEdit->setWhatsThis(i18n("Set here the title of content creator."));
129 
130     // --------------------------------------------------------
131 
132     QGroupBox* const contactBox = new QGroupBox(i18n("Contact"), this);
133     QGridLayout* const grid2    = new QGridLayout(contactBox);
134 
135     d->emailCheck = new QCheckBox(i18nc("contact email address", "E-mail:"), contactBox);
136     d->emailEdit  = new QLineEdit(contactBox);
137     d->emailEdit->setClearButtonEnabled(true);
138     d->emailEdit->setWhatsThis(i18n("Set here the contact e-mail."));
139 
140     d->urlCheck = new QCheckBox(i18n("URL:"), contactBox);
141     d->urlEdit  = new QLineEdit(contactBox);
142     d->urlEdit->setClearButtonEnabled(true);
143     d->urlEdit->setWhatsThis(i18n("Set here the contact URL."));
144 
145     d->phoneCheck = new QCheckBox(i18n("Phone:"), contactBox);
146     d->phoneEdit  = new QLineEdit(contactBox);
147     d->phoneEdit->setClearButtonEnabled(true);
148     d->phoneEdit->setWhatsThis(i18n("Set here the contact 'phone number."));
149 
150     d->addressCheck = new QCheckBox(i18nc("Street address", "Address:"), contactBox);
151     d->addressEdit  = new QLineEdit(contactBox);
152     d->addressEdit->setClearButtonEnabled(true);
153     d->addressEdit->setWhatsThis(i18n("Set here the contact address."));
154 
155     d->postalCodeCheck = new QCheckBox(i18n("Postal code:"), contactBox);
156     d->postalCodeEdit  = new QLineEdit(contactBox);
157     d->postalCodeEdit->setClearButtonEnabled(true);
158     d->postalCodeEdit->setWhatsThis(i18n("Set here the contact postal code."));
159 
160     d->cityCheck = new QCheckBox(i18n("City:"), contactBox);
161     d->cityEdit  = new QLineEdit(contactBox);
162     d->cityEdit->setClearButtonEnabled(true);
163     d->cityEdit->setWhatsThis(i18n("Set here the contact city."));
164 
165     d->regionCheck = new QCheckBox(i18n("State/Province:"), contactBox);
166     d->regionEdit  = new QLineEdit(contactBox);
167     d->regionEdit->setClearButtonEnabled(true);
168     d->regionEdit->setWhatsThis(i18n("Set here the contact state/province."));
169 
170     d->countryCheck = new QCheckBox(i18n("Country:"), contactBox);
171     d->countryEdit  = new QLineEdit(contactBox);
172     d->countryEdit->setClearButtonEnabled(true);
173     d->countryEdit->setWhatsThis(i18n("Set here the contact country."));
174 
175     grid2->addWidget(d->emailCheck,         0, 0, 1, 1);
176     grid2->addWidget(d->emailEdit,          0, 1, 1, 2);
177     grid2->addWidget(d->urlCheck,           1, 0, 1, 1);
178     grid2->addWidget(d->urlEdit,            1, 1, 1, 2);
179     grid2->addWidget(d->phoneCheck,         2, 0, 1, 1);
180     grid2->addWidget(d->phoneEdit,          2, 1, 1, 2);
181     grid2->addWidget(d->addressCheck,       3, 0, 1, 1);
182     grid2->addWidget(d->addressEdit,        3, 1, 1, 2);
183     grid2->addWidget(d->postalCodeCheck,    4, 0, 1, 1);
184     grid2->addWidget(d->postalCodeEdit,     4, 1, 1, 2);
185     grid2->addWidget(d->cityCheck,          5, 0, 1, 1);
186     grid2->addWidget(d->cityEdit,           5, 1, 1, 2);
187     grid2->addWidget(d->regionCheck,        6, 0, 1, 1);
188     grid2->addWidget(d->regionEdit,         6, 1, 1, 2);
189     grid2->addWidget(d->countryCheck,       7, 0, 1, 1);
190     grid2->addWidget(d->countryEdit,        7, 1, 1, 2);
191     grid2->setColumnStretch(2, 10);
192     grid2->setContentsMargins(spacing, spacing, spacing, spacing);
193     grid2->setSpacing(spacing);
194 
195     // --------------------------------------------------------
196 
197     d->creditCheck = new QCheckBox(i18n("Credit:"), this);
198     d->creditEdit  = new QLineEdit(this);
199     d->creditEdit->setClearButtonEnabled(true);
200     d->creditEdit->setWhatsThis(i18n("Set here the content provider."));
201 
202     // --------------------------------------------------------
203 
204     d->sourceCheck = new QCheckBox(i18nc("original owner of content", "Source:"), this);
205     d->sourceEdit  = new QLineEdit(this);
206     d->sourceEdit->setClearButtonEnabled(true);
207     d->sourceEdit->setWhatsThis(i18n("Set here the original owner of content."));
208 
209     // --------------------------------------------------------
210 
211     grid->addWidget(d->creatorEdit,         0, 0, 1, 3);
212     grid->addWidget(d->syncEXIFArtistCheck, 1, 0, 1, 3);
213     grid->addWidget(d->creatorTitleCheck,   2, 0, 1, 1);
214     grid->addWidget(d->creatorTitleEdit,    2, 1, 1, 2);
215     grid->addWidget(contactBox,             3, 0, 1, 3);
216     grid->addWidget(d->creditCheck,         4, 0, 1, 1);
217     grid->addWidget(d->creditEdit,          4, 1, 1, 2);
218     grid->addWidget(d->sourceCheck,         5, 0, 1, 1);
219     grid->addWidget(d->sourceEdit,          5, 1, 1, 2);
220     grid->setRowStretch(6, 10);
221     grid->setColumnStretch(2, 10);
222     grid->setContentsMargins(QMargins());
223     grid->setSpacing(spacing);
224 
225     // --------------------------------------------------------
226 
227     connect(d->creatorTitleCheck, SIGNAL(toggled(bool)),
228             d->creatorTitleEdit, SLOT(setEnabled(bool)));
229 
230     connect(d->emailCheck, SIGNAL(toggled(bool)),
231             d->emailEdit, SLOT(setEnabled(bool)));
232 
233     connect(d->urlCheck, SIGNAL(toggled(bool)),
234             d->urlEdit, SLOT(setEnabled(bool)));
235 
236     connect(d->phoneCheck, SIGNAL(toggled(bool)),
237             d->phoneEdit, SLOT(setEnabled(bool)));
238 
239     connect(d->addressCheck, SIGNAL(toggled(bool)),
240             d->addressEdit, SLOT(setEnabled(bool)));
241 
242     connect(d->postalCodeCheck, SIGNAL(toggled(bool)),
243             d->postalCodeEdit, SLOT(setEnabled(bool)));
244 
245     connect(d->cityCheck, SIGNAL(toggled(bool)),
246             d->cityEdit, SLOT(setEnabled(bool)));
247 
248     connect(d->regionCheck, SIGNAL(toggled(bool)),
249             d->regionEdit, SLOT(setEnabled(bool)));
250 
251     connect(d->countryCheck, SIGNAL(toggled(bool)),
252             d->countryEdit, SLOT(setEnabled(bool)));
253 
254     connect(d->creditCheck, SIGNAL(toggled(bool)),
255             d->creditEdit, SLOT(setEnabled(bool)));
256 
257     connect(d->sourceCheck, SIGNAL(toggled(bool)),
258             d->sourceEdit, SLOT(setEnabled(bool)));
259 
260     // --------------------------------------------------------
261 
262     connect(d->creatorEdit, SIGNAL(signalModified()),
263             this, SIGNAL(signalModified()));
264 
265     connect(d->creatorTitleCheck, SIGNAL(toggled(bool)),
266             this, SIGNAL(signalModified()));
267 
268     connect(d->emailCheck, SIGNAL(toggled(bool)),
269             this, SIGNAL(signalModified()));
270 
271     connect(d->urlCheck, SIGNAL(toggled(bool)),
272             this, SIGNAL(signalModified()));
273 
274     connect(d->phoneCheck, SIGNAL(toggled(bool)),
275             this, SIGNAL(signalModified()));
276 
277     connect(d->addressCheck, SIGNAL(toggled(bool)),
278             this, SIGNAL(signalModified()));
279 
280     connect(d->postalCodeCheck, SIGNAL(toggled(bool)),
281             this, SIGNAL(signalModified()));
282 
283     connect(d->cityCheck, SIGNAL(toggled(bool)),
284             this, SIGNAL(signalModified()));
285 
286     connect(d->regionCheck, SIGNAL(toggled(bool)),
287             this, SIGNAL(signalModified()));
288 
289     connect(d->countryCheck, SIGNAL(toggled(bool)),
290             this, SIGNAL(signalModified()));
291 
292     connect(d->creditCheck, SIGNAL(toggled(bool)),
293             this, SIGNAL(signalModified()));
294 
295     connect(d->sourceCheck, SIGNAL(toggled(bool)),
296             this, SIGNAL(signalModified()));
297 
298     // --------------------------------------------------------
299 
300     connect(d->creatorTitleEdit, SIGNAL(textChanged(QString)),
301             this, SIGNAL(signalModified()));
302 
303     connect(d->emailEdit, SIGNAL(textChanged(QString)),
304             this, SIGNAL(signalModified()));
305 
306     connect(d->urlEdit, SIGNAL(textChanged(QString)),
307             this, SIGNAL(signalModified()));
308 
309     connect(d->phoneEdit, SIGNAL(textChanged(QString)),
310             this, SIGNAL(signalModified()));
311 
312     connect(d->addressEdit, SIGNAL(textChanged(QString)),
313             this, SIGNAL(signalModified()));
314 
315     connect(d->postalCodeEdit, SIGNAL(textChanged(QString)),
316             this, SIGNAL(signalModified()));
317 
318     connect(d->cityEdit, SIGNAL(textChanged(QString)),
319             this, SIGNAL(signalModified()));
320 
321     connect(d->regionEdit, SIGNAL(textChanged(QString)),
322             this, SIGNAL(signalModified()));
323 
324     connect(d->countryEdit, SIGNAL(textChanged(QString)),
325             this, SIGNAL(signalModified()));
326 
327     connect(d->creditEdit, SIGNAL(textChanged(QString)),
328             this, SIGNAL(signalModified()));
329 
330     connect(d->sourceEdit, SIGNAL(textChanged(QString)),
331             this, SIGNAL(signalModified()));
332 }
333 
~XMPCredits()334 XMPCredits::~XMPCredits()
335 {
336     delete d;
337 }
338 
syncEXIFArtistIsChecked() const339 bool XMPCredits::syncEXIFArtistIsChecked() const
340 {
341     return d->syncEXIFArtistCheck->isChecked();
342 }
343 
setCheckedSyncEXIFArtist(bool c)344 void XMPCredits::setCheckedSyncEXIFArtist(bool c)
345 {
346     d->syncEXIFArtistCheck->setChecked(c);
347 }
348 
getXMPByLine() const349 QString XMPCredits::getXMPByLine() const
350 {
351     QStringList oldv, newv;
352     bool b = d->creatorEdit->getValues(oldv, newv);
353     Q_UNUSED(b);
354 
355     return (newv.join(QLatin1Char(';')));
356 }
357 
readMetadata(const DMetadata & meta)358 void XMPCredits::readMetadata(const DMetadata& meta)
359 {
360     blockSignals(true);
361 
362     QString     data;
363     QStringList list;
364 
365     list = meta.getXmpTagStringSeq("Xmp.dc.creator", false);
366     d->creatorEdit->setValues(list);
367 
368     d->creatorTitleEdit->clear();
369     d->creatorTitleCheck->setChecked(false);
370     data = meta.getXmpTagString("Xmp.photoshop.AuthorsPosition", false);
371 
372     if (!data.isNull())
373     {
374         d->creatorTitleEdit->setText(data);
375         d->creatorTitleCheck->setChecked(true);
376     }
377 
378     d->creatorTitleEdit->setEnabled(d->creatorTitleCheck->isChecked());
379 
380     // --------------------------------------------------------
381 
382     d->emailEdit->clear();
383     d->emailCheck->setChecked(false);
384     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiEmailWork", false);
385 
386     if (data.isNull())
387         data = meta.getXmpTagString("Xmp.iptc.CiEmailWork", false);
388 
389     if (!data.isNull())
390     {
391         d->emailEdit->setText(data);
392         d->emailCheck->setChecked(true);
393     }
394 
395     d->emailEdit->setEnabled(d->emailCheck->isChecked());
396 
397     // --------------------------------------------------------
398 
399     d->urlEdit->clear();
400     d->urlCheck->setChecked(false);
401     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork", false);
402 
403     if (data.isNull())
404         data = meta.getXmpTagString("Xmp.iptc.CiUrlWork", false);
405 
406     if (!data.isNull())
407     {
408         d->urlEdit->setText(data);
409         d->urlCheck->setChecked(true);
410     }
411 
412     d->urlEdit->setEnabled(d->urlCheck->isChecked());
413 
414     // --------------------------------------------------------
415 
416     d->phoneEdit->clear();
417     d->phoneCheck->setChecked(false);
418     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiTelWork", false);
419 
420     if (data.isNull())
421         data = meta.getXmpTagString("Xmp.iptc.CiTelWork", false);
422 
423     if (!data.isNull())
424     {
425         d->phoneEdit->setText(data);
426         d->phoneCheck->setChecked(true);
427     }
428 
429     d->phoneEdit->setEnabled(d->phoneCheck->isChecked());
430 
431     // --------------------------------------------------------
432 
433     d->addressEdit->clear();
434     d->addressCheck->setChecked(false);
435     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrExtadr", false);
436 
437     if (data.isNull())
438         data = meta.getXmpTagString("Xmp.iptc.CiAdrExtadr", false);
439 
440     if (!data.isNull())
441     {
442         d->addressEdit->setText(data);
443         d->addressCheck->setChecked(true);
444     }
445 
446     d->addressEdit->setEnabled(d->addressCheck->isChecked());
447 
448     // --------------------------------------------------------
449 
450     d->postalCodeEdit->clear();
451     d->postalCodeCheck->setChecked(false);
452     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrPcode", false);
453 
454     if (data.isNull())
455         data = meta.getXmpTagString("Xmp.iptc.CiAdrPcode", false);
456 
457     if (!data.isNull())
458     {
459         d->postalCodeEdit->setText(data);
460         d->postalCodeCheck->setChecked(true);
461     }
462 
463     d->postalCodeEdit->setEnabled(d->postalCodeCheck->isChecked());
464 
465     // --------------------------------------------------------
466 
467     d->cityEdit->clear();
468     d->cityCheck->setChecked(false);
469     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity", false);
470 
471     if (data.isNull())
472         data = meta.getXmpTagString("Xmp.iptc.CiAdrCity", false);
473 
474     if (!data.isNull())
475     {
476         d->cityEdit->setText(data);
477         d->cityCheck->setChecked(true);
478     }
479 
480     d->cityEdit->setEnabled(d->cityCheck->isChecked());
481 
482     // --------------------------------------------------------
483 
484     d->regionEdit->clear();
485     d->regionCheck->setChecked(false);
486     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrRegion", false);
487 
488     if (data.isNull())
489     {
490         data = meta.getXmpTagString("Xmp.iptc.CiAdrRegion", false);
491     }
492 
493     if (!data.isNull())
494     {
495         d->regionEdit->setText(data);
496         d->regionCheck->setChecked(true);
497     }
498 
499     d->regionEdit->setEnabled(d->regionCheck->isChecked());
500 
501     // --------------------------------------------------------
502 
503     d->countryEdit->clear();
504     d->countryCheck->setChecked(false);
505     data = meta.getXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry", false);
506 
507     if (data.isNull())
508     {
509         data = meta.getXmpTagString("Xmp.iptc.CiAdrCtry", false);
510     }
511 
512     if (!data.isNull())
513     {
514         d->countryEdit->setText(data);
515         d->countryCheck->setChecked(true);
516     }
517 
518     d->countryEdit->setEnabled(d->countryCheck->isChecked());
519 
520     // --------------------------------------------------------
521 
522     d->creditEdit->clear();
523     d->creditCheck->setChecked(false);
524     data = meta.getXmpTagString("Xmp.photoshop.Credit", false);
525 
526     if (!data.isNull())
527     {
528         d->creditEdit->setText(data);
529         d->creditCheck->setChecked(true);
530     }
531 
532     d->creditEdit->setEnabled(d->creditCheck->isChecked());
533 
534     // --------------------------------------------------------
535 
536     d->sourceEdit->clear();
537     d->sourceCheck->setChecked(false);
538     data = meta.getXmpTagString("Xmp.photoshop.Source", false);
539 
540     if (data.isNull())
541     {
542         data = meta.getXmpTagString("Xmp.dc.source", false);
543     }
544 
545     if (!data.isNull())
546     {
547         d->sourceEdit->setText(data);
548         d->sourceCheck->setChecked(true);
549     }
550 
551     d->sourceEdit->setEnabled(d->sourceCheck->isChecked());
552 
553     blockSignals(false);
554 }
555 
applyMetadata(const DMetadata & meta)556 void XMPCredits::applyMetadata(const DMetadata& meta)
557 {
558     QStringList oldList, newList;
559 
560     if (d->creatorEdit->getValues(oldList, newList))
561     {
562         meta.setXmpTagStringSeq("Xmp.dc.creator", newList);
563 
564         if (syncEXIFArtistIsChecked())
565         {
566             meta.removeExifTag("Exif.Image.Artist");
567             meta.setExifTagString("Exif.Image.Artist", getXMPByLine());
568         }
569     }
570     else
571     {
572         meta.removeXmpTag("Xmp.dc.creator");
573     }
574 
575     if (d->creatorTitleCheck->isChecked())
576     {
577         meta.setXmpTagString("Xmp.photoshop.AuthorsPosition", d->creatorTitleEdit->text());
578     }
579     else
580     {
581         meta.removeXmpTag("Xmp.photoshop.AuthorsPosition");
582     }
583 
584     // --------------------------------------------------------
585 
586     if (d->emailCheck->isChecked())
587     {
588         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiEmailWork", d->emailEdit->text());
589         meta.removeXmpTag("Xmp.iptc.CiEmailWork");
590     }
591     else
592     {
593         meta.removeXmpTag("Xmp.iptc.CiEmailWork");
594         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiEmailWork");
595     }
596 
597     if (d->urlCheck->isChecked())
598     {
599         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork", d->urlEdit->text());
600         meta.removeXmpTag("Xmp.iptc.CiUrlWork");
601     }
602     else
603     {
604         meta.removeXmpTag("Xmp.iptc.CiUrlWork");
605         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork");
606     }
607 
608     if (d->phoneCheck->isChecked())
609     {
610         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiTelWork", d->phoneEdit->text());
611         meta.removeXmpTag("Xmp.iptc.CiTelWork");
612     }
613     else
614     {
615         meta.removeXmpTag("Xmp.iptc.CiTelWork");
616         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiTelWork");
617     }
618 
619     if (d->addressCheck->isChecked())
620     {
621         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrExtadr", d->addressEdit->text());
622         meta.removeXmpTag("Xmp.iptc.CiAdrExtadr");
623     }
624     else
625     {
626         meta.removeXmpTag("Xmp.iptc.CiAdrExtadr");
627         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrExtadr");
628     }
629 
630     if (d->postalCodeCheck->isChecked())
631     {
632         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrPcode", d->postalCodeEdit->text());
633         meta.removeXmpTag("Xmp.iptc.CiAdrPcode");
634     }
635     else
636     {
637         meta.removeXmpTag("Xmp.iptc.CiAdrPcode");
638         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrPcode");
639     }
640 
641     if (d->cityCheck->isChecked())
642     {
643         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity", d->cityEdit->text());
644         meta.removeXmpTag("Xmp.iptc.CiAdrCity");
645     }
646     else
647     {
648         meta.removeXmpTag("Xmp.iptc.CiAdrCity");
649         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity");
650     }
651 
652     if (d->regionCheck->isChecked())
653     {
654         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrRegion", d->regionEdit->text());
655         meta.removeXmpTag("Xmp.iptc.CiAdrRegion");
656     }
657     else
658     {
659         meta.removeXmpTag("Xmp.iptc.CiAdrRegion");
660         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrRegion");
661     }
662 
663     if (d->countryCheck->isChecked())
664     {
665         meta.setXmpTagString("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry", d->countryEdit->text());
666         meta.removeXmpTag("Xmp.iptc.CiAdrCtry");
667     }
668     else
669     {
670         meta.removeXmpTag("Xmp.iptc.CiAdrCtry");
671         meta.removeXmpTag("Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry");
672     }
673 
674     // --------------------------------------------------------
675 
676     if (d->creditCheck->isChecked())
677     {
678         meta.setXmpTagString("Xmp.photoshop.Credit", d->creditEdit->text());
679     }
680     else
681     {
682         meta.removeXmpTag("Xmp.photoshop.Credit");
683     }
684 
685     if (d->sourceCheck->isChecked())
686     {
687         meta.setXmpTagString("Xmp.photoshop.Source", d->sourceEdit->text());
688         meta.setXmpTagString("Xmp.dc.source", d->sourceEdit->text());
689     }
690     else
691     {
692         meta.removeXmpTag("Xmp.photoshop.Source");
693         meta.removeXmpTag("Xmp.dc.source");
694     }
695 }
696 
697 } // namespace DigikamGenericMetadataEditPlugin
698