blob: 5793206e82b64664c23f091a27ee4d1529b0da1b (
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
|
#include "cuesheet.h"
#include <iostream>
CueSheet::CueSheet(const QString& filename) {
QFile f(filename);
f.open(QIODevice::ReadOnly | QIODevice::Text);
int track = 0;
QString artist;
QString name;
int index;
while(!f.atEnd()) {
QTextStream line(f.readLine());
QString cmd;
line >> cmd;
if(cmd == "TRACK") {
int n;
line >> n;
if(track) {
Track t = {track, artist, name, index};
track_list.append(t);
} else {
album_artist = artist;
album_name = name;
}
track = n;
} else if(cmd == "PERFORMER") {
QRegExp rx("(?:\")(.*)(?:\")");
rx.indexIn(line.readLine());
artist = rx.cap(1);
} else if(cmd == "TITLE") {
QRegExp rx("(?:\")(.*)(?:\")");
rx.indexIn(line.readLine());
name = rx.cap(1);
} else if(cmd == "INDEX") {
int n;
QString s;
line >> n >> s;
QStringList l = s.split(':');
index = l[0].toInt() * 60 * 1000 + l[1].toInt() * 1000 + l[2].toInt() * 1000 / 75;
}
}
if(track) {
Track t = {track, artist, name, index};
track_list.append(t);
} else {
album_artist = artist;
album_name = name;
}
f.close();
}
const QString& CueSheet::artist() const {
return album_artist;
}
const QString& CueSheet::name() const {
return album_name;
}
int CueSheet::tracks() const {
return track_list.size();
}
const CueSheet::Track& CueSheet::operator[](int track) const {
return track_list[track];
}
|