[Kde-imaging] extragear/libs/kipi-plugins/metadataedit
Gilles Caulier
caulier.gilles at free.fr
Wed Oct 18 13:40:40 CEST 2006
SVN commit 596732 by cgilles:
kipiplugins from trunk : MetadataEdit plugin: Exif Date & Time informations editor support now sub-seconds time values.
CCMAIL: kde-imaging at kde.org
CCBUGS: 103255
M +119 -21 exifdatetime.cpp
--- trunk/extragear/libs/kipi-plugins/metadataedit/exifdatetime.cpp #596731:596732
@@ -32,6 +32,7 @@
#include <klocale.h>
#include <kdialog.h>
#include <kdatetimewidget.h>
+#include <knuminput.h>
// Local includes.
@@ -48,19 +49,32 @@
EXIFDateTimePriv()
{
- dateCreatedSel = 0;
- dateOriginalSel = 0;
- dateDigitalizedSel = 0;
+ dateCreatedSel = 0;
+ dateOriginalSel = 0;
+ dateDigitalizedSel = 0;
+ dateCreatedSubSecEdit = 0;
+ dateOriginalSubSecEdit = 0;
+ dateDigitalizedSubSecEdit = 0;
- dateCreatedCheck = 0;
- dateOriginalCheck = 0;
- dateDigitalizedCheck = 0;
+ dateCreatedCheck = 0;
+ dateOriginalCheck = 0;
+ dateDigitalizedCheck = 0;
+ dateCreatedSubSecCheck = 0;
+ dateOriginalSubSecCheck = 0;
+ dateDigitalizedSubSecCheck = 0;
}
QCheckBox *dateCreatedCheck;
QCheckBox *dateOriginalCheck;
QCheckBox *dateDigitalizedCheck;
+ QCheckBox *dateCreatedSubSecCheck;
+ QCheckBox *dateOriginalSubSecCheck;
+ QCheckBox *dateDigitalizedSubSecCheck;
+ KIntSpinBox *dateCreatedSubSecEdit;
+ KIntSpinBox *dateOriginalSubSecEdit;
+ KIntSpinBox *dateDigitalizedSubSecEdit;
+
KDateTimeWidget *dateCreatedSel;
KDateTimeWidget *dateOriginalSel;
KDateTimeWidget *dateDigitalizedSel;
@@ -75,39 +89,57 @@
// --------------------------------------------------------
- d->dateCreatedCheck = new QCheckBox(i18n("Creation date and time"), parent);
- d->dateCreatedSel = new KDateTimeWidget(parent);
+ d->dateCreatedCheck = new QCheckBox(i18n("Creation date and time"), parent);
+ d->dateCreatedSubSecCheck = new QCheckBox(i18n("Creation sub-second"), parent);
+ d->dateCreatedSel = new KDateTimeWidget(parent);
+ d->dateCreatedSubSecEdit = new KIntSpinBox(0, 999, 1, 0, 10, parent);
d->dateCreatedSel->setDateTime(QDateTime::currentDateTime());
- grid->addMultiCellWidget(d->dateCreatedCheck, 0, 0, 0, 1);
- grid->addMultiCellWidget(d->dateCreatedSel, 1, 1, 0, 1);
+ grid->addMultiCellWidget(d->dateCreatedCheck, 0, 0, 0, 0);
+ grid->addMultiCellWidget(d->dateCreatedSubSecCheck, 0, 0, 1, 2);
+ grid->addMultiCellWidget(d->dateCreatedSel, 1, 1, 0, 0);
+ grid->addMultiCellWidget(d->dateCreatedSubSecEdit, 1, 1, 1, 1);
QWhatsThis::add(d->dateCreatedSel, i18n("<p>Set here the date and time of image creation. "
"In this standard it is the date and time the file was changed."));
+ QWhatsThis::add(d->dateCreatedSubSecEdit, i18n("<p>Set here the fractions of seconds for the date "
+ "and time of image creation."));
// --------------------------------------------------------
- d->dateOriginalCheck = new QCheckBox(i18n("Original date and time"), parent);
- d->dateOriginalSel = new KDateTimeWidget(parent);
+ d->dateOriginalCheck = new QCheckBox(i18n("Original date and time"), parent);
+ d->dateOriginalSubSecCheck = new QCheckBox(i18n("Original sub-second"), parent);
+ d->dateOriginalSel = new KDateTimeWidget(parent);
+ d->dateOriginalSubSecEdit = new KIntSpinBox(0, 999, 1, 0, 10, parent);
d->dateOriginalSel->setDateTime(QDateTime::currentDateTime());
- grid->addMultiCellWidget(d->dateOriginalCheck, 2, 2, 0, 1);
- grid->addMultiCellWidget(d->dateOriginalSel, 3, 3, 0, 1);
+ grid->addMultiCellWidget(d->dateOriginalCheck, 2, 2, 0, 0);
+ grid->addMultiCellWidget(d->dateOriginalSubSecCheck, 2, 2, 1, 2);
+ grid->addMultiCellWidget(d->dateOriginalSel, 3, 3, 0, 0);
+ grid->addMultiCellWidget(d->dateOriginalSubSecEdit, 3, 3, 1, 1);
QWhatsThis::add(d->dateOriginalSel, i18n("<p>Set here the date and time when the original image "
"data was generated. For a digital still camera the date and "
"time the picture was taken are recorded."));
+ QWhatsThis::add(d->dateOriginalSubSecEdit, i18n("<p>Set here the fractions of seconds for the date "
+ "and time when the original image data was generated."));
// --------------------------------------------------------
- d->dateDigitalizedCheck = new QCheckBox(i18n("Digitization date and time"), parent);
- d->dateDigitalizedSel = new KDateTimeWidget(parent);
+ d->dateDigitalizedCheck = new QCheckBox(i18n("Digitization date and time"), parent);
+ d->dateDigitalizedSubSecCheck = new QCheckBox(i18n("Digitization sub-second"), parent);
+ d->dateDigitalizedSel = new KDateTimeWidget(parent);
+ d->dateDigitalizedSubSecEdit = new KIntSpinBox(0, 999, 1, 0, 10, parent);
d->dateDigitalizedSel->setDateTime(QDateTime::currentDateTime());
- grid->addMultiCellWidget(d->dateDigitalizedCheck, 4, 4, 0, 1);
- grid->addMultiCellWidget(d->dateDigitalizedSel, 5, 5, 0, 1);
+ grid->addMultiCellWidget(d->dateDigitalizedCheck, 4, 4, 0, 0);
+ grid->addMultiCellWidget(d->dateDigitalizedSubSecCheck, 4, 4, 1, 2);
+ grid->addMultiCellWidget(d->dateDigitalizedSel, 5, 5, 0, 0);
+ grid->addMultiCellWidget(d->dateDigitalizedSubSecEdit, 5, 5, 1, 1);
QWhatsThis::add(d->dateDigitalizedSel, i18n("<p>Set here the date and time when the image was "
"stored as digital data. If, for example, an image was "
"captured by a digital still camera and at the same "
"time the file was recorded, then Original and Digitization "
"date and time will have the same contents."));
+ QWhatsThis::add(d->dateDigitalizedSubSecEdit, i18n("<p>Set here the fractions of seconds for the date "
+ "and time when the image was stored as digital data."));
- grid->setColStretch(2, 10);
+ grid->setColStretch(3, 10);
grid->setRowStretch(6, 10);
// --------------------------------------------------------
@@ -121,6 +153,15 @@
connect(d->dateDigitalizedCheck, SIGNAL(toggled(bool)),
d->dateDigitalizedSel, SLOT(setEnabled(bool)));
+ connect(d->dateCreatedSubSecCheck, SIGNAL(toggled(bool)),
+ d->dateCreatedSubSecEdit, SLOT(setEnabled(bool)));
+
+ connect(d->dateOriginalSubSecCheck, SIGNAL(toggled(bool)),
+ d->dateOriginalSubSecEdit, SLOT(setEnabled(bool)));
+
+ connect(d->dateDigitalizedSubSecCheck, SIGNAL(toggled(bool)),
+ d->dateDigitalizedSubSecEdit, SLOT(setEnabled(bool)));
+
// --------------------------------------------------------
readMetadata(exifData);
@@ -137,7 +178,7 @@
exiv2Iface.setExif(exifData);
QDateTime datetime;
- QString datetimeStr;
+ QString datetimeStr, data;
datetimeStr = exiv2Iface.getExifTagString("Exif.Image.DateTime", false);
@@ -152,6 +193,19 @@
}
d->dateCreatedSel->setEnabled(d->dateCreatedCheck->isChecked());
+ data = exiv2Iface.getExifTagString("Exif.Photo.SubSecTime", false);
+ if (!data.isNull())
+ {
+ bool ok = false;
+ int subsec = data.toInt(&ok);
+ if (ok)
+ {
+ d->dateCreatedSubSecEdit->setValue(subsec);
+ d->dateCreatedSubSecCheck->setChecked(true);
+ }
+ }
+ d->dateCreatedSubSecEdit->setEnabled(d->dateCreatedSubSecCheck->isChecked());
+
datetimeStr = exiv2Iface.getExifTagString("Exif.Photo.DateTimeOriginal", false);
if (!datetimeStr.isEmpty())
@@ -165,6 +219,19 @@
}
d->dateOriginalSel->setEnabled(d->dateOriginalCheck->isChecked());
+ data = exiv2Iface.getExifTagString("Exif.Photo.SubSecTimeOriginal", false);
+ if (!data.isNull())
+ {
+ bool ok = false;
+ int subsec = data.toInt(&ok);
+ if (ok)
+ {
+ d->dateOriginalSubSecEdit->setValue(subsec);
+ d->dateOriginalSubSecCheck->setChecked(true);
+ }
+ }
+ d->dateOriginalSubSecEdit->setEnabled(d->dateOriginalSubSecCheck->isChecked());
+
datetimeStr = exiv2Iface.getExifTagString("Exif.Photo.DateTimeDigitized", false);
if (!datetimeStr.isEmpty())
@@ -177,6 +244,19 @@
}
}
d->dateDigitalizedSel->setEnabled(d->dateDigitalizedCheck->isChecked());
+
+ data = exiv2Iface.getExifTagString("Exif.Photo.SubSecTimeDigitized", false);
+ if (!data.isNull())
+ {
+ bool ok = false;
+ int subsec = data.toInt(&ok);
+ if (ok)
+ {
+ d->dateDigitalizedSubSecEdit->setValue(subsec);
+ d->dateDigitalizedSubSecCheck->setChecked(true);
+ }
+ }
+ d->dateDigitalizedSubSecEdit->setEnabled(d->dateDigitalizedSubSecCheck->isChecked());
}
void EXIFDateTime::applyMetadata(QByteArray& exifData)
@@ -190,18 +270,36 @@
else
exiv2Iface.removeExifTag("Exif.Image.DateTime");
+ if (d->dateCreatedSubSecCheck->isChecked())
+ exiv2Iface.setExifTagString("Exif.Photo.SubSecTime",
+ QString::number(d->dateCreatedSubSecEdit->value()).ascii());
+ else
+ exiv2Iface.removeExifTag("Exif.Photo.SubSecTime");
+
if (d->dateOriginalCheck->isChecked())
exiv2Iface.setExifTagString("Exif.Photo.DateTimeOriginal",
d->dateOriginalSel->dateTime().toString(QString("yyyy:MM:dd hh:mm:ss")).ascii());
else
exiv2Iface.removeExifTag("Exif.Photo.DateTimeOriginal");
+ if (d->dateOriginalSubSecCheck->isChecked())
+ exiv2Iface.setExifTagString("Exif.Photo.SubSecTimeOriginal",
+ QString::number(d->dateOriginalSubSecEdit->value()).ascii());
+ else
+ exiv2Iface.removeExifTag("Exif.Photo.SubSecTimeOriginal");
+
if (d->dateDigitalizedCheck->isChecked())
- exiv2Iface.setIptcTagString("Exif.Photo.DateTimeDigitized",
+ exiv2Iface.setExifTagString("Exif.Photo.DateTimeDigitized",
d->dateDigitalizedSel->dateTime().toString(QString("yyyy:MM:dd hh:mm:ss")).ascii());
else
exiv2Iface.removeExifTag("Exif.Photo.DateTimeDigitized");
+ if (d->dateDigitalizedSubSecCheck->isChecked())
+ exiv2Iface.setExifTagString("Exif.Photo.SubSecTimeDigitized",
+ QString::number(d->dateDigitalizedSubSecEdit->value()).ascii());
+ else
+ exiv2Iface.removeExifTag("Exif.Photo.SubSecTimeDigitized");
+
exifData = exiv2Iface.getExif();
}
More information about the Kde-imaging
mailing list