filehandle.h 2.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/***************************************************************************
                          filehandle.h
                             -------------------
    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
19 20 21 22 23
#define JUK_FILEHANDLE_H

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 62
    bool operator!=(const FileHandle &f) const;

    static const FileHandle &null();
63 64 65 66

private:
    class FileHandlePrivate;
    FileHandlePrivate *d;
67 68

    void setup(const QFileInfo &info, const QString &path);
69 70
};

71 72 73
QDataStream &operator<<(QDataStream &s, const FileHandle &f);
CacheDataStream &operator>>(CacheDataStream &s, FileHandle &f);

74
#endif