-
Notifications
You must be signed in to change notification settings - Fork 0
/
song.cpp
47 lines (41 loc) · 998 Bytes
/
song.cpp
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
#include "song.h"
#include <QTextCodec>
#include <taglib/tag.h>
#include <taglib/taglib.h>
#include <taglib/fileref.h>
Song::Song()
{}
Song::Song(QString path)
{
QTextCodec* gbk = QTextCodec::codecForName("GBK");
this->path = path;
TagLib::FileRef f(path.toUtf8());
if (f.tag()->artist().isLatin1()) {
title = gbk->toUnicode(f.tag()->title().toCString());
artist = gbk->toUnicode(f.tag()->artist().toCString());
album = gbk->toUnicode(f.tag()->album().toCString());
title = title.trimmed();
artist = artist.trimmed();
album = album.trimmed();
} else {
title = TStringToQString(f.tag()->title()).trimmed();
artist = TStringToQString(f.tag()->artist()).trimmed();
album = TStringToQString(f.tag()->album()).trimmed();
}
}
QString Song::Album()
{
return album;
}
QString Song::Artist()
{
return artist;
}
QString Song::Title()
{
return title;
}
QString Song::Path()
{
return path;
}