forked from flacon/flacon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack.h
171 lines (129 loc) · 4.88 KB
/
track.h
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* Flacon - audio File Encoder
* https://github.com/flacon/flacon
*
* Copyright: 2017
* Alexander Sokoloff <sokoloff.a@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef TRACK_H
#define TRACK_H
#include <QObject>
#include "types.h"
#include "tags.h"
#include "inputaudiofile.h"
#include <QDebug>
class Disc;
class Track : public QObject
{
Q_OBJECT
friend class Disc;
public:
Track();
Track(const Track &other);
Track &operator=(const Track &other);
~Track();
const InputAudioFile &audioFile() const { return mAudiofile; }
void setAudioFile(const InputAudioFile &file);
QString audioFileName() const { return mAudiofile.fileName(); }
QString tag(const TagId &tagId) const;
QByteArray tagData(const TagId &tagId) const;
TagValue tagValue(TagId tagId) const;
void setTag(const TagId &tagId, const QString &value);
void setTag(const TagId &tagId, const QByteArray &value);
void setTag(TagId tagId, const TagValue &value);
QString codecName() const;
void setCodecName(const QString &value);
const QTextCodec *codec() const { return mTextCodec; }
bool operator==(const Track &other) const;
QString artist() const { return tag(TagId::Artist); }
void setArtist(const QString &value) { setTag(TagId::Artist, value); }
QString album() const { return tag(TagId::Album); }
void setAlbum(const QString &value) { setTag(TagId::Album, value); }
QString comment() const { return tag(TagId::Comment); }
void setComment(const QString &value) { setTag(TagId::Comment, value); }
QString title() const { return tag(TagId::Title); }
void setTitle(const QString &value) { setTag(TagId::Title, value); }
QString genre() const { return tag(TagId::Genre); }
void setGenre(const QString &value) { setTag(TagId::Genre, value); }
QString date() const { return tag(TagId::Date); }
void setDate(const QString &value) { setTag(TagId::Date, value); }
QString discId() const { return tag(TagId::DiscId); }
TrackNum trackNum() const;
void setTrackNum(TrackNum value);
TrackNum trackCount() const;
void setTrackCount(TrackNum value);
DiscNum discNum() const;
void setDiscNum(DiscNum value);
DiscNum discCount() const;
void setDiscCount(DiscNum value);
QString resultFileName() const;
QString resultFilePath() const;
Duration duration() const { return mDuration; }
CueIndex cueIndex(int indexNum) const;
void setCueIndex(int indexNum, const CueIndex &value);
QString cueFileName() const { return mCueFileName; }
void setCueFileName(const QString &value) { mCueFileName = value; }
signals:
void tagChanged(TagId tagId);
private:
QHash<int, TagValue> mTags;
QTextCodec *mTextCodec;
QVector<CueIndex> mCueIndexes;
Duration mDuration;
QString mCueFileName;
InputAudioFile mAudiofile;
QString calcResultFilePath() const;
QString safeFilePathLen(const QString &path) const;
};
class Tracks : public QVector<Track>
{
public:
Tracks();
explicit Tracks(int size);
explicit Tracks(const QList<Track *> &other);
Tracks(const Tracks &other);
Tracks &operator=(const Tracks &other);
virtual ~Tracks();
QString uri() const { return mUri; }
void setUri(const QString &value) { mUri = value; }
QString title() const;
void setTitle(const QByteArray &value);
void setTitle(const QString &value);
private:
QString mUri;
TagValue mTitle;
};
using TrackPtrList = QList<Track *>;
class UcharDet
{
public:
UcharDet();
UcharDet(const UcharDet &) = delete;
UcharDet &operator=(const UcharDet &) = delete;
~UcharDet();
void add(const Track &track);
UcharDet &operator<<(const Track &track);
QString textCodecName() const;
QTextCodec *textCodec() const;
private:
struct Data;
Data *mData;
};
QTextCodec *determineTextCodec(const QVector<Track *> &tracks);
QDebug operator<<(QDebug debug, const Track &track);
#endif // TRACK_H