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

0001 /*
0002     EmbeddedImageData extracts binary data of cover art files.
0003     SPDX-FileCopyrightText: 2018 Alexander Stippich <a.stippich@gmx.net>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef KFILEMETADATA_EMBEDDEDIMAGEDATA_H
0009 #define KFILEMETADATA_EMBEDDEDIMAGEDATA_H
0010 
0011 #include "kfilemetadata_export.h"
0012 #include <QByteArray>
0013 #include <QFlags>
0014 #include <QMap>
0015 #include <QMetaType>
0016 #include <memory>
0017 
0018 namespace KFileMetaData {
0019 
0020 /**
0021  * \class EmbeddedImageData embeddedimagedata.h <KFileMetaData/EmbeddedImageData>
0022  *
0023  * \brief EmbeddedImageData defines enums for different image types that can
0024  * be extracted from the metadata of e.g. music files
0025  * @todo KF6 make this an enum only in KF6 similar to properties.h
0026  */
0027 class KFILEMETADATA_EXPORT EmbeddedImageData {
0028 public:
0029     EmbeddedImageData();
0030     virtual ~EmbeddedImageData();
0031     /**
0032      * @see ImageTypes
0033      */
0034     enum ImageType {
0035         FrontCover = 1 << 0x0,
0036         Other = 1 << 0x01,
0037         FileIcon = 1 << 0x02,
0038         OtherFileIcon = 1 << 0x03,
0039         BackCover = 1 << 0x04,
0040         LeafletPage = 1 << 0x05,
0041         Media = 1 << 0x06,
0042         LeadArtist = 1 << 0x07,
0043         Artist = 1 << 0x08,
0044         Conductor = 1 << 0x09,
0045         Band = 1 << 0x0A,
0046         Composer = 1 << 0x0B,
0047         Lyricist = 1 << 0x0C,
0048         RecordingLocation = 1 << 0x0D,
0049         DuringRecording = 1 << 0x0E,
0050         DuringPerformance = 1 << 0x0F,
0051         MovieScreenCapture = 1 << 0x10,
0052         ColouredFish = 1 << 0x11,
0053         Illustration = 1 << 0x12,
0054         BandLogo = 1 << 0x13,
0055         PublisherLogo = 1 << 0x14,
0056         Unknown = 1 << 30,
0057         AllImages = 0x7fffffff
0058     };
0059     /**
0060      * Stores a combination of #ImageType values.
0061      */
0062     Q_DECLARE_FLAGS(ImageTypes, ImageType)
0063 
0064 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 91)
0065 
0066     /**
0067      * Extracts the images stored in the metadata tags from a file.
0068      * By default, the front cover is extracted.
0069      * @deprecated Since 5.91 Use ExtractorCollection and ExtractionResult::imageData() instead.
0070      */
0071 KFILEMETADATA_DEPRECATED_VERSION(5, 91, "Use ExtractorCollection and ExtractionResult::imageData() instead")
0072     QMap<ImageType, QByteArray> imageData(const QString &fileUrl, const EmbeddedImageData::ImageTypes types = FrontCover) const;
0073 
0074     /**
0075      * Provides a list of mimetypes which are supported for reading
0076      * of embedded images in e.g. audio files.
0077      * @since 5.52
0078      * @deprecated Since 5.91 Mimetypes are automatically handled when using the Extractor/WriterCollection.
0079      */
0080 KFILEMETADATA_DEPRECATED_VERSION(5, 91, "Mimetypes are automatically handled when using the Extractor/WriterCollection")
0081     QStringList mimeTypes() const;
0082     
0083     /**
0084      * Extracts the images stored in the metadata tags from a file.
0085      * By default, the front cover is extracted.
0086      * @deprecated Since 5.91 Use WriterCollection and WriteData::addImageData() instead.
0087      */
0088 KFILEMETADATA_DEPRECATED_VERSION(5, 91, "Use WriterCollection and WriteData::addImageData() instead")
0089     void writeImageData(const QString &fileUrl, QMap<ImageType, QByteArray> &imageData);
0090 #endif
0091 
0092 private:
0093     class Private;
0094     std::unique_ptr<Private> d;
0095     EmbeddedImageData& operator=(const EmbeddedImageData&);
0096 };
0097 
0098 }
0099 
0100 Q_DECLARE_METATYPE(KFileMetaData::EmbeddedImageData::ImageType)
0101 Q_DECLARE_METATYPE(KFileMetaData::EmbeddedImageData::ImageTypes)
0102 
0103 #endif // KFILEMETADATA_EMBEDDEDIMAGEDATA_H