filehandle.h 2.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/***************************************************************************
    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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef JUK_FILEHANDLE_H
17 18
#define JUK_FILEHANDLE_H

19
#include <qstringlist.h>
20

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

class Tag;
26
class CacheDataStream;
27 28 29 30 31 32 33 34 35 36 37

/**
 * An value based, explicitly shared wrapper around file related information
 * used in JuK's playlists.
 */

class FileHandle
{
public:
    FileHandle();
    FileHandle(const FileHandle &f);
38
    explicit FileHandle(const QFileInfo &info, const QString &path = QString::null);
39
    explicit FileHandle(const QString &path);
40 41
    ~FileHandle();

42 43 44 45
    /**
     * Forces the FileHandle to reread its information from the disk.
     */
    void refresh();
46
    void setFile(const QString &path);
47

48
    Tag *tag() const;
49 50
    QString absFilePath() const;
    const QFileInfo &fileInfo() const;
51

52
    bool isNull() const;
53 54 55
    bool current() const;
    const QDateTime &lastModified() const;

56 57
    void read(CacheDataStream &s);

58 59
    FileHandle &operator=(const FileHandle &f);
    bool operator==(const FileHandle &f) const;
60 61
    bool operator!=(const FileHandle &f) const;

62 63 64
    static QStringList properties();
    QString property(const QString &name) const;

65
    static const FileHandle &null();
66 67 68 69

private:
    class FileHandlePrivate;
    FileHandlePrivate *d;
70 71

    void setup(const QFileInfo &info, const QString &path);
72 73
};

74 75
typedef QValueList<FileHandle> FileHandleList;

76 77 78
QDataStream &operator<<(QDataStream &s, const FileHandle &f);
CacheDataStream &operator>>(CacheDataStream &s, FileHandle &f);

79
#endif