X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=lib%2Fqtcammetadata.cpp;h=aee8813f2e2dc28f2ddd601fec9bb66c8b82c32b;hp=cbfe09a3ff2c6528f12bd25701e85e9ea157ea0d;hb=3fa3497f2a03fcb1d483638efc831b72aac574c3;hpb=5d7816dfa3be66e64d98bcebefcc2bc84d20a095 diff --git a/lib/qtcammetadata.cpp b/lib/qtcammetadata.cpp index cbfe09a..aee8813 100644 --- a/lib/qtcammetadata.cpp +++ b/lib/qtcammetadata.cpp @@ -27,6 +27,7 @@ #include #include #include +#include const char *orientations[] = { "rotate-0", @@ -143,7 +144,33 @@ void QtCamMetaData::setOrientation(Orientation orientation) { } void QtCamMetaData::setArtist(const QString& artist) { - d_ptr->addTag(GST_TAG_ARTIST, artist); + /* try the shortcut first */ + if (!artist.contains('%')) { + d_ptr->addTag(GST_TAG_ARTIST, artist); + return; + } + + std::vector result(artist.size()); + struct tm tm; + time_t t; + t = time(NULL); + if (t == -1) { + qWarning() << "Failed to get current time"; + d_ptr->addTag(GST_TAG_ARTIST, artist); + return; + } + + if (!localtime_r(&t, &tm)) { + qWarning() << "Failed to get local time"; + d_ptr->addTag(GST_TAG_ARTIST, artist); + return; + } + + while (!strftime(result.data(), result.size(), artist.toUtf8().constData(), &tm)) { + result.resize(result.size() * 2); + } + + d_ptr->addTag(GST_TAG_ARTIST, QString::fromUtf8(result.data())); } void QtCamMetaData::setDateTime(const QDateTime& dateTime) {