filehandle.h 2.38 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
    FileHandle(const QString &path, CacheDataStream &s);
41 42
    ~FileHandle();

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

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

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

57 58
    void read(CacheDataStream &s);

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

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

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

private:
    class FileHandlePrivate;
    FileHandlePrivate *d;
71 72

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

75 76
typedef QValueList<FileHandle> FileHandleList;

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

80
#endif