1 | /* |
2 | * This file is part of KFileMetaData |
3 | * Copyright (C) 2014 Vishesh Handa <me@vhanda.in> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2.1 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
18 | * |
19 | */ |
20 | |
21 | #ifndef KFILEMETADATA_PROPERTIES |
22 | #define KFILEMETADATA_PROPERTIES |
23 | |
24 | #include <QMap> |
25 | #include <QVariant> |
26 | |
27 | /** @file properties.h <KFileMetaData/Properties> */ |
28 | namespace KFileMetaData { |
29 | namespace Property { |
30 | |
31 | /** |
32 | * @brief The Property enum contains all files property types that KFileMetaData manipulates |
33 | * |
34 | * @todo KF6 remove PropertyCount and LastProperty such that one can easily add new properties |
35 | */ |
36 | enum Property { |
37 | FirstProperty = 0, |
38 | Empty = 0, |
39 | |
40 | /** |
41 | * The Bit Rate of the Audio in the File. Represented as an integer |
42 | * in kbit/sec |
43 | */ |
44 | BitRate, |
45 | |
46 | /** |
47 | * The number of channels of the Audio in the File. Represented as an |
48 | * integer. |
49 | */ |
50 | Channels, |
51 | |
52 | /** |
53 | * The duration of the media in the file. Represented as an integer |
54 | * in seconds. |
55 | */ |
56 | Duration, |
57 | |
58 | /** |
59 | * The Genre of an Audio file. This s represented as a string |
60 | * of genres and not integers. The IDv1 standard provides a list of |
61 | * commonly excepted genres. |
62 | */ |
63 | Genre, |
64 | |
65 | /** |
66 | * The same rate or frequency of the Audio in the file. This is represented |
67 | * as an integer in Hz. So a file with "44.1KHz" will have a frequency |
68 | * of 44100 |
69 | */ |
70 | SampleRate, |
71 | |
72 | /** |
73 | * Represents the track number in a set. Typically maps to the "TRCK" tag |
74 | * in IDv3 |
75 | */ |
76 | TrackNumber, |
77 | |
78 | /** |
79 | * Indicates the year a track was released. Represented as an integer. |
80 | * Typically mapped to the "TYE (Year)" tag in IDv1 |
81 | */ |
82 | ReleaseYear, |
83 | |
84 | /** |
85 | * Represents a comment stored in the file. This can map |
86 | * to e.g. the "COMM" field from IDv3 |
87 | */ |
88 | , |
89 | |
90 | /** |
91 | * Represents the artist of a media file. This generally corresponds |
92 | * to the IDv1 ARTIST tag. Many extractors often split this string |
93 | * into a number of artists. |
94 | */ |
95 | Artist, |
96 | |
97 | /** |
98 | * Represents the album of a media file. This generally corresponds |
99 | * to the IDv1 ALBUM tag. |
100 | */ |
101 | Album, |
102 | |
103 | /** |
104 | * Represents the album artist of a media file. This generally corresponds |
105 | * to the IDv3 TPE2 ("Band/Orchestra/Accompaniment") tag. |
106 | */ |
107 | AlbumArtist, |
108 | |
109 | /** |
110 | * Represents the Composer of a media file. This generally corresponds |
111 | * to the IDv2 COMPOSER tag. |
112 | */ |
113 | Composer, |
114 | |
115 | /** |
116 | * Represents the Lyricist of a media file. This generally corresponds |
117 | * to the IDv2 "Lyricist/text writer" tag. |
118 | */ |
119 | Lyricist, |
120 | |
121 | /** |
122 | * The Author field indicated the primary creator of a document. |
123 | * This often corresponds directly to dc:creator |
124 | */ |
125 | Author, |
126 | |
127 | /** |
128 | * Refers to the Title of the content of the file. This can represented |
129 | * by the IDv1 tag TT2 (Title/songname/content description) or the TITLE |
130 | * in a PDF file or the 'dc:title' tag in DublinCore. |
131 | */ |
132 | Title, |
133 | |
134 | /** |
135 | * Refers to the subject of the file. This directly corresponds to the |
136 | * 'dc:subject' tag from DublinCore. |
137 | */ |
138 | Subject, |
139 | |
140 | /** |
141 | * Refers to the Application used to create this file. In the ODF standard |
142 | * this maps to the 'meta:generator' tag. In PDFs its mapped to the |
143 | * "Producer" tag. |
144 | */ |
145 | Generator, |
146 | |
147 | /** |
148 | * The number of pages in a document |
149 | */ |
150 | PageCount, |
151 | |
152 | /** |
153 | * The number of words in a document. This is often only provided for |
154 | * documents where the word count is available in the metadata. |
155 | */ |
156 | WordCount, |
157 | |
158 | /** |
159 | * The number of lines in a document. This is often only provided for |
160 | * documents where the line count is available in the metadata. |
161 | */ |
162 | LineCount, |
163 | |
164 | /** |
165 | * Same as @c Language. |
166 | * @deprecated Since 5.50, use @c Language instead |
167 | */ |
168 | Langauge, |
169 | /** |
170 | * The language the document is written in. This directly maps to the |
171 | * 'dc:language' tag from DublinCore. We do NOT employ any language |
172 | * detection schemes on the text. |
173 | * @since 5.50 |
174 | */ |
175 | Language = Langauge, |
176 | |
177 | /** |
178 | * The copyright of the file. Represented as a string. |
179 | */ |
180 | Copyright, |
181 | |
182 | /** |
183 | * The publisher of the content. Represented as a string. |
184 | */ |
185 | Publisher, |
186 | |
187 | /** |
188 | * The date the content of the file was created. This is extracted |
189 | * from the File MetaData and not from the file system. |
190 | * In ODF, it corresponds to "meta:creation-date", in PDF to the |
191 | * "CreationDate" tag, and otherwise the "dcterms:created" tag. |
192 | */ |
193 | CreationDate, |
194 | |
195 | /** |
196 | * The keywords used to represent the document. This is mostly a string list |
197 | * of all the keywords. |
198 | */ |
199 | Keywords, |
200 | |
201 | /** |
202 | * Represents the width of the Media in pixels. This is generally |
203 | * only applicable for Images and Videos. |
204 | */ |
205 | Width, |
206 | |
207 | /** |
208 | * Represents the height of the Media in pixels. This is generally |
209 | * only applicable for Images and Videos. |
210 | */ |
211 | Height, |
212 | |
213 | /** |
214 | * The Aspect Ratio of the visual image or video. |
215 | * It is the width of a pixel divided by the height of the pixel. |
216 | */ |
217 | AspectRatio, |
218 | |
219 | /** |
220 | * Number of frames per second |
221 | */ |
222 | FrameRate, |
223 | |
224 | /** |
225 | * Same as @c EquipmentManufacturer. |
226 | * @deprecated Since 5.60, use @c Manufacturer instead |
227 | */ |
228 | ImageMake, |
229 | /** |
230 | * The manufacturer of the equipment used for generating the file |
231 | * and metadata. Typically maps to the 'Exif.Image.Make' tag. |
232 | * @since 5.60 |
233 | */ |
234 | Manufacturer = ImageMake, |
235 | |
236 | /** |
237 | * Same as @c EquipmentModel. |
238 | * @deprecated Since 5.60, use @c Model instead |
239 | */ |
240 | ImageModel, |
241 | /** |
242 | * The model name of the equipment used for generating the file |
243 | * and metadata. Typically maps to the 'Exif.Image.Model' tag. |
244 | * @since 5.60 |
245 | */ |
246 | Model = ImageModel, |
247 | |
248 | ImageDateTime, |
249 | ImageOrientation, |
250 | PhotoFlash, |
251 | PhotoPixelXDimension, |
252 | PhotoPixelYDimension, |
253 | PhotoDateTimeOriginal, |
254 | PhotoFocalLength, |
255 | PhotoFocalLengthIn35mmFilm, |
256 | PhotoExposureTime, |
257 | PhotoFNumber, |
258 | PhotoApertureValue, |
259 | PhotoExposureBiasValue, |
260 | PhotoWhiteBalance, |
261 | PhotoMeteringMode, |
262 | PhotoISOSpeedRatings, |
263 | PhotoSaturation, |
264 | PhotoSharpness, |
265 | PhotoGpsLatitude, |
266 | PhotoGpsLongitude, |
267 | PhotoGpsAltitude, |
268 | |
269 | TranslationUnitsTotal, |
270 | TranslationUnitsWithTranslation, |
271 | TranslationUnitsWithDraftTranslation, |
272 | TranslationLastAuthor, |
273 | TranslationLastUpDate, |
274 | TranslationTemplateDate, |
275 | |
276 | /** |
277 | * The URL this file has originally been downloaded from. |
278 | */ |
279 | OriginUrl, |
280 | |
281 | /** |
282 | * The subject of the email this file was originally attached to. |
283 | */ |
284 | OriginEmailSubject, |
285 | |
286 | /** |
287 | * The sender of the email this file was originally attached to. |
288 | */ |
289 | OriginEmailSender, |
290 | |
291 | /** |
292 | * The message ID of the email this file was originally attached to. |
293 | */ |
294 | OriginEmailMessageId, |
295 | |
296 | /** |
297 | * Represents the disc number in a multi-disc set. Typically maps to the "TPOS" tag for mp3 |
298 | */ |
299 | DiscNumber, |
300 | |
301 | /** |
302 | * Represents the location where an audio file was recorded. |
303 | */ |
304 | Location, |
305 | |
306 | /** |
307 | * Represents the (lead) performer of an audio file. |
308 | */ |
309 | Performer, |
310 | |
311 | /** |
312 | * Represents the ensemble of an audio file. |
313 | */ |
314 | Ensemble, |
315 | |
316 | /** |
317 | * Represents the arranger of an audio file. |
318 | */ |
319 | Arranger, |
320 | |
321 | /** |
322 | * Represents the conductor of an audio file. |
323 | */ |
324 | Conductor, |
325 | |
326 | /** |
327 | * Represents the opus of an audio file mostly used for classical music. |
328 | */ |
329 | Opus, |
330 | |
331 | /** |
332 | * Represents the label of the content. |
333 | */ |
334 | Label, |
335 | |
336 | /** |
337 | * Contains the name of the compilation of an audio file. |
338 | */ |
339 | Compilation, |
340 | |
341 | /** |
342 | * Contains the license information of the file |
343 | */ |
344 | License, |
345 | |
346 | /** |
347 | * For ratings stored in Metadata tags |
348 | */ |
349 | Rating, |
350 | /** |
351 | * Contains the lyrics of a song embedded in the file |
352 | */ |
353 | Lyrics, |
354 | /** |
355 | * Contains ReplayGain information for audio files |
356 | */ |
357 | ReplayGainAlbumPeak, |
358 | /** |
359 | * Contains ReplayGain information for audio files |
360 | * The album gain is given in "dB" |
361 | */ |
362 | ReplayGainAlbumGain, |
363 | /** |
364 | * Contains ReplayGain information for audio files |
365 | */ |
366 | ReplayGainTrackPeak, |
367 | /** |
368 | * Contains ReplayGain information for audio files |
369 | * The track gain is given in "dB" |
370 | */ |
371 | ReplayGainTrackGain, |
372 | |
373 | /** |
374 | * Represents the description stored in the file. This maps |
375 | * to the 'dc:description' tag from DublinCore |
376 | */ |
377 | Description, |
378 | |
379 | PropertyCount, |
380 | LastProperty = PropertyCount-1, |
381 | |
382 | }; |
383 | |
384 | } // namespace Property |
385 | |
386 | typedef QMap<Property::Property, QVariant> PropertyMap; |
387 | |
388 | inline QVariantMap toVariantMap(const PropertyMap& propMap) { |
389 | QVariantMap varMap; |
390 | PropertyMap::const_iterator it = propMap.constBegin(); |
391 | for (; it != propMap.constEnd(); ++it) { |
392 | int p = static_cast<int>(it.key()); |
393 | varMap.insertMulti(QString::number(p), it.value()); |
394 | } |
395 | |
396 | return varMap; |
397 | } |
398 | |
399 | inline PropertyMap toPropertyMap(const QVariantMap& varMap) { |
400 | PropertyMap propMap; |
401 | QVariantMap::const_iterator it = varMap.constBegin(); |
402 | for (; it != varMap.constEnd(); ++it) { |
403 | int p = it.key().toInt(); |
404 | propMap.insertMulti(static_cast<Property::Property>(p), it.value()); |
405 | } |
406 | |
407 | return propMap; |
408 | } |
409 | |
410 | } // namespace KFileMetaData |
411 | |
412 | Q_DECLARE_METATYPE(KFileMetaData::Property::Property) |
413 | |
414 | #endif |
415 | |