metabundle.h

来自「Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 」· C头文件 代码 · 共 546 行 · 第 1/2 页

H
546
字号
// Max Howell <max.howell@methylblue.com>, (C) 2004// Alexandre Pereira de Oliveira <aleprj@gmail.com>, (C) 2005// Shane King <kde@dontletsstart.com>, (C) 2006// Peter C. Ndikuwera <pndiku@gmail.com>, (C) 2006// License: GNU General Public License V2#ifndef METABUNDLE_H#define METABUNDLE_H#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)#define PRETTY_TITLE_CACHE#endif#include <qstringlist.h>#include <kurl.h>    //inline functions#include <klocale.h> //inline functions#include <taglib/audioproperties.h>#include "expression.h"#include "atomicstring.h"#include "moodbar.h"#include "amarok_export.h"class KFileMetaInfo;class QDir;class QTextStream;template<class T> class QValueList;namespace TagLib {    class ByteVector;    class File;    class FileRef;    class String;    namespace ID3v2 {        class UniqueFileIdentifierFrame;        class Tag;    }    namespace MPEG {        class File;    }}class PodcastEpisodeBundle;namespace LastFm {    class Bundle;}/** * @class MetaBundle * @author Max Howell <max.howell@methylblue.com> * * If this class doesn't work for you in some way, extend it sensibly :) * */class LIBAMAROK_EXPORT MetaBundle{public:    enum Column    {        Filename = 0,        Title,        Artist,        AlbumArtist,        Composer,        Year,        Album,        DiscNumber,        Track,        Bpm,        Genre,        Comment,        Directory,        Type,        Length,        Bitrate,        SampleRate,        Score,        Rating,        PlayCount,        LastPlayed,        Mood,        Filesize,        NUM_COLUMNS    };    class LIBAMAROK_EXPORT EmbeddedImage {    public:        EmbeddedImage() {}        EmbeddedImage( const TagLib::ByteVector& data, const TagLib::String& description );        const QCString &hash() const;        const QString &description() const { return m_description; }        bool save( const QDir& dir ) const;    private:        QByteArray m_data;        QString m_description;        mutable QCString m_hash;   };    typedef QValueList<EmbeddedImage> EmbeddedImageList;    /** This is a bit vector for selecting columns. It's very fast to compare        in matchFast. It might be a good idea to replace the QValue<int>        column masks with this eventually. */    typedef Q_UINT32 ColumnMask;    /** Returns the name of the column at \p index as a string -- not i18ned, for internal purposes. */    static const QString &exactColumnName( int index );    /** Returns the name of the column at \p index as a string -- i18ned, for display purposes. */    static const QString prettyColumnName( int index );    /** Returns the index of the column with the not i18ned name \p name. */    static int columnIndex( const QString &name );    // These values are stored on the Database, so, don't change the order. Only append new ones to the end.    enum FileType { other, mp3, ogg, wma, mp4, flac, ra, rv, rm, rmj, rmvb, asf };    //for the audioproperties    static const int Undetermined = -2; /// we haven't yet read the tags    static const int Irrelevant   = -1; /// not applicable to this stream/media type, eg length for http streams    static const int Unavailable  =  0; /// cannot be obtained    // whether file is part of a compilation    enum Compilation { CompilationNo = 0, CompilationYes = 1, CompilationUnknown = -1 };    /// Creates an empty MetaBundle    LIBAMAROK_EXPORT MetaBundle();    /// Creates a MetaBundle for url, tags will be obtained and set    LIBAMAROK_EXPORT explicit MetaBundle( const KURL &url,                                          bool noCache = false,                                          TagLib::AudioProperties::ReadStyle = TagLib::AudioProperties::Fast,                                          EmbeddedImageList* images = 0 );    /** For the StreamProvider */    LIBAMAROK_EXPORT MetaBundle( const QString &title,            const QString &streamUrl,            const int bitrate,            const QString &genre,            const QString &streamName,            const KURL &url );    LIBAMAROK_EXPORT MetaBundle( const MetaBundle &bundle );    ~MetaBundle();    MetaBundle& operator=( const MetaBundle& bundle );    bool operator==( const MetaBundle& bundle ) const;    bool operator!=( const MetaBundle& bundle ) const;    /** Test for an empty metabundle */    bool isEmpty() const;    /** Empty the metabundle */    void clear();    /** Is it media that has metadata? Note currently we don't check for an audio mimetype */    bool isValidMedia() const;    /** The bundle doesn't yet know its audioProperties */    bool audioPropertiesUndetermined() const;    /** The embedded artwork in the file (loaded from file into images variable, unmodified if no images present/loadable) */    void embeddedImages(EmbeddedImageList &images) const;    /** If you want Accurate reading say so. If EmbeddedImageList != NULL, embedded art is loaded into it */    void readTags( TagLib::AudioProperties::ReadStyle = TagLib::AudioProperties::Fast, EmbeddedImageList* images = 0 );    /** Saves the changes to the file using the transactional algorithm for safety. */    bool safeSave();    /** Saves the changes to the file. Returns false on error. */    bool save( TagLib::FileRef* fileref = 0 );    /** Saves the MetaBundle's data as XML to a text stream. */    bool save( QTextStream &stream, const QStringList &attributes = QStringList() ) const;    /** Returns whether the url referred to is a local file */    bool isFile() const;    /** Returns whether the url referred to can be accessed via kio slaves */    bool isKioUrl() const;    /** Returns whether url can be accessed via kio slaves */    static bool isKioUrl( const KURL &url );    /** Returns whether composer, disc number and bpm fields are available. */    bool hasExtendedMetaInformation() const;    void copyFrom( const MetaBundle& bundle );    void copyFrom( const PodcastEpisodeBundle &peb );    /** Returns a string representation of the tag at \p column, in a format suitable for internal purposes.        For example, for a track 3:24 long, it'll return "204" (seconds).        This should not be used for displaying the tag to the user. */    QString exactText( int column, bool ensureCached = false ) const;    /** Sets the tag at \p column from a string in the same format as returned by exactText(). */    void setExactText( int column, const QString &text );    /** Returns the tag at \p column in a format suitable for displaying to the user. */    QString prettyText( int column ) const;    /** Returns whether the bundle matches \p expression.        This is fast and doesn't take advanced syntax into account,        and should only be used when it is certain none is present.        The tags in \p columns are checked for matches.        @see ExpressionParser::isAdvancedExpression() */    bool matchesSimpleExpression( const QString &expression, const QValueList<int> &columns ) const;    /** A faster version of the above, that pre-caches all the data to be        searched in a single string, to avoid re-building integer and lower        case strings over and over. It is designed to be called from a        playlist search *only* -- it is not entirely thread-safe for efficiency,        although it's highly unlikely to crash. Consider this the beginning        of a real super-efficient index (e.g. suffix tree).        \p terms is a list of lower-case words. */    bool matchesFast(const QStringList &terms, ColumnMask columns) const;    /** Returns whether the bundle matches \p expression.        This takes advanced syntax into account, and is slightly slower than matchesSimpleExpression().        The tags in \p defaultColumns are checked for matches where the expression doesn't specify any manually. */    bool matchesExpression( const QString &expression, const QValueList<int> &defaultColumns ) const;    /** Returns whether the bundle matches the pre-parsed expression \p parsedData.        The tags in \p defaultColumns are checked for matches where the expression doesn't specify any manually.        @see ExpressionParser */    bool matchesParsedExpression( const ParsedExpression &parsedData, const QValueList<int> &defaultColumns ) const;    /** PlaylistItem reimplements this so it can be informed of moodbar        data events without having to use signals */    virtual void moodbarJobEvent( int newState )        { (void) newState; }public:    /**     * A class to load MetaBundles from XML.     * #include "xmlloader.h"     */    class XmlLoader;public: //accessors    const KURL &url()               const;    QString      title()     const;    AtomicString artist()    const;    AtomicString albumArtist() const;    AtomicString composer()  const;    AtomicString album()     const;    AtomicString genre()     const;    AtomicString comment()   const;    QString      filename()  const;    QString      directory() const;    QString      type()      const;    int     year()        const;    int     discNumber()  const;    int     track()       const;    float   bpm()         const;    int     length()      const;    int     bitrate()     const;    int     sampleRate()  const;    float   score( bool ensureCached = false )      const;    int     rating( bool ensureCached = false )     const; //returns rating * 2, to accommodate .5 ratings    int     playCount( bool ensureCached = false )  const;    uint    lastPlay( bool ensureCached = false )   const;    Moodbar       &moodbar();    const Moodbar &moodbar_const() const;    int     filesize()    const;    int compilation() const;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?