filehandle.h 2.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/***************************************************************************
    begin                : Sun Feb 29 2004
    copyright            : (C) 2004 by Scott Wheeler
    email                : wheeler@kde.org
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

16 17
#ifndef FILEHANDLE_H
#define FILEHANDLE_H
18

19
#include <QString>
20

21 22 23
class QFileInfo;
class QDateTime;
class QDataStream;
24
class QStringList;
25

26
class CoverInfo;
27
class Tag;
28
class CacheDataStream;
29

30 31 32
template<class T>
class QList;

33 34 35 36 37 38 39 40 41 42
/**
 * An value based, explicitly shared wrapper around file related information
 * used in JuK's playlists.
 */

class FileHandle
{
public:
    FileHandle();
    FileHandle(const FileHandle &f);
43
    explicit FileHandle(const QFileInfo &info, const QString &path = QString());
44
    explicit FileHandle(const QString &path);
45
    FileHandle(const QString &path, CacheDataStream &s);
46 47
    ~FileHandle();

48 49 50 51
    /**
     * Forces the FileHandle to reread its information from the disk.
     */
    void refresh();
52
    void setFile(const QString &path);
53

54
    Tag *tag() const;
55
    CoverInfo *coverInfo() const;
56 57
    QString absFilePath() const;
    const QFileInfo &fileInfo() const;
58

59
    bool isNull() const;
60 61 62
    bool current() const;
    const QDateTime &lastModified() const;

63 64
    void read(CacheDataStream &s);

65 66
    FileHandle &operator=(const FileHandle &f);
    bool operator==(const FileHandle &f) const;
67 68
    bool operator!=(const FileHandle &f) const;

69 70 71
    static QStringList properties();
    QString property(const QString &name) const;

72
    static const FileHandle &null();
73 74 75 76

private:
    class FileHandlePrivate;
    FileHandlePrivate *d;
77 78

    void setup(const QFileInfo &info, const QString &path);
79 80
};

81
typedef QList<FileHandle> FileHandleList;
82

83 84 85
QDataStream &operator<<(QDataStream &s, const FileHandle &f);
CacheDataStream &operator>>(CacheDataStream &s, FileHandle &f);

86
#endif
87 88

// vim: set et sw=4 tw=0 sta: