File indexing completed on 2025-01-19 03:51:25

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-10-24
0007  * Description : XMP origin settings page.
0008  *
0009  * SPDX-FileCopyrightText: 2007-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 "xmporigin.h"
0016 
0017 // Qt includes
0018 
0019 #include <QCheckBox>
0020 #include <QMap>
0021 #include <QPushButton>
0022 #include <QGridLayout>
0023 #include <QApplication>
0024 #include <QStyle>
0025 #include <QComboBox>
0026 #include <QDateTimeEdit>
0027 #include <QLineEdit>
0028 
0029 // KDE includes
0030 
0031 #include <klocalizedstring.h>
0032 
0033 // Local includes
0034 
0035 #include "squeezedcombobox.h"
0036 #include "dlayoutbox.h"
0037 #include "metadatacheckbox.h"
0038 #include "timezonecombobox.h"
0039 #include "countryselector.h"
0040 #include "dexpanderbox.h"
0041 
0042 namespace DigikamGenericMetadataEditPlugin
0043 {
0044 
0045 class Q_DECL_HIDDEN XMPOrigin::Private
0046 {
0047 public:
0048 
0049     explicit Private()
0050       : dateCreatedCheck      (nullptr),
0051         dateDigitalizedCheck  (nullptr),
0052         dateVideoCheck        (nullptr),
0053         syncEXIFDateCheck     (nullptr),
0054         cityCheck             (nullptr),
0055         sublocationCheck      (nullptr),
0056         provinceCheck         (nullptr),
0057         setTodayCreatedBtn    (nullptr),
0058         setTodayDigitalizedBtn(nullptr),
0059         setTodayVideoBtn      (nullptr),
0060         dateCreatedSel        (nullptr),
0061         dateDigitalizedSel    (nullptr),
0062         dateVideoSel          (nullptr),
0063         zoneCreatedSel        (nullptr),
0064         zoneDigitalizedSel    (nullptr),
0065         zoneVideoSel          (nullptr),
0066         cityEdit              (nullptr),
0067         sublocationEdit       (nullptr),
0068         provinceEdit          (nullptr),
0069         countryCheck          (nullptr),
0070         countryCB             (nullptr)
0071     {
0072     }
0073 
0074     QCheckBox*                     dateCreatedCheck;
0075     QCheckBox*                     dateDigitalizedCheck;
0076     QCheckBox*                     dateVideoCheck;
0077     QCheckBox*                     syncEXIFDateCheck;
0078     QCheckBox*                     cityCheck;
0079     QCheckBox*                     sublocationCheck;
0080     QCheckBox*                     provinceCheck;
0081 
0082     QPushButton*                   setTodayCreatedBtn;
0083     QPushButton*                   setTodayDigitalizedBtn;
0084     QPushButton*                   setTodayVideoBtn;
0085 
0086     QDateTimeEdit*                 dateCreatedSel;
0087     QDateTimeEdit*                 dateDigitalizedSel;
0088     QDateTimeEdit*                 dateVideoSel;
0089 
0090     TimeZoneComboBox*              zoneCreatedSel;
0091     TimeZoneComboBox*              zoneDigitalizedSel;
0092     TimeZoneComboBox*              zoneVideoSel;
0093 
0094     QLineEdit*                     cityEdit;
0095     QLineEdit*                     sublocationEdit;
0096     QLineEdit*                     provinceEdit;
0097 
0098     MetadataCheckBox*              countryCheck;
0099 
0100     CountrySelector*               countryCB;
0101 };
0102 
0103 XMPOrigin::XMPOrigin(QWidget* const parent)
0104     : MetadataEditPage(parent),
0105       d               (new Private)
0106 {
0107     QGridLayout* const grid = new QGridLayout(widget());
0108 
0109     QString dateTimeFormat  = QLocale().dateTimeFormat(QLocale::ShortFormat);
0110 
0111     if (!dateTimeFormat.contains(QLatin1String("yyyy")))
0112     {
0113         dateTimeFormat.replace(QLatin1String("yy"),
0114                                QLatin1String("yyyy"));
0115     }
0116 
0117     if (!dateTimeFormat.contains(QLatin1String("ss")))
0118     {
0119         dateTimeFormat.replace(QLatin1String("mm"),
0120                                QLatin1String("mm:ss"));
0121     }
0122 
0123     // --------------------------------------------------------
0124 
0125     d->dateDigitalizedCheck   = new QCheckBox(i18n("Digitization date"), this);
0126     d->zoneDigitalizedSel     = new TimeZoneComboBox(this);
0127 
0128     d->dateDigitalizedSel     = new QDateTimeEdit(this);
0129     d->dateDigitalizedSel->setDisplayFormat(dateTimeFormat);
0130 
0131     d->setTodayDigitalizedBtn = new QPushButton();
0132     d->setTodayDigitalizedBtn->setIcon(QIcon::fromTheme(QLatin1String("view-calendar")));
0133     d->setTodayDigitalizedBtn->setWhatsThis(i18n("Set digitization date to today"));
0134 
0135     d->dateDigitalizedSel->setWhatsThis(i18n("Set here the creation date of "
0136                                              "digital representation."));
0137     d->zoneDigitalizedSel->setWhatsThis(i18n("Set here the time zone of "
0138                                              "digital representation."));
0139 
0140     slotSetTodayDigitalized();
0141 
0142     // --------------------------------------------------------
0143 
0144     d->dateCreatedCheck   = new QCheckBox(i18n("Creation date"), this);
0145     d->zoneCreatedSel     = new TimeZoneComboBox(this);
0146 
0147     d->dateCreatedSel     = new QDateTimeEdit(this);
0148     d->dateCreatedSel->setDisplayFormat(dateTimeFormat);
0149 
0150     d->syncEXIFDateCheck  = new QCheckBox(i18n("Sync Exif creation date"), this);
0151 
0152     d->setTodayCreatedBtn = new QPushButton();
0153     d->setTodayCreatedBtn->setIcon(QIcon::fromTheme(QLatin1String("view-calendar")));
0154     d->setTodayCreatedBtn->setWhatsThis(i18n("Set creation date to today"));
0155 
0156     d->dateCreatedSel->setWhatsThis(i18n("Set here the creation date of "
0157                                          "intellectual content."));
0158     d->zoneCreatedSel->setWhatsThis(i18n("Set here the time zone of "
0159                                          "intellectual content."));
0160 
0161     slotSetTodayCreated();
0162 
0163     // --------------------------------------------------------
0164 
0165     d->dateVideoCheck   = new QCheckBox(i18n("Video date"), this);
0166     d->zoneVideoSel     = new TimeZoneComboBox(this);
0167 
0168     d->dateVideoSel     = new QDateTimeEdit(this);
0169     d->dateVideoSel->setDisplayFormat(dateTimeFormat);
0170 
0171     d->setTodayVideoBtn = new QPushButton();
0172     d->setTodayVideoBtn->setIcon(QIcon::fromTheme(QLatin1String("view-calendar")));
0173     d->setTodayVideoBtn->setWhatsThis(i18n("Set video date to today"));
0174 
0175     d->dateVideoSel->setWhatsThis(i18n("Set here the video date of "
0176                                        "intellectual content."));
0177     d->zoneVideoSel->setWhatsThis(i18n("Set here the time zone of "
0178                                        "intellectual content."));
0179 
0180     slotSetTodayVideo();
0181 
0182     // --------------------------------------------------------
0183 
0184     d->cityCheck = new QCheckBox(i18n("City:"), this);
0185     d->cityEdit  = new QLineEdit(this);
0186     d->cityEdit->setClearButtonEnabled(true);
0187     d->cityEdit->setPlaceholderText(i18n("Set here the content's city of origin."));
0188 
0189     // --------------------------------------------------------
0190 
0191     d->sublocationCheck = new QCheckBox(i18n("Sublocation:"), this);
0192     d->sublocationEdit  = new QLineEdit(this);
0193     d->sublocationEdit->setClearButtonEnabled(true);
0194     d->sublocationEdit->setPlaceholderText(i18n("Set here the content's location within the city."));
0195 
0196     // --------------------------------------------------------
0197 
0198     d->provinceCheck = new QCheckBox(i18n("State/Province:"), this);
0199     d->provinceEdit  = new QLineEdit(this);
0200     d->provinceEdit->setClearButtonEnabled(true);
0201     d->provinceEdit->setPlaceholderText(i18n("Set here the content's Province or State of origin."));
0202 
0203     // --------------------------------------------------------
0204 
0205     d->countryCheck = new MetadataCheckBox(i18n("Country:"), this);
0206     d->countryCB    = new CountrySelector(this);
0207     d->countryCB->setWhatsThis(i18n("Select here country name of content origin."));
0208 
0209     // Remove 2 last items for the list (separator + Unknown item)
0210 
0211     d->countryCB->removeItem(d->countryCB->count()-1);
0212     d->countryCB->removeItem(d->countryCB->count()-1);
0213 
0214     // --------------------------------------------------------
0215 
0216     grid->addWidget(d->dateDigitalizedCheck,                0, 0, 1, 6);
0217     grid->addWidget(d->dateDigitalizedSel,                  1, 0, 1, 3);
0218     grid->addWidget(d->zoneDigitalizedSel,                  1, 3, 1, 1);
0219     grid->addWidget(d->setTodayDigitalizedBtn,              1, 5, 1, 1);
0220     grid->addWidget(d->dateCreatedCheck,                    2, 0, 1, 6);
0221     grid->addWidget(d->dateCreatedSel,                      3, 0, 1, 3);
0222     grid->addWidget(d->zoneCreatedSel,                      3, 3, 1, 1);
0223     grid->addWidget(d->setTodayCreatedBtn,                  3, 5, 1, 1);
0224     grid->addWidget(d->syncEXIFDateCheck,                   4, 0, 1, 6);
0225     grid->addWidget(new DLineWidget(Qt::Horizontal, this),  5, 0, 1, 6);
0226     grid->addWidget(d->dateVideoCheck,                      6, 0, 1, 6);
0227     grid->addWidget(d->dateVideoSel,                        7, 0, 1, 3);
0228     grid->addWidget(d->zoneVideoSel,                        7, 3, 1, 1);
0229     grid->addWidget(d->setTodayVideoBtn,                    7, 5, 1, 1);
0230     grid->addWidget(new DLineWidget(Qt::Horizontal, this),  8, 0, 1, 6);
0231     grid->addWidget(d->cityCheck,                           9, 0, 1, 1);
0232     grid->addWidget(d->cityEdit,                            9, 1, 1, 5);
0233     grid->addWidget(d->sublocationCheck,                   10, 0, 1, 1);
0234     grid->addWidget(d->sublocationEdit,                    10, 1, 1, 5);
0235     grid->addWidget(d->provinceCheck,                      11, 0, 1, 1);
0236     grid->addWidget(d->provinceEdit,                       11, 1, 1, 5);
0237     grid->addWidget(d->countryCheck,                       12, 0, 1, 1);
0238     grid->addWidget(d->countryCB,                          12, 1, 1, 5);
0239     grid->setColumnStretch(4, 10);
0240     grid->setRowStretch(13, 10);
0241 
0242     int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0243                        QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0244 
0245     grid->setContentsMargins(spacing, spacing, spacing, spacing);
0246     grid->setSpacing(spacing);
0247 
0248     // --------------------------------------------------------
0249 
0250     connect(d->dateCreatedCheck, SIGNAL(toggled(bool)),
0251             d->dateCreatedSel, SLOT(setEnabled(bool)));
0252 
0253     connect(d->dateDigitalizedCheck, SIGNAL(toggled(bool)),
0254             d->dateDigitalizedSel, SLOT(setEnabled(bool)));
0255 
0256     connect(d->dateVideoCheck, SIGNAL(toggled(bool)),
0257             d->dateVideoSel, SLOT(setEnabled(bool)));
0258 
0259     connect(d->dateCreatedCheck, SIGNAL(toggled(bool)),
0260             d->zoneCreatedSel, SLOT(setEnabled(bool)));
0261 
0262     connect(d->dateDigitalizedCheck, SIGNAL(toggled(bool)),
0263             d->zoneDigitalizedSel, SLOT(setEnabled(bool)));
0264 
0265     connect(d->dateVideoCheck, SIGNAL(toggled(bool)),
0266             d->zoneVideoSel, SLOT(setEnabled(bool)));
0267 
0268     connect(d->dateCreatedCheck, SIGNAL(toggled(bool)),
0269             d->syncEXIFDateCheck, SLOT(setEnabled(bool)));
0270 
0271     connect(d->cityCheck, SIGNAL(toggled(bool)),
0272             d->cityEdit, SLOT(setEnabled(bool)));
0273 
0274     connect(d->sublocationCheck, SIGNAL(toggled(bool)),
0275             d->sublocationEdit, SLOT(setEnabled(bool)));
0276 
0277     connect(d->provinceCheck, SIGNAL(toggled(bool)),
0278             d->provinceEdit, SLOT(setEnabled(bool)));
0279 
0280     connect(d->countryCheck, SIGNAL(toggled(bool)),
0281             d->countryCB, SLOT(setEnabled(bool)));
0282 
0283     // --------------------------------------------------------
0284 
0285     connect(d->dateCreatedCheck, SIGNAL(toggled(bool)),
0286             this, SIGNAL(signalModified()));
0287 
0288     connect(d->dateDigitalizedCheck, SIGNAL(toggled(bool)),
0289             this, SIGNAL(signalModified()));
0290 
0291     connect(d->dateVideoCheck, SIGNAL(toggled(bool)),
0292             this, SIGNAL(signalModified()));
0293 
0294     connect(d->cityCheck, SIGNAL(toggled(bool)),
0295             this, SIGNAL(signalModified()));
0296 
0297     connect(d->sublocationCheck, SIGNAL(toggled(bool)),
0298             this, SIGNAL(signalModified()));
0299 
0300     connect(d->provinceCheck, SIGNAL(toggled(bool)),
0301             this, SIGNAL(signalModified()));
0302 
0303     connect(d->countryCheck, SIGNAL(toggled(bool)),
0304             this, SIGNAL(signalModified()));
0305 
0306     // --------------------------------------------------------
0307 
0308     connect(d->dateCreatedSel, SIGNAL(dateTimeChanged(QDateTime)),
0309             this, SIGNAL(signalModified()));
0310 
0311     connect(d->dateDigitalizedSel, SIGNAL(dateTimeChanged(QDateTime)),
0312             this, SIGNAL(signalModified()));
0313 
0314     connect(d->dateVideoSel, SIGNAL(dateTimeChanged(QDateTime)),
0315             this, SIGNAL(signalModified()));
0316 
0317     connect(d->zoneCreatedSel, SIGNAL(currentTextChanged(QString)),
0318             this, SIGNAL(signalModified()));
0319 
0320     connect(d->zoneDigitalizedSel, SIGNAL(currentTextChanged(QString)),
0321             this, SIGNAL(signalModified()));
0322 
0323     connect(d->zoneVideoSel, SIGNAL(currentTextChanged(QString)),
0324             this, SIGNAL(signalModified()));
0325 
0326     // --------------------------------------------------------
0327 
0328     connect(d->setTodayCreatedBtn, SIGNAL(clicked()),
0329             this, SLOT(slotSetTodayCreated()));
0330 
0331     connect(d->setTodayDigitalizedBtn, SIGNAL(clicked()),
0332             this, SLOT(slotSetTodayDigitalized()));
0333 
0334     connect(d->setTodayVideoBtn, SIGNAL(clicked()),
0335             this, SLOT(slotSetTodayVideo()));
0336 
0337     // --------------------------------------------------------
0338 
0339     connect(d->countryCB, SIGNAL(activated(int)),
0340             this, SIGNAL(signalModified()));
0341 
0342     connect(d->cityEdit, SIGNAL(textChanged(QString)),
0343             this, SIGNAL(signalModified()));
0344 
0345     connect(d->sublocationEdit, SIGNAL(textChanged(QString)),
0346             this, SIGNAL(signalModified()));
0347 
0348     connect(d->provinceEdit, SIGNAL(textChanged(QString)),
0349             this, SIGNAL(signalModified()));
0350 }
0351 
0352 XMPOrigin::~XMPOrigin()
0353 {
0354     delete d;
0355 }
0356 
0357 void XMPOrigin::slotSetTodayVideo()
0358 {
0359     d->dateVideoSel->setDateTime(QDateTime::currentDateTime());
0360     d->zoneVideoSel->setToUTC();
0361 }
0362 
0363 void XMPOrigin::slotSetTodayCreated()
0364 {
0365     d->dateCreatedSel->setDateTime(QDateTime::currentDateTime());
0366     d->zoneCreatedSel->setToUTC();
0367 }
0368 
0369 void XMPOrigin::slotSetTodayDigitalized()
0370 {
0371     d->dateDigitalizedSel->setDateTime(QDateTime::currentDateTime());
0372     d->zoneDigitalizedSel->setToUTC();
0373 }
0374 
0375 bool XMPOrigin::syncEXIFDateIsChecked() const
0376 {
0377     return d->syncEXIFDateCheck->isChecked();
0378 }
0379 
0380 void XMPOrigin::setCheckedSyncEXIFDate(bool c)
0381 {
0382     d->syncEXIFDateCheck->setChecked(c);
0383 }
0384 
0385 QDateTime XMPOrigin::getXMPCreationDate() const
0386 {
0387     return d->dateCreatedSel->dateTime();
0388 }
0389 
0390 void XMPOrigin::readMetadata(const DMetadata& meta)
0391 {
0392     blockSignals(true);
0393 
0394     QString     data;
0395     QStringList code, list;
0396     QDateTime   dateTime;
0397     QString     dateTimeStr;
0398 
0399     dateTimeStr = meta.getXmpTagString("Xmp.photoshop.DateCreated", false);
0400 
0401     if (dateTimeStr.isEmpty())
0402     {
0403         dateTimeStr = meta.getXmpTagString("Xmp.xmp.CreateDate", false);
0404     }
0405 
0406     if (dateTimeStr.isEmpty())
0407     {
0408         dateTimeStr = meta.getXmpTagString("Xmp.xmp.ModifyDate", false);
0409     }
0410 
0411     if (dateTimeStr.isEmpty())
0412     {
0413         dateTimeStr = meta.getXmpTagString("Xmp.exif.DateTimeOriginal", false);
0414     }
0415 
0416     if (dateTimeStr.isEmpty())
0417     {
0418         dateTimeStr = meta.getXmpTagString("Xmp.tiff.DateTime", false);
0419     }
0420 
0421     if (dateTimeStr.isEmpty())
0422     {
0423         dateTimeStr = meta.getXmpTagString("Xmp.xmp.ModifyDate", false);
0424     }
0425 
0426     if (dateTimeStr.isEmpty())
0427     {
0428         dateTimeStr = meta.getXmpTagString("Xmp.xmp.MetadataDate", false);
0429     }
0430 
0431     d->dateCreatedSel->setDateTime(QDateTime::currentDateTime());
0432     d->dateCreatedCheck->setChecked(false);
0433     d->zoneCreatedSel->setToUTC();
0434 
0435     if (!dateTimeStr.isEmpty())
0436     {
0437         dateTime = QDateTime::fromString(dateTimeStr, Qt::ISODate);
0438 
0439         if (dateTime.isValid())
0440         {
0441             d->dateCreatedSel->setDateTime(dateTime);
0442             d->dateCreatedCheck->setChecked(true);
0443             d->zoneCreatedSel->setTimeZone(dateTimeStr);
0444         }
0445     }
0446 
0447     d->dateCreatedSel->setEnabled(d->dateCreatedCheck->isChecked());
0448     d->zoneCreatedSel->setEnabled(d->dateCreatedCheck->isChecked());
0449     d->syncEXIFDateCheck->setEnabled(d->dateCreatedCheck->isChecked());
0450 
0451     dateTimeStr = meta.getXmpTagString("Xmp.exif.DateTimeDigitized", false);
0452 
0453     d->dateDigitalizedSel->setDateTime(QDateTime::currentDateTime());
0454     d->dateDigitalizedCheck->setChecked(false);
0455     d->zoneDigitalizedSel->setToUTC();
0456 
0457     if (!dateTimeStr.isEmpty())
0458     {
0459         dateTime = QDateTime::fromString(dateTimeStr, Qt::ISODate);
0460 
0461         if (dateTime.isValid())
0462         {
0463             d->dateDigitalizedSel->setDateTime(dateTime);
0464             d->dateDigitalizedCheck->setChecked(true);
0465             d->zoneDigitalizedSel->setTimeZone(dateTimeStr);
0466         }
0467     }
0468 
0469     d->dateDigitalizedSel->setEnabled(d->dateDigitalizedCheck->isChecked());
0470     d->zoneDigitalizedSel->setEnabled(d->dateDigitalizedCheck->isChecked());
0471 
0472     dateTimeStr = meta.getXmpTagString("Xmp.video.DateTimeOriginal", false);
0473 
0474     if (dateTimeStr.isEmpty())
0475     {
0476         dateTimeStr = meta.getXmpTagString("Xmp.video.DateTimeDigitized", false);
0477     }
0478 
0479     if (dateTimeStr.isEmpty())
0480     {
0481         dateTimeStr = meta.getXmpTagString("Xmp.video.ModificationDate", false);
0482     }
0483 
0484     if (dateTimeStr.isEmpty())
0485     {
0486         dateTimeStr = meta.getXmpTagString("Xmp.video.DateUTC", false);
0487     }
0488 
0489     d->dateVideoSel->setDateTime(QDateTime::currentDateTime());
0490     d->dateVideoCheck->setChecked(false);
0491     d->zoneVideoSel->setToUTC();
0492 
0493     if (!dateTimeStr.isEmpty())
0494     {
0495         dateTime = QDateTime::fromString(dateTimeStr, Qt::ISODate);
0496 
0497         if (dateTime.isValid())
0498         {
0499             d->dateVideoSel->setDateTime(dateTime);
0500             d->dateVideoCheck->setChecked(true);
0501             d->zoneVideoSel->setTimeZone(dateTimeStr);
0502         }
0503     }
0504 
0505     d->dateVideoSel->setEnabled(d->dateVideoCheck->isChecked());
0506     d->zoneVideoSel->setEnabled(d->dateVideoCheck->isChecked());
0507 
0508     d->cityEdit->clear();
0509     d->cityCheck->setChecked(false);
0510     data = meta.getXmpTagString("Xmp.photoshop.City", false);
0511 
0512     if (!data.isNull())
0513     {
0514         d->cityEdit->setText(data);
0515         d->cityCheck->setChecked(true);
0516     }
0517 
0518     d->cityEdit->setEnabled(d->cityCheck->isChecked());
0519 
0520     d->sublocationEdit->clear();
0521     d->sublocationCheck->setChecked(false);
0522     data = meta.getXmpTagString("Xmp.iptc.Location", false);
0523 
0524     if (!data.isNull())
0525     {
0526         d->sublocationEdit->setText(data);
0527         d->sublocationCheck->setChecked(true);
0528     }
0529 
0530     d->sublocationEdit->setEnabled(d->sublocationCheck->isChecked());
0531 
0532     d->provinceEdit->clear();
0533     d->provinceCheck->setChecked(false);
0534     data = meta.getXmpTagString("Xmp.photoshop.State", false);
0535 
0536     if (!data.isNull())
0537     {
0538         d->provinceEdit->setText(data);
0539         d->provinceCheck->setChecked(true);
0540     }
0541 
0542     d->provinceEdit->setEnabled(d->provinceCheck->isChecked());
0543 
0544     d->countryCB->setCurrentIndex(0);
0545     d->countryCheck->setChecked(false);
0546     data = meta.getXmpTagString("Xmp.iptc.CountryCode", false);
0547 
0548     if (!data.isNull())
0549     {
0550         int item = -1;
0551 
0552         for (int i = 0 ; i < d->countryCB->count() ; ++i)
0553         {
0554             if (d->countryCB->itemText(i).left(3) == data)
0555                 item = i;
0556         }
0557 
0558         if (item != -1)
0559         {
0560             d->countryCB->setCurrentIndex(item);
0561             d->countryCheck->setChecked(true);
0562         }
0563         else
0564         {
0565             d->countryCheck->setValid(false);
0566         }
0567     }
0568 
0569     d->countryCB->setEnabled(d->countryCheck->isChecked());
0570 
0571     blockSignals(false);
0572 }
0573 
0574 void XMPOrigin::applyMetadata(const DMetadata& meta)
0575 {
0576     QString xmpDateTimeFormat = QLatin1String("yyyy-MM-ddThh:mm:ss");
0577 
0578     if (d->dateCreatedCheck->isChecked())
0579     {
0580         meta.setXmpTagString("Xmp.photoshop.DateCreated",
0581                              getXMPCreationDate().toString(xmpDateTimeFormat) +
0582                              d->zoneCreatedSel->getTimeZone());
0583         meta.setXmpTagString("Xmp.xmp.CreateDate",
0584                              getXMPCreationDate().toString(xmpDateTimeFormat) +
0585                              d->zoneCreatedSel->getTimeZone());
0586         meta.setXmpTagString("Xmp.exif.DateTimeOriginal",
0587                              getXMPCreationDate().toString(xmpDateTimeFormat) +
0588                              d->zoneCreatedSel->getTimeZone());
0589         meta.setXmpTagString("Xmp.tiff.DateTime",
0590                              getXMPCreationDate().toString(xmpDateTimeFormat) +
0591                              d->zoneCreatedSel->getTimeZone());
0592         meta.setXmpTagString("Xmp.xmp.ModifyDate",
0593                              getXMPCreationDate().toString(xmpDateTimeFormat) +
0594                              d->zoneCreatedSel->getTimeZone());
0595         meta.setXmpTagString("Xmp.xmp.MetadataDate",
0596                              getXMPCreationDate().toString(xmpDateTimeFormat) +
0597                              d->zoneCreatedSel->getTimeZone());
0598 
0599         if (syncEXIFDateIsChecked())
0600         {
0601             meta.setExifTagString("Exif.Image.DateTime",
0602                                   getXMPCreationDate().toString(QLatin1String("yyyy:MM:dd hh:mm:ss")));
0603         }
0604     }
0605     else
0606     {
0607         meta.removeXmpTag("Xmp.photoshop.DateCreated");
0608         meta.removeXmpTag("Xmp.xmp.CreateDate");
0609         meta.removeXmpTag("Xmp.exif.DateTimeOriginal");
0610         meta.removeXmpTag("Xmp.tiff.DateTime");
0611         meta.removeXmpTag("Xmp.xmp.ModifyDate");
0612         meta.removeXmpTag("Xmp.xmp.MetadataDate");
0613     }
0614 
0615     if (d->dateDigitalizedCheck->isChecked())
0616     {
0617         meta.setXmpTagString("Xmp.exif.DateTimeDigitized",
0618                              d->dateDigitalizedSel->dateTime().toString(xmpDateTimeFormat) +
0619                              d->zoneDigitalizedSel->getTimeZone());
0620     }
0621     else
0622     {
0623         meta.removeXmpTag("Xmp.exif.DateTimeDigitized");
0624     }
0625 
0626     if (d->dateVideoCheck->isChecked())
0627     {
0628         meta.setXmpTagString("Xmp.video.DateTimeOriginal",
0629                              d->dateVideoSel->dateTime().toString(xmpDateTimeFormat) +
0630                              d->zoneVideoSel->getTimeZone());
0631         meta.setXmpTagString("Xmp.video.DateTimeDigitized",
0632                              d->dateVideoSel->dateTime().toString(xmpDateTimeFormat) +
0633                              d->zoneVideoSel->getTimeZone());
0634         meta.setXmpTagString("Xmp.video.ModificationDate",
0635                              d->dateVideoSel->dateTime().toString(xmpDateTimeFormat) +
0636                              d->zoneVideoSel->getTimeZone());
0637         meta.setXmpTagString("Xmp.video.DateUTC",
0638                              d->dateVideoSel->dateTime().toString(xmpDateTimeFormat) +
0639                              d->zoneVideoSel->getTimeZone());
0640     }
0641     else
0642     {
0643         meta.removeXmpTag("Xmp.video.DateTimeOriginal");
0644         meta.removeXmpTag("Xmp.video.DateTimeDigitized");
0645         meta.removeXmpTag("Xmp.video.ModificationDate");
0646         meta.removeXmpTag("Xmp.video.DateUTC");
0647     }
0648 
0649     if (d->cityCheck->isChecked())
0650     {
0651         meta.setXmpTagString("Xmp.photoshop.City", d->cityEdit->text());
0652     }
0653     else
0654     {
0655         meta.removeXmpTag("Xmp.photoshop.City");
0656     }
0657 
0658     if (d->sublocationCheck->isChecked())
0659     {
0660         meta.setXmpTagString("Xmp.iptc.Location", d->sublocationEdit->text());
0661     }
0662     else
0663     {
0664         meta.removeXmpTag("Xmp.iptc.Location");
0665     }
0666 
0667     if (d->provinceCheck->isChecked())
0668     {
0669         meta.setXmpTagString("Xmp.photoshop.State", d->provinceEdit->text());
0670     }
0671     else
0672     {
0673         meta.removeXmpTag("Xmp.photoshop.State");
0674     }
0675 
0676     if (d->countryCheck->isChecked())
0677     {
0678         QString countryName = d->countryCB->currentText().mid(6);
0679         QString countryCode = d->countryCB->currentText().left(3);
0680         meta.setXmpTagString("Xmp.iptc.CountryCode", countryCode);
0681         meta.setXmpTagString("Xmp.photoshop.Country", countryName);
0682     }
0683     else if (d->countryCheck->isValid())
0684     {
0685         meta.removeXmpTag("Xmp.iptc.CountryCode");
0686         meta.removeXmpTag("Xmp.photoshop.Country");
0687     }
0688 }
0689 
0690 } // namespace DigikamGenericMetadataEditPlugin
0691 
0692 #include "moc_xmporigin.cpp"