1/*
2 This file is part of the KFileMetaData project
3 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "propertyinfo.h"
9
10#include <KLazyLocalizedString>
11#include <KLocalizedString>
12
13#include "formatstrings_p.h"
14#include "icnamematch_p.h"
15
16#include <array>
17
18#include <QLocale>
19
20using namespace KFileMetaData;
21
22class KFileMetaData::PropertyInfoData
23{
24 using FormatFunction = QString (&)(const QVariant&);
25
26public:
27 const Property::Property prop;
28 const bool shouldBeIndexed = false;
29 const QString name;
30 const KLazyLocalizedString displayName;
31 const QMetaType::Type valueType = QMetaType::UnknownType;
32 const FormatFunction formatAsString = FormatStrings::toStringFunction;
33
34 static constexpr auto fromId(Property::Property property) -> const PropertyInfoData*;
35 static auto fromName(const QString& name) -> const PropertyInfoData*;
36
37 static const PropertyInfoData s_Empty;
38 static const std::array<PropertyInfoData, 83> s_allProperties;
39 static const QHash<LcIdentifierName, const PropertyInfoData*> s_propertyHash;
40};
41
42const PropertyInfoData PropertyInfoData::s_Empty{ .prop: Property::Empty, .shouldBeIndexed: false, QStringLiteral("empty"), .displayName: kli18nc(context: "@label", text: "Empty") };
43
44const std::array<PropertyInfoData, 83> PropertyInfoData::s_allProperties
45{
46 PropertyInfoData{ .prop: Property::AssistiveAlternateDescription, .shouldBeIndexed: true, QStringLiteral("assistiveDescription"), .displayName: kli18nc(context: "@label accessible alt text", text: "Assistive Description"), .valueType: QMetaType::QString },
47 PropertyInfoData{ .prop: Property::Album, .shouldBeIndexed: true, QStringLiteral("album"), .displayName: kli18nc(context: "@label music album", text: "Album"), .valueType: QMetaType::QString },
48 PropertyInfoData{ .prop: Property::AlbumArtist, .shouldBeIndexed: true, QStringLiteral("albumArtist"), .displayName: kli18nc(context: "@label", text: "Album Artist"), .valueType: QMetaType::QString },
49 PropertyInfoData{ .prop: Property::Artist, .shouldBeIndexed: true, QStringLiteral("artist"), .displayName: kli18nc(context: "@label", text: "Artist"), .valueType: QMetaType::QString },
50 PropertyInfoData{ .prop: Property::AspectRatio, .shouldBeIndexed: false, QStringLiteral("aspectRatio"), .displayName: kli18nc(context: "@label", text: "Aspect Ratio"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAspectRatio },
51 PropertyInfoData{ .prop: Property::Author, .shouldBeIndexed: true, QStringLiteral("author"), .displayName: kli18nc(context: "@label", text: "Author"), .valueType: QMetaType::QString },
52 PropertyInfoData{ .prop: Property::BitRate, .shouldBeIndexed: false, QStringLiteral("bitRate"), .displayName: kli18nc(context: "@label", text: "Bitrate"), .valueType: QMetaType::Int, .formatAsString: FormatStrings::formatBitRate },
53 PropertyInfoData{ .prop: Property::Channels, .shouldBeIndexed: false, QStringLiteral("channels"), .displayName: kli18nc(context: "@label", text: "Channels"), .valueType: QMetaType::Int },
54 PropertyInfoData{ .prop: Property::Comment, .shouldBeIndexed: false, QStringLiteral("comment"), .displayName: kli18nc(context: "@label", text: "Comment"), .valueType: QMetaType::QString },
55 PropertyInfoData{ .prop: Property::Description, .shouldBeIndexed: false, QStringLiteral("description"), .displayName: kli18nc(context: "@label", text: "Description"), .valueType: QMetaType::QString },
56 PropertyInfoData{ .prop: Property::Composer, .shouldBeIndexed: true, QStringLiteral("composer"), .displayName: kli18nc(context: "@label", text: "Composer"), .valueType: QMetaType::QString },
57 PropertyInfoData{ .prop: Property::Copyright, .shouldBeIndexed: false, QStringLiteral("copyright"), .displayName: kli18nc(context: "@label", text: "Copyright"), .valueType: QMetaType::QString },
58 PropertyInfoData{ .prop: Property::CreationDate, .shouldBeIndexed: false, QStringLiteral("creationDate"), .displayName: kli18nc(context: "@label", text: "Creation Date"), .valueType: QMetaType::QDateTime, .formatAsString: FormatStrings::formatDate },
59 PropertyInfoData{ .prop: Property::Duration, .shouldBeIndexed: false, QStringLiteral("duration"), .displayName: kli18nc(context: "@label", text: "Duration"), .valueType: QMetaType::Int, .formatAsString: FormatStrings::formatDuration },
60 PropertyInfoData{ .prop: Property::FrameRate, .shouldBeIndexed: false, QStringLiteral("frameRate"), .displayName: kli18nc(context: "@label", text: "Frame Rate"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsFrameRate },
61 PropertyInfoData{ .prop: Property::Generator, .shouldBeIndexed: false, QStringLiteral("generator"), .displayName: kli18nc(context: "@label", text: "Document Generated By"), .valueType: QMetaType::QString },
62 PropertyInfoData{ .prop: Property::Genre, .shouldBeIndexed: true, QStringLiteral("genre"), .displayName: kli18nc(context: "@label music genre", text: "Genre"), .valueType: QMetaType::QString },
63 PropertyInfoData{ .prop: Property::Height, .shouldBeIndexed: false, QStringLiteral("height"), .displayName: kli18nc(context: "@label", text: "Height"), .valueType: QMetaType::Int },
64 PropertyInfoData{ .prop: Property::ImageDateTime, .shouldBeIndexed: false, QStringLiteral("imageDateTime"), .displayName: kli18nc(context: "@label EXIF", text: "Image Date Time"), .valueType: QMetaType::QDateTime, .formatAsString: FormatStrings::formatDate },
65 PropertyInfoData{ .prop: Property::Manufacturer, .shouldBeIndexed: false, QStringLiteral("manufacturer"), .displayName: kli18nc(context: "@label EXIF", text: "Manufacturer"), .valueType: QMetaType::QString },
66 PropertyInfoData{ .prop: Property::Model, .shouldBeIndexed: false, QStringLiteral("model"), .displayName: kli18nc(context: "@label EXIF", text: "Model"), .valueType: QMetaType::QString },
67 PropertyInfoData{ .prop: Property::ImageOrientation, .shouldBeIndexed: false, QStringLiteral("imageOrientation"), .displayName: kli18nc(context: "@label EXIF", text: "Image Orientation"), .valueType: QMetaType::Int, .formatAsString: FormatStrings::formatOrientationValue },
68 PropertyInfoData{ .prop: Property::Keywords, .shouldBeIndexed: false, QStringLiteral("keywords"), .displayName: kli18nc(context: "@label", text: "Keywords"), .valueType: QMetaType::QString },
69 PropertyInfoData{ .prop: Property::Language, .shouldBeIndexed: false, QStringLiteral("language"), .displayName: kli18nc(context: "@label", text: "Language"), .valueType: QMetaType::QString },
70 PropertyInfoData{ .prop: Property::LineCount, .shouldBeIndexed: false, QStringLiteral("lineCount"), .displayName: kli18nc(context: "@label number of lines", text: "Line Count"), .valueType: QMetaType::Int },
71 PropertyInfoData{ .prop: Property::Lyricist, .shouldBeIndexed: true, QStringLiteral("lyricist"), .displayName: kli18nc(context: "@label", text: "Lyricist"), .valueType: QMetaType::QString },
72 PropertyInfoData{ .prop: Property::PageCount, .shouldBeIndexed: false, QStringLiteral("pageCount"), .displayName: kli18nc(context: "@label", text: "Page Count"), .valueType: QMetaType::Int },
73 PropertyInfoData{ .prop: Property::PhotoApertureValue, .shouldBeIndexed: false, QStringLiteral("photoApertureValue"), .displayName: kli18nc(context: "@label EXIF", text: "Aperture Value"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsFNumber },
74 PropertyInfoData{ .prop: Property::PhotoDateTimeOriginal, .shouldBeIndexed: false, QStringLiteral("photoDateTimeOriginal"), .displayName: kli18nc(context: "@label EXIF", text: "Original Date Time"), .valueType: QMetaType::QDateTime, .formatAsString: FormatStrings::formatDate },
75 PropertyInfoData{ .prop: Property::PhotoExposureBiasValue, .shouldBeIndexed: false, QStringLiteral("photoExposureBiasValue"), .displayName: kli18nc(context: "@label EXIF", text: "Exposure Bias"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatPhotoExposureBias },
76 PropertyInfoData{ .prop: Property::PhotoExposureTime, .shouldBeIndexed: false, QStringLiteral("photoExposureTime"), .displayName: kli18nc(context: "@label EXIF", text: "Exposure Time"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatPhotoTime },
77 PropertyInfoData{ .prop: Property::PhotoFlash, .shouldBeIndexed: false, QStringLiteral("photoFlash"), .displayName: kli18nc(context: "@label EXIF", text: "Flash"), .valueType: QMetaType::Int, .formatAsString: FormatStrings::formatPhotoFlashValue },
78 PropertyInfoData{ .prop: Property::PhotoFNumber, .shouldBeIndexed: false, QStringLiteral("photoFNumber"), .displayName: kli18nc(context: "@label EXIF", text: "F Number"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsFNumber },
79 PropertyInfoData{ .prop: Property::PhotoFocalLength, .shouldBeIndexed: false, QStringLiteral("photoFocalLength"), .displayName: kli18nc(context: "@label EXIF", text: "Focal Length"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsMilliMeter },
80 PropertyInfoData{ .prop: Property::PhotoFocalLengthIn35mmFilm, .shouldBeIndexed: false, QStringLiteral("photoFocalLengthIn35mmFilm"), .displayName: kli18nc(context: "@label EXIF", text: "Focal Length 35mm"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsMilliMeter },
81 PropertyInfoData{ .prop: Property::PhotoGpsLatitude, .shouldBeIndexed: false, QStringLiteral("photoGpsLatitude"), .displayName: kli18nc(context: "@label EXIF", text: "GPS Latitude"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsDegree },
82 PropertyInfoData{ .prop: Property::PhotoGpsLongitude, .shouldBeIndexed: false, QStringLiteral("photoGpsLongitude"), .displayName: kli18nc(context: "@label EXIF", text: "GPS Longitude"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsDegree },
83 PropertyInfoData{ .prop: Property::PhotoGpsAltitude, .shouldBeIndexed: false, QStringLiteral("photoGpsAltitude"), .displayName: kli18nc(context: "@label EXIF", text: "GPS Altitude"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatAsMeter },
84 PropertyInfoData{ .prop: Property::PhotoISOSpeedRatings, .shouldBeIndexed: false, QStringLiteral("photoISOSpeedRatings"), .displayName: kli18nc(context: "@label EXIF", text: "ISO Speed Rating"), .valueType: QMetaType::Int },
85 PropertyInfoData{ .prop: Property::PhotoMeteringMode, .shouldBeIndexed: false, QStringLiteral("photoMeteringMode"), .displayName: kli18nc(context: "@label EXIF", text: "Metering Mode"), .valueType: QMetaType::Int },
86 PropertyInfoData{ .prop: Property::PhotoPixelXDimension, .shouldBeIndexed: false, QStringLiteral("photoPixelXDimension"), .displayName: kli18nc(context: "@label EXIF", text: "X Dimension"), .valueType: QMetaType::Int },
87 PropertyInfoData{ .prop: Property::PhotoPixelYDimension, .shouldBeIndexed: false, QStringLiteral("photoPixelYDimension"), .displayName: kli18nc(context: "@label EXIF", text: "Y Dimension"), .valueType: QMetaType::Int },
88 PropertyInfoData{ .prop: Property::PhotoSaturation, .shouldBeIndexed: false, QStringLiteral("photoSaturation"), .displayName: kli18nc(context: "@label EXIF", text: "Saturation"), .valueType: QMetaType::Int },
89 PropertyInfoData{ .prop: Property::PhotoSharpness, .shouldBeIndexed: false, QStringLiteral("photoSharpness"), .displayName: kli18nc(context: "@label EXIF", text: "Sharpness"), .valueType: QMetaType::Int },
90 PropertyInfoData{ .prop: Property::PhotoWhiteBalance, .shouldBeIndexed: false, QStringLiteral("photoWhiteBalance"), .displayName: kli18nc(context: "@label EXIF", text: "White Balance"), .valueType: QMetaType::Int },
91 PropertyInfoData{ .prop: Property::ColorSpace, .shouldBeIndexed: false, QStringLiteral("colorSpace"), .displayName: kli18nc(context: "@label", text: "Color Space"), .valueType: QMetaType::QString },
92 PropertyInfoData{ .prop: Property::VideoCodec, .shouldBeIndexed: false, QStringLiteral("videoCodec"), .displayName: kli18nc(context: "@label", text: "Video Codec"), .valueType: QMetaType::QString },
93 PropertyInfoData{ .prop: Property::AudioCodec, .shouldBeIndexed: false, QStringLiteral("audioCodec"), .displayName: kli18nc(context: "@label", text: "Audio Codec"), .valueType: QMetaType::QString },
94 PropertyInfoData{ .prop: Property::PixelFormat, .shouldBeIndexed: false, QStringLiteral("pixelFormat"), .displayName: kli18nc(context: "@label", text: "Pixel Format"), .valueType: QMetaType::QString },
95 PropertyInfoData{ .prop: Property::Publisher, .shouldBeIndexed: true, QStringLiteral("publisher"), .displayName: kli18nc(context: "@label", text: "Publisher"), .valueType: QMetaType::QString },
96 PropertyInfoData{ .prop: Property::Label, .shouldBeIndexed: true, QStringLiteral("label"), .displayName: kli18nc(context: "@label", text: "Label"), .valueType: QMetaType::QString },
97 PropertyInfoData{ .prop: Property::ReleaseYear, .shouldBeIndexed: false, QStringLiteral("releaseYear"), .displayName: kli18nc(context: "@label", text: "Release Year"), .valueType: QMetaType::Int },
98 PropertyInfoData{ .prop: Property::SampleRate, .shouldBeIndexed: false, QStringLiteral("sampleRate"), .displayName: kli18nc(context: "@label", text: "Sample Rate"), .valueType: QMetaType::Int, .formatAsString: FormatStrings::formatSampleRate },
99 PropertyInfoData{ .prop: Property::Subject, .shouldBeIndexed: false, QStringLiteral("subject"), .displayName: kli18nc(context: "@label", text: "Subject"), .valueType: QMetaType::QString },
100 PropertyInfoData{ .prop: Property::Title, .shouldBeIndexed: true, QStringLiteral("title"), .displayName: kli18nc(context: "@label", text: "Title"), .valueType: QMetaType::QString },
101 PropertyInfoData{ .prop: Property::TrackNumber, .shouldBeIndexed: false, QStringLiteral("trackNumber"), .displayName: kli18nc(context: "@label music track number", text: "Track Number"), .valueType: QMetaType::Int },
102 PropertyInfoData{ .prop: Property::DiscNumber, .shouldBeIndexed: false, QStringLiteral("discNumber"), .displayName: kli18nc(context: "@label music disc number", text: "Disc Number"), .valueType: QMetaType::Int },
103 PropertyInfoData{ .prop: Property::Location, .shouldBeIndexed: true, QStringLiteral("location"), .displayName: kli18nc(context: "@label", text: "Location"), .valueType: QMetaType::QString },
104 PropertyInfoData{ .prop: Property::Performer, .shouldBeIndexed: true, QStringLiteral("performer"), .displayName: kli18nc(context: "@label", text: "Performer"), .valueType: QMetaType::QString },
105 PropertyInfoData{ .prop: Property::Ensemble, .shouldBeIndexed: true, QStringLiteral("ensemble"), .displayName: kli18nc(context: "@label", text: "Ensemble"), .valueType: QMetaType::QString },
106 PropertyInfoData{ .prop: Property::Arranger, .shouldBeIndexed: true, QStringLiteral("arranger"), .displayName: kli18nc(context: "@label", text: "Arranger"), .valueType: QMetaType::QString },
107 PropertyInfoData{ .prop: Property::Conductor, .shouldBeIndexed: true, QStringLiteral("conductor"), .displayName: kli18nc(context: "@label", text: "Conductor"), .valueType: QMetaType::QString },
108 PropertyInfoData{ .prop: Property::Compilation, .shouldBeIndexed: true, QStringLiteral("compilation"), .displayName: kli18nc(context: "@label", text: "Compilation"), .valueType: QMetaType::QString },
109 PropertyInfoData{ .prop: Property::License, .shouldBeIndexed: true, QStringLiteral("license"), .displayName: kli18nc(context: "@label", text: "License"), .valueType: QMetaType::QString },
110 PropertyInfoData{ .prop: Property::Lyrics, .shouldBeIndexed: true, QStringLiteral("lyrics"), .displayName: kli18nc(context: "@label", text: "Lyrics"), .valueType: QMetaType::QString },
111 PropertyInfoData{ .prop: Property::Opus, .shouldBeIndexed: false, QStringLiteral("opus"), .displayName: kli18nc(context: "@label", text: "Opus"), .valueType: QMetaType::Int },
112 PropertyInfoData{ .prop: Property::Rating, .shouldBeIndexed: false, QStringLiteral("embeddedRating"), .displayName: kli18nc(context: "@label", text: "Rating"), .valueType: QMetaType::Int },
113 PropertyInfoData{ .prop: Property::ReplayGainAlbumPeak, .shouldBeIndexed: false, QStringLiteral("replayGainAlbumPeak"), .displayName: kli18nc(context: "@label ReplayGain is the name of a standard", text: "ReplayGain Album Peak"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatDouble },
114 PropertyInfoData{ .prop: Property::ReplayGainAlbumGain, .shouldBeIndexed: false, QStringLiteral("replayGainAlbumGain"), .displayName: kli18nc(context: "@label ReplayGain is the name of a standard", text: "ReplayGain Album Gain"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatDouble },
115 PropertyInfoData{ .prop: Property::ReplayGainTrackPeak, .shouldBeIndexed: false, QStringLiteral("replayGainTrackPeak"), .displayName: kli18nc(context: "@label ReplayGain is the name of a standard", text: "ReplayGain Track Peak"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatDouble },
116 PropertyInfoData{ .prop: Property::ReplayGainTrackGain, .shouldBeIndexed: false, QStringLiteral("replayGainTrackGain"), .displayName: kli18nc(context: "@label ReplayGain is the name of a standard", text: "ReplayGain Track Gain"), .valueType: QMetaType::Double, .formatAsString: FormatStrings::formatDouble },
117 PropertyInfoData{ .prop: Property::Width, .shouldBeIndexed: false, QStringLiteral("width"), .displayName: kli18nc(context: "@label", text: "Width"), .valueType: QMetaType::Int },
118 PropertyInfoData{ .prop: Property::WordCount, .shouldBeIndexed: false, QStringLiteral("wordCount"), .displayName: kli18nc(context: "@label number of words", text: "Word Count"), .valueType: QMetaType::Int },
119 PropertyInfoData{ .prop: Property::TranslationUnitsTotal, .shouldBeIndexed: false, QStringLiteral("translationUnitsTotal"), .displayName: kli18nc(context: "@label number of translatable strings", text: "Translatable Units"), .valueType: QMetaType::Int },
120 PropertyInfoData{ .prop: Property::TranslationUnitsWithTranslation, .shouldBeIndexed: false, QStringLiteral("translationUnitsWithTranslation"), .displayName: kli18nc(context: "@label number of translated strings", text: "Translations"), .valueType: QMetaType::Int },
121 PropertyInfoData{ .prop: Property::TranslationUnitsWithDraftTranslation, .shouldBeIndexed: false, QStringLiteral("translationUnitsWithDraftTranslation"), .displayName: kli18nc(context: "@label number of fuzzy translated strings", text: "Draft Translations"), .valueType: QMetaType::Int },
122 PropertyInfoData{ .prop: Property::TranslationLastAuthor, .shouldBeIndexed: false, QStringLiteral("translationLastAuthor"), .displayName: kli18nc(context: "@label translation author", text: "Author"), .valueType: QMetaType::QString },
123 PropertyInfoData{ .prop: Property::TranslationLastUpDate, .shouldBeIndexed: false, QStringLiteral("translationLastUpDate"), .displayName: kli18nc(context: "@label translations last update", text: "Last Update"), .valueType: QMetaType::QString, .formatAsString: FormatStrings::formatDate },
124 PropertyInfoData{ .prop: Property::TranslationTemplateDate, .shouldBeIndexed: false, QStringLiteral("translationTemplateDate"), .displayName: kli18nc(context: "@label date of template creation8", text: "Template Creation"), .valueType: QMetaType::QString, .formatAsString: FormatStrings::formatDate },
125 PropertyInfoData{ .prop: Property::OriginUrl, .shouldBeIndexed: false, QStringLiteral("originUrl"), .displayName: kli18nc(context: "@label the URL a file was originally downloaded from", text: "Downloaded From"), .valueType: QMetaType::QUrl },
126 PropertyInfoData{ .prop: Property::OriginEmailSubject, .shouldBeIndexed: false, QStringLiteral("originEmailSubject"), .displayName: kli18nc(context: "@label the subject of an email this file was attached to", text: "E-Mail Attachment Subject"), .valueType: QMetaType::QString },
127 PropertyInfoData{ .prop: Property::OriginEmailSender, .shouldBeIndexed: false, QStringLiteral("originEmailSender"), .displayName: kli18nc(context: "@label the sender of an email this file was attached to", text: "E-Mail Attachment Sender"), .valueType: QMetaType::QString },
128 PropertyInfoData{ .prop: Property::OriginEmailMessageId, .shouldBeIndexed: false, QStringLiteral("originEmailMessageId"), .displayName: kli18nc(context: "@label the message ID of an email this file was attached to", text: "E-Mail Attachment Message ID"), .valueType: QMetaType::QString }
129};
130
131const QHash<LcIdentifierName, const PropertyInfoData*> PropertyInfoData::s_propertyHash = []()
132{
133 QHash<LcIdentifierName, const PropertyInfoData*> infoHash;
134 infoHash.reserve(size: s_allProperties.size());
135
136 for (const auto& info: s_allProperties) {
137 infoHash[QStringView(info.name)] = &info;
138 }
139 return infoHash;
140}();
141
142constexpr auto PropertyInfoData::fromId(Property::Property property) -> const PropertyInfoData*
143{
144 for (const auto& p : s_allProperties) {
145 if (p.prop == property)
146 return &p;
147 }
148 return &s_Empty;
149}
150
151auto PropertyInfoData::fromName(const QString& name) -> const PropertyInfoData*
152{
153 return s_propertyHash.value(key: LcIdentifierName(name), defaultValue: &s_Empty);
154}
155
156
157PropertyInfo::PropertyInfo(Property::Property property) : d(PropertyInfoData::fromId(property)) {};
158
159PropertyInfo::PropertyInfo() : d(&PropertyInfoData::s_Empty) {};
160
161PropertyInfo::PropertyInfo(const PropertyInfo& pi)
162 : d(pi.d)
163{
164}
165
166PropertyInfo::~PropertyInfo() = default;
167
168PropertyInfo& PropertyInfo::operator=(const PropertyInfo& rhs)
169{
170 d = rhs.d;
171 return *this;
172}
173
174bool PropertyInfo::operator==(const PropertyInfo& rhs) const
175{
176 return d == rhs.d;
177}
178
179QString PropertyInfo::displayName() const
180{
181 return d->displayName.toString();
182}
183
184QString PropertyInfo::name() const
185{
186 return d->name;
187}
188
189Property::Property PropertyInfo::property() const
190{
191 return d->prop;
192}
193
194QMetaType::Type PropertyInfo::valueType() const
195{
196 return d->valueType;
197}
198
199bool PropertyInfo::shouldBeIndexed() const
200{
201 return d->shouldBeIndexed;
202}
203
204QString PropertyInfo::formatAsDisplayString(const QVariant &value) const
205{
206 if (value.userType() == QMetaType::QVariantList || value.userType() == QMetaType::QStringList) {
207 if (d->valueType == QMetaType::QString) {
208 return QLocale().createSeparatedList(strl: value.toStringList());
209 } else {
210 QStringList displayList;
211 const auto valueList = value.toList();
212 for (const auto& entry : valueList) {
213 displayList << d->formatAsString(entry);
214 }
215 return QLocale().createSeparatedList(strl: displayList);
216 }
217 } else {
218 return d->formatAsString(value);
219 }
220}
221
222PropertyInfo PropertyInfo::fromName(const QString& name)
223{
224 PropertyInfo pi;
225 pi.d = PropertyInfoData::fromName(name);
226 return pi;
227}
228
229QStringList PropertyInfo::allNames()
230{
231 static QStringList sNames = []() {
232 QStringList names;
233 names.reserve(asize: PropertyInfoData::s_allProperties.size());
234 for (auto info: PropertyInfoData::s_allProperties) {
235 names.append(t: info.name);
236 }
237 return names;
238 }();
239 return sNames;
240}
241

source code of kfilemetadata/src/propertyinfo.cpp