filehandle.h 2.37 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
#include <QVector>
22
#include <QMetaType>
23

24
class QString;
25 26 27
class QFileInfo;
class QDateTime;
class QDataStream;
28
class QStringList;
29

30
class CoverInfo;
31
class Tag;
32
class CacheDataStream;
33 34

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

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

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

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

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

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

66 67
    void read(CacheDataStream &s);

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

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

75 76
private:
    class FileHandlePrivate;
77
    QExplicitlySharedDataPointer<FileHandlePrivate> d;
78 79
};

80
typedef QVector<FileHandle> FileHandleList;
81

82 83 84
Q_DECLARE_METATYPE(FileHandle);
Q_DECLARE_METATYPE(FileHandleList);

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

88
#endif
89 90

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