summaryrefslogtreecommitdiffstats
path: root/juk/tag.h
blob: 771c0cba2c4b8d2ac3cf56f9543cae5ca2284fe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/***************************************************************************
    begin                : Sun Feb 17 2002
    copyright            : (C) 2002 - 2004 by Scott Wheeler
    email                : [email protected]
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 TAG_H
#define TAG_H

#include <tqfileinfo.h>

namespace TagLib { class File; }

class CacheDataStream;

/*!
 * This should really be called "metadata" and may at some point be titled as
 * such.  Right now it's mostly a TQt wrapper around TagLib.
 */

class Tag
{
    friend class FileHandle;
public:
    Tag(const TQString &fileName);
    /**
     * Create an empty tag.  Used in FileHandle for cache restoration.
     */
    Tag(const TQString &fileName, bool);

    bool save();

    TQString title() const { return m_title; }
    TQString artist() const { return m_artist; }
    TQString album() const { return m_album; }
    TQString genre() const { return m_genre; }
    int track() const { return m_track; }
    int year() const { return m_year; }
    TQString comment() const { return m_comment; }

    TQString fileName() const { return m_fileName; }

    void setTitle(const TQString &value) { m_title = value; }
    void setArtist(const TQString &value) { m_artist = value; }
    void setAlbum(const TQString &value) { m_album = value; }
    void setGenre(const TQString &value) { m_genre = value; }
    void setTrack(int value) { m_track = value; }
    void setYear(int value) { m_year = value; }
    void setComment(const TQString &value) { m_comment = value; }

    void setFileName(const TQString &value) { m_fileName = value; }

    int seconds() const { return m_seconds; }
    int bitrate() const { return m_bitrate; }

    bool isValid() const { return m_isValid; }

    /**
     * As a convenience, since producing a length string from a number of second
     * isn't a one liner, provide the length in string form.
     */
    TQString lengthString() const { return m_lengthString; }
    CacheDataStream &read(CacheDataStream &s);

private:
    void setup(TagLib::File *file);

    TQString m_fileName;
    TQString m_title;
    TQString m_artist;
    TQString m_album;
    TQString m_genre;
    TQString m_comment;
    int m_track;
    int m_year;
    int m_seconds;
    int m_bitrate;
    TQDateTime m_modificationTime;
    TQString m_lengthString;
    bool m_isValid;
};

TQDataStream &operator<<(TQDataStream &s, const Tag &t);
CacheDataStream &operator>>(CacheDataStream &s, Tag &t);

#endif