Commit abc7ddc4 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Camera interface is now able to sort item taken quicly (less than 1 second)...

Camera interface is now able to sort item taken quicly (less than 1 second) using millisecond time stamp from Exif metadata.
BUGS: 246401
parent 23ecc133
......@@ -191,6 +191,41 @@ bool DMetadata::setProgramId(bool on) const
return true;
}
int DMetadata::getMSecsInfo() const
{
int ms = 0;
bool ok = mSecTimeStamp("Exif.Photo.SubSecTime", ms);
if (ok) return ms;
ok = mSecTimeStamp("Exif.Photo.SubSecTimeOriginal", ms);
if (ok) return ms;
ok = mSecTimeStamp("Exif.Photo.SubSecTimeDigitized", ms);
if (ok) return ms;
return 0;
}
bool DMetadata::mSecTimeStamp(const char* exifTagName, int& ms) const
{
bool ok = false;
QString val = getExifTagString(exifTagName);
if (!val.isEmpty())
{
int sub = val.toUInt(&ok);
if (ok)
{
int _ms = (int)(QString("0.%1").arg(sub).toFloat(&ok) * 1000.0);
if (ok)
{
ms = _ms;
kDebug() << "msec timestamp: " << ms;
}
}
}
return ok;
}
CaptionsMap DMetadata::getImageComments() const
{
if (getFilePath().isEmpty())
......
......@@ -131,6 +131,15 @@ public:
PhotoInfoContainer getPhotographInformation() const;
/** Returns millisecond time-stamp from Exif tags or 0 if not found.
*/
int getMSecsInfo() const;
/** Extract milliseconds time-stamp of photo from an Exif tag and store it to 'ms'.
* Returns true if data are extracted.
*/
bool mSecTimeStamp(const char* exifTagName, int& ms) const;
/** Returns the requested metadata field as a QVariant. See metadatainfo.h for a specification
of the format of the QVariant.
*/
......
......@@ -160,6 +160,8 @@ void DKCamera::fillItemInfoFromMetadata(CamItemInfo& info, const DMetadata& meta
{
QSize dims = meta.getImageDimensions();
info.mtime = meta.getImageDateTime();
//NOTE: see B.K.O #246401 to sort based on milliseconds for items taken quickly.
info.mtime.setTime(info.mtime.time().addMSecs(meta.getMSecsInfo()));
info.width = dims.width();
info.height = dims.height();
info.photoInfo = meta.getPhotographInformation();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment