File indexing completed on 2024-05-05 16:09:03

0001 /*
0002     This file is part of KFileMetaData
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef KFILEMETADATA_PROPERTIES
0009 #define KFILEMETADATA_PROPERTIES
0010 
0011 #include "kfilemetadata_export.h"
0012 
0013 #include <QMap>
0014 #include <QVariant>
0015 
0016 /** @file properties.h <KFileMetaData/Properties> */
0017 namespace KFileMetaData {
0018 namespace Property {
0019 
0020 /**
0021  * @brief The Property enum contains all files property types that KFileMetaData manipulates
0022  *
0023  * @todo KF6 remove PropertyCount and LastProperty such that one can easily add new properties
0024  */
0025 enum Property {
0026     FirstProperty = 0,
0027     Empty = 0,
0028 
0029     /**
0030      * The Bit Rate of the Audio in the File. Represented as an integer
0031      * in kbit/sec
0032      */
0033     BitRate,
0034 
0035     /**
0036      * The number of channels of the Audio in the File. Represented as an
0037      * integer.
0038      */
0039     Channels,
0040 
0041     /**
0042      * The duration of the media in the file. Represented as an integer
0043      * in seconds.
0044      */
0045     Duration,
0046 
0047     /**
0048      * The Genre of an Audio file. This s represented as a string
0049      * of genres and not integers. The IDv1 standard provides a list of
0050      * commonly excepted genres.
0051      */
0052     Genre,
0053 
0054     /**
0055      * The same rate or frequency of the Audio in the file. This is represented
0056      * as an integer in Hz. So a file with "44.1KHz" will have a frequency
0057      * of 44100
0058      */
0059     SampleRate,
0060 
0061     /**
0062      * Represents the track number in a set. Typically maps to the "TRCK" tag
0063      * in IDv3
0064      */
0065     TrackNumber,
0066 
0067     /**
0068      * Indicates the year a track was released. Represented as an integer.
0069      * Typically mapped to the "TYE (Year)" tag in IDv1
0070      */
0071     ReleaseYear,
0072 
0073     /**
0074      * Represents a comment stored in the file. This can map
0075      * to e.g. the "COMM" field from IDv3
0076      */
0077     Comment,
0078 
0079     /**
0080      * Represents the artist of a media file. This generally corresponds
0081      * to the IDv1 ARTIST tag. Many extractors often split this string
0082      * into a number of artists.
0083      */
0084     Artist,
0085 
0086     /**
0087      * Represents the album of a media file. This generally corresponds
0088      * to the IDv1 ALBUM tag.
0089      */
0090     Album,
0091 
0092     /**
0093      * Represents the album artist of a media file. This generally corresponds
0094      * to the IDv3 TPE2 ("Band/Orchestra/Accompaniment") tag.
0095      */
0096     AlbumArtist,
0097 
0098     /**
0099      * Represents the Composer of a media file. This generally corresponds
0100      * to the IDv2 COMPOSER tag.
0101      */
0102     Composer,
0103 
0104     /**
0105      * Represents the Lyricist of a media file. This generally corresponds
0106      * to the IDv2 "Lyricist/text writer" tag.
0107      */
0108     Lyricist,
0109 
0110     /**
0111      * The Author field indicated the primary creator of a document.
0112      * This often corresponds directly to dc:creator
0113      */
0114     Author,
0115 
0116     /**
0117      * Refers to the Title of the content of the file. This can represented
0118      * by the IDv1 tag TT2 (Title/songname/content description) or the TITLE
0119      * in a PDF file or the 'dc:title' tag in DublinCore.
0120      */
0121     Title,
0122 
0123     /**
0124      * Refers to the subject of the file. This directly corresponds to the
0125      * 'dc:subject' tag from DublinCore.
0126      */
0127     Subject,
0128 
0129     /**
0130      * Refers to the Application used to create this file. In the ODF standard
0131      * this maps to the 'meta:generator' tag. In PDFs its mapped to the
0132      * "Producer" tag.
0133      */
0134     Generator,
0135 
0136     /**
0137      * The number of pages in a document
0138      */
0139     PageCount,
0140 
0141     /**
0142      * The number of words in a document. This is often only provided for
0143      * documents where the word count is available in the metadata.
0144      */
0145     WordCount,
0146 
0147     /**
0148      * The number of lines in a document. This is often only provided for
0149      * documents where the line count is available in the metadata.
0150      */
0151     LineCount,
0152 
0153     /**
0154      * The language the document is written in. This directly maps to the
0155      * 'dc:language' tag from DublinCore. We do NOT employ any language
0156      * detection schemes on the text.
0157      * @since 5.50
0158      */
0159     Language,
0160 
0161 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 50)
0162     /**
0163      * Same as @c Language.
0164      * @deprecated Since 5.50, use @c Language instead
0165      */
0166     Langauge KFILEMETADATA_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 50, "Use Language") = Language,
0167 #endif
0168 
0169     /**
0170      * The copyright of the file. Represented as a string.
0171      */
0172     Copyright,
0173 
0174     /**
0175      * The publisher of the content. Represented as a string.
0176      */
0177     Publisher,
0178 
0179     /**
0180      * The date the content of the file was created. This is extracted
0181      * from the File MetaData and not from the file system.
0182      * In ODF, it corresponds to "meta:creation-date", in PDF to the
0183      * "CreationDate" tag, and otherwise the "dcterms:created" tag.
0184      */
0185     CreationDate,
0186 
0187     /**
0188      * The keywords used to represent the document. This is mostly a string list
0189      * of all the keywords.
0190      */
0191     Keywords,
0192 
0193     /**
0194      * Represents the width of the Media in pixels. This is generally
0195      * only applicable for Images and Videos.
0196      */
0197     Width,
0198 
0199     /**
0200      * Represents the height of the Media in pixels. This is generally
0201      * only applicable for Images and Videos.
0202      */
0203     Height,
0204 
0205     /**
0206      * The Aspect Ratio of the visual image or video.
0207      * It is the width of a pixel divided by the height of the pixel.
0208      */
0209     AspectRatio,
0210 
0211     /**
0212      * Number of frames per second
0213      */
0214     FrameRate,
0215 
0216     /**
0217      * The manufacturer of the equipment used for generating the file
0218      * and metadata. Typically maps to the 'Exif.Image.Make' tag.
0219      * @since 5.60
0220      */
0221     Manufacturer,
0222 
0223 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 60)
0224     /**
0225      * Same as @c Manufacturer.
0226      * @deprecated Since 5.60, use @c Manufacturer instead
0227      */
0228     ImageMake KFILEMETADATA_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 60, "Use Manufacturer") = Manufacturer,
0229 #endif
0230 
0231     /**
0232      * The model name of the equipment used for generating the file
0233      * and metadata. Typically maps to the 'Exif.Image.Model' tag.
0234      * @since 5.60
0235      */
0236     Model,
0237 
0238 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 60)
0239     /**
0240      * Same as @c Model.
0241      * @deprecated Since 5.60, use @c Model instead
0242      */
0243     ImageModel KFILEMETADATA_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 60, "Use Model") = Model,
0244 #endif
0245 
0246     ImageDateTime,
0247     ImageOrientation,
0248     PhotoFlash,
0249     PhotoPixelXDimension,
0250     PhotoPixelYDimension,
0251     PhotoDateTimeOriginal,
0252     PhotoFocalLength,
0253     PhotoFocalLengthIn35mmFilm,
0254     PhotoExposureTime,
0255     PhotoFNumber,
0256     PhotoApertureValue,
0257     PhotoExposureBiasValue,
0258     PhotoWhiteBalance,
0259     PhotoMeteringMode,
0260     PhotoISOSpeedRatings,
0261     PhotoSaturation,
0262     PhotoSharpness,
0263     PhotoGpsLatitude,
0264     PhotoGpsLongitude,
0265     PhotoGpsAltitude,
0266 
0267     TranslationUnitsTotal,
0268     TranslationUnitsWithTranslation,
0269     TranslationUnitsWithDraftTranslation,
0270     TranslationLastAuthor,
0271     TranslationLastUpDate,
0272     TranslationTemplateDate,
0273 
0274     /**
0275      * The URL this file has originally been downloaded from.
0276      */
0277     OriginUrl,
0278 
0279     /**
0280      * The subject of the email this file was originally attached to.
0281      */
0282     OriginEmailSubject,
0283 
0284     /**
0285      * The sender of the email this file was originally attached to.
0286      */
0287     OriginEmailSender,
0288 
0289     /**
0290      * The message ID of the email this file was originally attached to.
0291      */
0292     OriginEmailMessageId,
0293 
0294     /**
0295      * Represents the disc number in a multi-disc set. Typically maps to the "TPOS" tag for mp3
0296      */
0297     DiscNumber,
0298 
0299     /**
0300      * Represents the location where an audio file was recorded.
0301      */
0302     Location,
0303 
0304     /**
0305      * Represents the (lead) performer of an audio file.
0306      */
0307     Performer,
0308 
0309     /**
0310      * Represents the ensemble of an audio file.
0311      */
0312     Ensemble,
0313 
0314     /**
0315      * Represents the arranger of an audio file.
0316      */
0317     Arranger,
0318 
0319     /**
0320      * Represents the conductor of an audio file.
0321      */
0322     Conductor,
0323 
0324     /**
0325      * Represents the opus of an audio file mostly used for classical music.
0326      */
0327     Opus,
0328 
0329     /**
0330      * Represents the label of the content.
0331      */
0332     Label,
0333 
0334     /**
0335      * Contains the name of the compilation of an audio file.
0336      */
0337     Compilation,
0338 
0339     /**
0340      * Contains the license information of the file
0341      */
0342     License,
0343 
0344     /**
0345      * For ratings stored in Metadata tags
0346      */
0347     Rating,
0348     /**
0349      * Contains the lyrics of a song embedded in the file
0350      */
0351     Lyrics,
0352     /**
0353       * Contains ReplayGain information for audio files
0354       */
0355     ReplayGainAlbumPeak,
0356     /**
0357       * Contains ReplayGain information for audio files
0358       * The album gain is given in "dB"
0359       */
0360     ReplayGainAlbumGain,
0361     /**
0362       * Contains ReplayGain information for audio files
0363       */
0364     ReplayGainTrackPeak,
0365     /**
0366       * Contains ReplayGain information for audio files
0367       * The track gain is given in "dB"
0368       */
0369     ReplayGainTrackGain,
0370 
0371     /**
0372      * Represents the description stored in the file. This maps
0373      * to the 'dc:description' tag from DublinCore
0374      */
0375     Description,
0376 
0377     PropertyCount,
0378     LastProperty = PropertyCount-1,
0379 
0380 };
0381 
0382 } // namespace Property
0383 
0384 typedef QMap<Property::Property, QVariant> PropertyMap;
0385 using PropertyMultiMap = QMultiMap<Property::Property, QVariant>;
0386 
0387 #if QT_DEPRECATED_SINCE(5, 15)
0388 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 89)
0389 QT_WARNING_PUSH
0390 QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
0391 QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
0392 
0393 KFILEMETADATA_DEPRECATED_VERSION(5, 89, "Deprecated for lack of usage, manaully convert the data if needed")
0394 inline QVariantMap toVariantMap(const PropertyMap& propMap) {
0395     QVariantMap varMap;
0396     PropertyMap::const_iterator it = propMap.constBegin();
0397     for (; it != propMap.constEnd(); ++it) {
0398         int p = static_cast<int>(it.key());
0399         varMap.insertMulti(QString::number(p), it.value());
0400     }
0401 
0402     return varMap;
0403 }
0404 
0405 KFILEMETADATA_DEPRECATED_VERSION(5, 89, "Deprecated for lack of usage, manaully convert the data if needed")
0406 inline PropertyMap toPropertyMap(const QVariantMap& varMap) {
0407     PropertyMap propMap;
0408     QVariantMap::const_iterator it = varMap.constBegin();
0409     for (; it != varMap.constEnd(); ++it) {
0410         int p = it.key().toInt();
0411         propMap.insertMulti(static_cast<Property::Property>(p), it.value());
0412     }
0413 
0414     return propMap;
0415 }
0416 QT_WARNING_POP
0417 #endif
0418 #endif
0419 
0420 } // namespace KFileMetaData
0421 
0422 Q_DECLARE_METATYPE(KFileMetaData::Property::Property)
0423 
0424 #endif