filehandle.h 2.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/**
 * Copyright (C) 2004 Scott Wheeler <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.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
16

17 18
#ifndef JUK_FILEHANDLE_H
#define JUK_FILEHANDLE_H
19

20
#include <QString>
21

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

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

31 32 33
template<class T>
class QList;

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

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

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

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

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

64 65
    void read(CacheDataStream &s);

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

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

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

private:
    class FileHandlePrivate;
    FileHandlePrivate *d;
78 79

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

82
typedef QList<FileHandle> FileHandleList;
83

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

87
#endif
88 89

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