File indexing completed on 2024-05-05 16:08:26

0001 /* This file is part of the KDE libraries
0002 
0003    Copyright (c) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
0004                  2007 Jos van den Oever <jos@vandenoever.info>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License (LGPL) as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 #ifndef KFILEMETAINFO_H
0022 #define KFILEMETAINFO_H
0023 
0024 #include "predicateproperties.h"
0025 #include "kfilemetainfoitem.h"
0026 #include <QList>
0027 #include <QStringList>
0028 #include <QUrl>
0029 class QUrl;
0030 
0031 typedef QList<KFileMetaInfoItem> KFileMetaInfoItemList;
0032 
0033 class KFileMetaInfoGroupPrivate;
0034 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KFileMetaInfoGroup
0035 {
0036 public:
0037     KFileMetaInfoGroup();
0038     KFileMetaInfoGroup(const KFileMetaInfoGroup &);
0039     ~KFileMetaInfoGroup();
0040     const KFileMetaInfoGroup &operator=(const KFileMetaInfoGroup &);
0041     KFileMetaInfoItemList items() const;
0042     const QString &name() const;
0043     const QStringList &keys() const;
0044 private:
0045     QSharedDataPointer<KFileMetaInfoGroupPrivate> d;
0046 };
0047 
0048 typedef QList<KFileMetaInfoGroup> KFileMetaInfoGroupList;
0049 
0050 class KFileMetaInfoPrivate;
0051 /**
0052  * KFileMetaInfo provides metadata extracted from a file or other resource.
0053  *
0054  * When instantiating an instance of this class, the metadata related to it
0055  * will be retrieved and stored in the instance. The data can be inspected
0056  * through KFileMetaInfoItem objects.
0057  **/
0058 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KFileMetaInfo
0059 {
0060 public:
0061     /**
0062      * This is used to specify what a KFileMetaInfo object should read, so
0063      * you can specify if you want to read "expensive" items or not.
0064      * This is like a preset which can be customized by passing additional
0065      * parameters to constructors.
0066      */
0067     enum What {
0068         Fastest       = 0x1,  /**< do the fastest possible read and omit all items
0069                                  that might need a significantly longer time
0070                                  than the others */
0071 // Deprecated
0072 //      DontCare      = 0x2,  ///< let the plugin decide what to read.
0073 
0074         TechnicalInfo = 0x4,  /**< extract technical details about the file, like
0075                                  e.g. play time, resolution or a compressioni
0076                                  type */
0077         ContentInfo   = 0x8,  /**< read information about the content of the file
0078                                  like comments or id3 tags */
0079         ExternalSources = 0x10, /**<read external metadata sources such as
0080                                  filesystem based extended attributes if
0081                                  they are supported for the filesystem;
0082                                  RDF storages etc */
0083         Thumbnail     = 0x20, /**< only read the file's thumbnail, if it contains
0084                                  one */
0085 // Deprecated
0086 //      Preferred     = 0x40,  ///< get at least the preferred items
0087         LinkedData    = 0x80, //< extract linked/related files like html links, source #include etc
0088         Everything    = 0xffff ///< read everything, even if it might take a while
0089 
0090     };
0091     Q_DECLARE_FLAGS(WhatFlags, What)
0092 
0093     /**
0094      * @brief Construct a KFileMetaInfo that contains metainformation about
0095      * the resource pointed to by @p path.
0096      *
0097      * When w is not Everything, a limit of 64kbytes is imposed on the file size.
0098      **/
0099     KDELIBS4SUPPORT_DEPRECATED explicit KFileMetaInfo(const QString &path, const QString &mimetype = QString(),
0100                            WhatFlags w = Everything);
0101     /**
0102      * @brief Construct a KFileMetaInfo that contains metainformation about
0103      * the resource pointed to by @p url.
0104      * @note that c'tor is not thread-safe
0105      **/
0106     KFileMetaInfo(const QUrl &url);
0107     /**
0108      * @brief Construct an empty, invalid KFileMetaInfo instance.
0109      **/
0110     KFileMetaInfo();
0111     /**
0112      * @brief Construct a KFileMetaInfo instance from another one.
0113      **/
0114     KFileMetaInfo(const KFileMetaInfo &);
0115     /**
0116      * @brief Destructor.
0117      **/
0118     ~KFileMetaInfo();
0119     /**
0120      * @brief Copy a KFileMetaInfo instance from another one.
0121      **/
0122     KFileMetaInfo &operator=(KFileMetaInfo const &kfmi);
0123     /**
0124      * @brief Save the changes made to this KFileMetaInfo instance.
0125      */
0126     bool applyChanges();
0127     /**
0128      * @brief Retrieve all the items.
0129      **/
0130     const QHash<QString, KFileMetaInfoItem> &items() const;
0131     KFileMetaInfoItem &item(const QString &key);
0132     const KFileMetaInfoItem &item(const QString &key) const;
0133     bool isValid() const;
0134     /**
0135      * Deprecated
0136      **/
0137     QStringList preferredKeys() const;
0138     /**
0139      * Deprecated
0140      **/
0141     QStringList supportedKeys() const;
0142     KDELIBS4SUPPORT_DEPRECATED_EXPORT friend QDataStream &operator >>(QDataStream &s, KFileMetaInfo &)
0143     ;
0144     KDELIBS4SUPPORT_DEPRECATED_EXPORT friend QDataStream &operator <<(QDataStream &s, const KFileMetaInfo &);
0145     /**
0146      * Deprecated
0147      **/
0148 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0149     KDELIBS4SUPPORT_DEPRECATED KFileMetaInfoGroupList preferredGroups() const;
0150 #endif
0151     /**
0152      * Deprecated
0153      **/
0154 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0155     KDELIBS4SUPPORT_DEPRECATED KFileMetaInfoGroupList supportedGroups() const;
0156 #endif
0157     KFileMetaInfoGroupList groups() const;
0158     QStringList keys() const;
0159     QUrl url() const;
0160 
0161 private:
0162     QSharedDataPointer<KFileMetaInfoPrivate> d;
0163 };
0164 
0165 Q_DECLARE_OPERATORS_FOR_FLAGS(KFileMetaInfo::WhatFlags)
0166 
0167 #endif