filehandle.h 2.3 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 <QExplicitlySharedDataPointer>
21

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

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

32 33 34
template<class T>
class QList;

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

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

    // manually declared so its definition can be delayed until .cpp
50 51
    ~FileHandle();

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

58
    Tag *tag() const;
59
    CoverInfo *coverInfo() const;
60 61
    QString absFilePath() const;
    const QFileInfo &fileInfo() const;
62

63
    bool isNull() const;
64 65 66
    bool current() const;
    const QDateTime &lastModified() const;

67 68
    void read(CacheDataStream &s);

69 70
    FileHandle &operator=(const FileHandle &f);
    bool operator==(const FileHandle &f) const;
71 72
    bool operator!=(const FileHandle &f) const;

73 74 75
    static QStringList properties();
    QString property(const QString &name) const;

76 77
private:
    class FileHandlePrivate;
78
    QExplicitlySharedDataPointer<FileHandlePrivate> d;
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: