diff --git a/autotests/propertyinfotest.cpp b/autotests/propertyinfotest.cpp --- a/autotests/propertyinfotest.cpp +++ b/autotests/propertyinfotest.cpp @@ -111,28 +111,34 @@ QVariant value; QString expected; } rows[] = { - { Property::DiscNumber, true, 2018, QStringLiteral("2018")}, - { Property::Title, false, QStringLiteral("Title"), QStringLiteral("Title")}, - { Property::Title, false, titleList, QStringLiteral("Title1 and Title2")}, - { Property::Artist, true, artistList, QStringLiteral("Artist1, Artist2, and Artist3")}, - { Property::Author, true, authorList, QStringLiteral("Author1")}, - { Property::Arranger, true, arrangerList, QStringLiteral("Arranger1 and Arranger2")}, - { Property::Duration, true, 1800, QStringLiteral("0:30:00")}, - { Property::SampleRate, true, 44100, QStringLiteral("44.1 kHz")}, - { Property::BitRate, true, 128000, QStringLiteral("128 kbit/s")}, - { Property::BitRate, true, 1350000, QStringLiteral("1.35 Mbit/s")}, - { Property::BitRate, true, 14700000, QStringLiteral("14.7 Mbit/s")}, - { Property::BitRate, true, bitRateList, QStringLiteral("128 kbit/s and 130 kbit/s")}, - { Property::ImageOrientation, true, 5, QStringLiteral("Transposed")}, - { Property::PhotoFlash, true, 0x00, QStringLiteral("No flash")}, - { Property::PhotoFlash, true, 0x50, QStringLiteral("No, red-eye reduction")}, - { Property::PhotoGpsAltitude, true, 1.1, QStringLiteral("1.1 m")}, + { Property::DiscNumber, true, 2018, QStringLiteral("2018")}, + { Property::Title, false, QStringLiteral("Title"), QStringLiteral("Title")}, + { Property::Title, false, titleList, QStringLiteral("Title1 and Title2")}, + { Property::Artist, true, artistList, QStringLiteral("Artist1, Artist2, and Artist3")}, + { Property::Author, true, authorList, QStringLiteral("Author1")}, + { Property::Arranger, true, arrangerList, QStringLiteral("Arranger1 and Arranger2")}, + { Property::Duration, true, 1800, QStringLiteral("0:30:00")}, + { Property::SampleRate, true, 44100, QStringLiteral("44.1 kHz")}, + { Property::BitRate, true, 128000, QStringLiteral("128 kbit/s")}, + { Property::BitRate, true, 1350000, QStringLiteral("1.35 Mbit/s")}, + { Property::BitRate, true, 14700000, QStringLiteral("14.7 Mbit/s")}, + { Property::BitRate, true, bitRateList, QStringLiteral("128 kbit/s and 130 kbit/s")}, + { Property::ImageOrientation, true, 5, QStringLiteral("Transposed")}, + { Property::PhotoFlash, true, 0x00, QStringLiteral("No flash")}, + { Property::PhotoFlash, true, 0x50, QStringLiteral("No, red-eye reduction")}, + { Property::PhotoGpsAltitude, true, 1.1, QStringLiteral("1.1 m")}, // make VisualStudio compiler happy: QChar(0x00B0) = "°" - { Property::PhotoGpsLatitude, true, 25, QStringLiteral("25") + QChar(0x00B0)}, - { Property::PhotoGpsLongitude, true, 13.5, QStringLiteral("13.5") + QChar(0x00B0)}, - { Property::FrameRate, true, 23, QStringLiteral("23 fps")}, - { Property::FrameRate, true, 23.976, QStringLiteral("23.98 fps")}, - { Property::AspectRatio, true, 1.77778, QStringLiteral("1.78:1")}, + { Property::PhotoGpsLatitude, true, 25, QStringLiteral("25") + QChar(0x00B0)}, + { Property::PhotoGpsLongitude, true, 13.5, QStringLiteral("13.5") + QChar(0x00B0)}, + { Property::PhotoExposureTime, true, 0.0015625, QStringLiteral("0.00156")}, + { Property::PhotoExposureBiasValue, true, 0.3333333, QStringLiteral("0.333")}, + { Property::ReplayGainAlbumGain, true, -9.90, QStringLiteral("-9.9")}, + { Property::ReplayGainAlbumPeak, true, 1.512, QStringLiteral("1.51")}, + { Property::ReplayGainAlbumGain, true, 10.44, QStringLiteral("10.4")}, + { Property::ReplayGainAlbumPeak, true, 1.306, QStringLiteral("1.31")}, + { Property::FrameRate, true, 23, QStringLiteral("23 fps")}, + { Property::FrameRate, true, 23.976, QStringLiteral("23.98 fps")}, + { Property::AspectRatio, true, 1.77778, QStringLiteral("1.78:1")}, }; for (auto row : rows) { diff --git a/src/formatstrings.cpp b/src/formatstrings.cpp --- a/src/formatstrings.cpp +++ b/src/formatstrings.cpp @@ -45,6 +45,11 @@ return value.toString(); } +QString FormatStrings::formatDouble(const QVariant& value) +{ + return QLocale().toString(value.toDouble(),'g',3); +} + QString FormatStrings::formatDate(const QVariant& value) { KFormat form; diff --git a/src/formatstrings_p.h b/src/formatstrings_p.h --- a/src/formatstrings_p.h +++ b/src/formatstrings_p.h @@ -31,6 +31,8 @@ public: static QString toStringFunction(const QVariant& value); + static QString formatDouble(const QVariant& value); + static QString formatDate(const QVariant& value); static QString formatDuration(const QVariant& value); diff --git a/src/propertyinfo.cpp b/src/propertyinfo.cpp --- a/src/propertyinfo.cpp +++ b/src/propertyinfo.cpp @@ -237,6 +237,7 @@ d->name = QStringLiteral("photoApertureValue"); d->displayName = i18nc("@label EXIF", "Photo Aperture Value"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::PhotoDateTimeOriginal: @@ -250,12 +251,14 @@ d->name = QStringLiteral("photoExposureBiasValue"); d->displayName = i18nc("@label EXIF", "Photo Exposure Bias"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::PhotoExposureTime: d->name = QStringLiteral("photoExposureTime"); d->displayName = i18nc("@label EXIF", "Photo Exposure Time"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::PhotoFlash: @@ -275,12 +278,14 @@ d->name = QStringLiteral("photoFocalLength"); d->displayName = i18nc("@label EXIF", "Photo Focal Length"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::PhotoFocalLengthIn35mmFilm: d->name = QStringLiteral("photoFocalLengthIn35mmFilm"); d->displayName = i18nc("@label EXIF", "Photo Focal Length 35mm"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::PhotoGpsLatitude: @@ -460,24 +465,28 @@ d->name = QStringLiteral("replayGainAlbumPeak"); d->displayName = i18nc("@label", "Replay Gain Album Peak"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::ReplayGainAlbumGain: d->name = QStringLiteral("replayGainAlbumGain"); d->displayName = i18nc("@label", "Replay Gain Album Gain"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::ReplayGainTrackPeak: d->name = QStringLiteral("replayGainTrackPeak"); d->displayName = i18nc("@label", "Replay Gain Track Peak"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::ReplayGainTrackGain: d->name = QStringLiteral("replayGainTrackGain"); d->displayName = i18nc("@label", "Replay Gain Track Gain"); d->valueType = QVariant::Double; + d->formatAsString = &FormatStrings::formatDouble; break; case Property::Width: