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