[3e4acc]: libkwave / GenreType.cpp Maximize Restore History

Download this file

GenreType.cpp    230 lines (208 with data), 6.7 kB

  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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*************************************************************************
GenreType.h - Map for genre types
-------------------
begin : Wed Sep 01 2002
copyright : (C) 2002 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "config.h"
#include <klocale.h>
#include "GenreType.h"
//***************************************************************************
QMap<int, const char *> GenreType::m_map;
//***************************************************************************
GenreType::GenreType()
{
}
//***************************************************************************
QString GenreType::name(int id, bool localized)
{
fill();
if (m_map.contains(id))
return QString((localized) ? i18n(m_map[id]) : m_map[id]);
else
return QString::number(id);
}
//***************************************************************************
int GenreType::fromID3(const QString &tag)
{
fill();
QString s = tag;
// remove brackets (optional)
if (s.startsWith("(") && s.endsWith(")"))
s = s.mid(1, tag.length()-2);
bool ok = false;
int i = s.toInt(&ok);
if ((i < 0) || (i >= m_map.count())) ok = false;
return (ok) ? i : id(tag);
}
//***************************************************************************
int GenreType::id(const QString &name)
{
fill();
QMap<int, const char *>::Iterator it;
for (it = m_map.begin(); it != m_map.end(); ++it) {
if (QString(it.value()) == name) return it.key();
if (i18n(it.value()) == name) return it.key();
}
return -1;
}
//***************************************************************************
QStringList GenreType::allTypes()
{
fill();
QStringList list;
foreach (const char *item, m_map.values())
list.append(i18n(item));
return list;
}
//***************************************************************************
void GenreType::fill()
{
if (m_map.count()) return;
{
static const char *map[] = {
// The following genres is defined in ID3v1
I18N_NOOP("Blues"),
I18N_NOOP("Classic Rock"),
I18N_NOOP("Country"),
I18N_NOOP("Dance"),
I18N_NOOP("Disco"),
I18N_NOOP("Funk"),
I18N_NOOP("Grunge"),
I18N_NOOP("Hip-Hop"),
I18N_NOOP("Jazz"),
I18N_NOOP("Metal"),
I18N_NOOP("New Age"),
I18N_NOOP("Oldies"),
I18N_NOOP("Other"),
I18N_NOOP("Pop"),
I18N_NOOP("R&B"),
I18N_NOOP("Rap"),
I18N_NOOP("Reggae"),
I18N_NOOP("Rock"),
I18N_NOOP("Techno"),
I18N_NOOP("Industrial"),
I18N_NOOP("Alternative"),
I18N_NOOP("Ska"),
I18N_NOOP("Death Metal"),
I18N_NOOP("Pranks"),
I18N_NOOP("Soundtrack"),
I18N_NOOP("Euro-Techno"),
I18N_NOOP("Ambient"),
I18N_NOOP("Trip-Hop"),
I18N_NOOP("Vocal"),
I18N_NOOP("Jazz+Funk"),
I18N_NOOP("Fusion"),
I18N_NOOP("Trance"),
I18N_NOOP("Classical"),
I18N_NOOP("Instrumental"),
I18N_NOOP("Acid"),
I18N_NOOP("House"),
I18N_NOOP("Game"),
I18N_NOOP("Sound Clip"),
I18N_NOOP("Gospel"),
I18N_NOOP("Noise"),
I18N_NOOP("AlternRock"),
I18N_NOOP("Bass"),
I18N_NOOP("Soul"),
I18N_NOOP("Punk"),
I18N_NOOP("Space"),
I18N_NOOP("Meditative"),
I18N_NOOP("Instrumental Pop"),
I18N_NOOP("Instrumental Rock"),
I18N_NOOP("Ethnic"),
I18N_NOOP("Gothic"),
I18N_NOOP("Darkwave"),
I18N_NOOP("Techno-Industrial"),
I18N_NOOP("Electronic"),
I18N_NOOP("Pop-Folk"),
I18N_NOOP("Eurodance"),
I18N_NOOP("Dream"),
I18N_NOOP("Southern Rock"),
I18N_NOOP("Comedy"),
I18N_NOOP("Cult"),
I18N_NOOP("Gangsta"),
I18N_NOOP("Top 40"),
I18N_NOOP("Christian Rap"),
I18N_NOOP("Pop/Funk"),
I18N_NOOP("Jungle"),
I18N_NOOP("Native American"),
I18N_NOOP("Cabaret"),
I18N_NOOP("New Wave"),
I18N_NOOP("Psychedelic"),
I18N_NOOP("Rave"),
I18N_NOOP("Showtunes"),
I18N_NOOP("Trailer"),
I18N_NOOP("Lo-Fi"),
I18N_NOOP("Tribal"),
I18N_NOOP("Acid Punk"),
I18N_NOOP("Acid Jazz"),
I18N_NOOP("Polka"),
I18N_NOOP("Retro"),
I18N_NOOP("Musical"),
I18N_NOOP("Rock & Roll"),
I18N_NOOP("Hard Rock"),
// The following genres are Winamp extensions
I18N_NOOP("Folk"),
I18N_NOOP("Folk-Rock"),
I18N_NOOP("National Folk"),
I18N_NOOP("Swing"),
I18N_NOOP("Fast Fusion"),
I18N_NOOP("Bebob"),
I18N_NOOP("Latin"),
I18N_NOOP("Revival"),
I18N_NOOP("Celtic"),
I18N_NOOP("Bluegrass"),
I18N_NOOP("Avantgarde"),
I18N_NOOP("Gothic Rock"),
I18N_NOOP("Progressive Rock"),
I18N_NOOP("Psychedelic Rock"),
I18N_NOOP("Symphonic Rock"),
I18N_NOOP("Slow Rock"),
I18N_NOOP("Big Band"),
I18N_NOOP("Chorus"),
I18N_NOOP("Easy Listening"),
I18N_NOOP("Acoustic"),
I18N_NOOP("Humour"),
I18N_NOOP("Speech"),
I18N_NOOP("Chanson"),
I18N_NOOP("Opera"),
I18N_NOOP("Chamber Music"),
I18N_NOOP("Sonata"),
I18N_NOOP("Symphony"),
I18N_NOOP("Booty Bass"),
I18N_NOOP("Primus"),
I18N_NOOP("Porn Groove"),
I18N_NOOP("Satire"),
I18N_NOOP("Slow Jam"),
I18N_NOOP("Club"),
I18N_NOOP("Tango"),
I18N_NOOP("Samba"),
I18N_NOOP("Folklore"),
I18N_NOOP("Ballad"),
I18N_NOOP("Power Ballad"),
I18N_NOOP("Rhythmic Soul"),
I18N_NOOP("Freestyle"),
I18N_NOOP("Duet"),
I18N_NOOP("Punk Rock"),
I18N_NOOP("Drum Solo"),
I18N_NOOP("Acapella"),
I18N_NOOP("Euro-House"),
I18N_NOOP("Dance Hall")
};
for (unsigned int i = 0; i < sizeof(map) / sizeof(map[0]); ++i)
m_map.insert(i, map[i]);
m_map.insert( -1, I18N_NOOP("Unknown"));
}
}
//***************************************************************************
//***************************************************************************