kwave  18.07.70
Kwave::GenreType Class Reference

#include <GenreType.h>

Collaboration diagram for Kwave::GenreType:
Collaboration graph

Public Member Functions

virtual ~GenreType ()
 

Static Public Member Functions

static QString name (int id, bool localized)
 
static int fromID3 (const QString &tag)
 
static int id (const QString &name)
 
static QStringList allTypes ()
 

Static Protected Member Functions

static void fill ()
 

Private Member Functions

 GenreType ()
 

Static Private Attributes

static QMap< int, const char * > m_map
 

Detailed Description

Definition at line 31 of file GenreType.h.

Constructor & Destructor Documentation

◆ GenreType()

Kwave::GenreType::GenreType ( )
private

private constructor

Definition at line 29 of file GenreType.cpp.

30 {
31 }

◆ ~GenreType()

virtual Kwave::GenreType::~GenreType ( )
inlinevirtual

Destructor

Definition at line 41 of file GenreType.h.

References name.

41 {}

Member Function Documentation

◆ allTypes()

QStringList Kwave::GenreType::allTypes ( )
static

returns a list with all known genre types (localized)

Definition at line 78 of file GenreType.cpp.

References fill(), and m_map.

Referenced by Kwave::FileInfoDialog::setupContentTab().

79 {
80  fill();
81 
82  QStringList list;
83  foreach (const char *item, m_map.values())
84  list.append(i18n(item));
85 
86  return list;
87 }
static void fill()
Definition: GenreType.cpp:90
static QMap< int, const char * > m_map
Definition: GenreType.h:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill()

void Kwave::GenreType::fill ( )
staticprotected

fills the map if it is empty

Definition at line 90 of file GenreType.cpp.

References m_map.

Referenced by allTypes(), fromID3(), id(), and name().

91 {
92  if (m_map.count()) return;
93  {
94  static const char *map[] = {
95  // The following genres are defined in ID3v1
96  I18N_NOOP("Blues"), // 0
97  I18N_NOOP("Classic Rock"),
98  I18N_NOOP("Country"),
99  I18N_NOOP("Dance"),
100  I18N_NOOP("Disco"),
101  I18N_NOOP("Funk"), // 5
102  I18N_NOOP("Grunge"),
103  I18N_NOOP("Hip-Hop"),
104  I18N_NOOP("Jazz"),
105  I18N_NOOP("Metal"),
106  I18N_NOOP("New Age"), // 10
107  I18N_NOOP("Oldies"),
108  I18N_NOOP("Other"),
109  I18N_NOOP("Pop"),
110  I18N_NOOP("Rhythm and Blues"),
111  I18N_NOOP("Rap"), // 15
112  I18N_NOOP("Reggae"),
113  I18N_NOOP("Rock"),
114  I18N_NOOP("Techno"),
115  I18N_NOOP("Industrial"),
116  I18N_NOOP("Alternative"), // 20
117  I18N_NOOP("Ska"),
118  I18N_NOOP("Death Metal"),
119  I18N_NOOP("Pranks"),
120  I18N_NOOP("Soundtrack"),
121  I18N_NOOP("Euro-Techno"), // 25
122  I18N_NOOP("Ambient"),
123  I18N_NOOP("Trip-Hop"),
124  I18N_NOOP("Vocal"),
125  I18N_NOOP("Jazz & Funk"),
126  I18N_NOOP("Fusion"), // 30
127  I18N_NOOP("Trance"),
128  I18N_NOOP("Classical"),
129  I18N_NOOP("Instrumental"),
130  I18N_NOOP("Acid"),
131  I18N_NOOP("House"), // 35
132  I18N_NOOP("Game"),
133  I18N_NOOP("Sound Clip"),
134  I18N_NOOP("Gospel"),
135  I18N_NOOP("Noise"),
136  I18N_NOOP("Alternative Rock"), // 40
137  I18N_NOOP("Bass"),
138  I18N_NOOP("Soul"),
139  I18N_NOOP("Punk"),
140  I18N_NOOP("Space"),
141  I18N_NOOP("Meditative"), // 45
142  I18N_NOOP("Instrumental Pop"),
143  I18N_NOOP("Instrumental Rock"),
144  I18N_NOOP("Ethnic"),
145  I18N_NOOP("Gothic"),
146  I18N_NOOP("Darkwave"), // 50
147  I18N_NOOP("Techno-Industrial"),
148  I18N_NOOP("Electronic"),
149  I18N_NOOP("Pop-Folk"),
150  I18N_NOOP("Eurodance"),
151  I18N_NOOP("Dream"), // 55
152  I18N_NOOP("Southern Rock"),
153  I18N_NOOP("Comedy"),
154  I18N_NOOP("Cult"),
155  I18N_NOOP("Gangsta"),
156  I18N_NOOP("Top 40"), // 60
157  I18N_NOOP("Christian Rap"),
158  I18N_NOOP("Pop/Funk"),
159  I18N_NOOP("Jungle"),
160  I18N_NOOP("Native American"),
161  I18N_NOOP("Cabaret"), // 65
162  I18N_NOOP("New Wave"),
163  I18N_NOOP("Psychedelic"),
164  I18N_NOOP("Rave"),
165  I18N_NOOP("Showtunes"),
166  I18N_NOOP("Trailer"), // 70
167  I18N_NOOP("Lo-Fi"),
168  I18N_NOOP("Tribal"),
169  I18N_NOOP("Acid Punk"),
170  I18N_NOOP("Acid Jazz"),
171  I18N_NOOP("Polka"), // 75
172  I18N_NOOP("Retro"),
173  I18N_NOOP("Musical"),
174  I18N_NOOP("Rock 'n' Roll"),
175  I18N_NOOP("Hard Rock"),
176 
177  // The following genres are Winamp extensions
178  I18N_NOOP("Folk"), // 80
179  I18N_NOOP("Folk-Rock"),
180  I18N_NOOP("National Folk"),
181  I18N_NOOP("Swing"),
182  I18N_NOOP("Fast Fusion"),
183  I18N_NOOP("Bebop"), // 85
184  I18N_NOOP("Latin"),
185  I18N_NOOP("Revival"),
186  I18N_NOOP("Celtic"),
187  I18N_NOOP("Bluegrass"),
188  I18N_NOOP("Avantgarde"), // 90
189  I18N_NOOP("Gothic Rock"),
190  I18N_NOOP("Progressive Rock"),
191  I18N_NOOP("Psychedelic Rock"),
192  I18N_NOOP("Symphonic Rock"),
193  I18N_NOOP("Slow Rock"), // 95
194  I18N_NOOP("Big Band"),
195  I18N_NOOP("Chorus"),
196  I18N_NOOP("Easy Listening"),
197  I18N_NOOP("Acoustic"),
198  I18N_NOOP("Humour"), // 100
199  I18N_NOOP("Speech"),
200  I18N_NOOP("Chanson"),
201  I18N_NOOP("Opera"),
202  I18N_NOOP("Chamber Music"),
203  I18N_NOOP("Sonata"), // 105
204  I18N_NOOP("Symphony"),
205  I18N_NOOP("Booty Bass"),
206  I18N_NOOP("Primus"),
207  I18N_NOOP("Porn Groove"),
208  I18N_NOOP("Satire"), // 110
209  I18N_NOOP("Slow Jam"),
210  I18N_NOOP("Club"),
211  I18N_NOOP("Tango"),
212  I18N_NOOP("Samba"),
213  I18N_NOOP("Folklore"), // 115
214  I18N_NOOP("Ballad"),
215  I18N_NOOP("Power Ballad"),
216  I18N_NOOP("Rhythmic Soul"),
217  I18N_NOOP("Freestyle"),
218  I18N_NOOP("Duet"), // 120
219  I18N_NOOP("Punk Rock"),
220  I18N_NOOP("Drum Solo"),
221  I18N_NOOP("A Cappella"),
222  I18N_NOOP("Euro-House"),
223  I18N_NOOP("Dance Hall"), // 125
224  I18N_NOOP("Goa"),
225  I18N_NOOP("Drum & Bass"),
226  I18N_NOOP("Club-House"),
227  I18N_NOOP("Hardcore Techno"),
228  I18N_NOOP("Terror"), // 130
229  I18N_NOOP("Indie"),
230  I18N_NOOP("BritPop"),
231  I18N_NOOP("Negerpunk"),
232  I18N_NOOP("Polsk Punk"),
233  I18N_NOOP("Beat"), // 135
234  I18N_NOOP("Christian Gangsta Rap"),
235  I18N_NOOP("Heavy Metal"),
236  I18N_NOOP("Black Metal"),
237  I18N_NOOP("Crossover"),
238  I18N_NOOP("Contemporary Christian"), // 140
239  I18N_NOOP("Christian Rock"),
240 
241  // WinAmp 1.91
242  I18N_NOOP("Merengue"), // 142
243  I18N_NOOP("Salsa"),
244  I18N_NOOP("Thrash Metal"),
245  I18N_NOOP("Anime"), // 145
246  I18N_NOOP("JPop"),
247  I18N_NOOP("SynthPop"),
248 
249  // WinAmp 5.6
250  I18N_NOOP("Abstract"), // 148
251  I18N_NOOP("Art Rock"),
252  I18N_NOOP("Baroque"), // 150
253  I18N_NOOP("Bhangra"),
254  I18N_NOOP("Big Beat"),
255  I18N_NOOP("Breakbeat"),
256  I18N_NOOP("Chillout"),
257  I18N_NOOP("Downtempo"), // 155
258  I18N_NOOP("Dub"),
259  I18N_NOOP("EBM"),
260  I18N_NOOP("Eclectic"),
261  I18N_NOOP("Electro"),
262  I18N_NOOP("Electroclash"), // 160
263  I18N_NOOP("Emo"),
264  I18N_NOOP("Experimental"),
265  I18N_NOOP("Garage"),
266  I18N_NOOP("Global"),
267  I18N_NOOP("IDM"), // 165
268  I18N_NOOP("Illbient"),
269  I18N_NOOP("Industro-Goth"),
270  I18N_NOOP("Jam Band"),
271  I18N_NOOP("Krautrock"),
272  I18N_NOOP("Leftfield"), // 170
273  I18N_NOOP("Lounge"),
274  I18N_NOOP("Math Rock"),
275  I18N_NOOP("New Romantic"),
276  I18N_NOOP("Nu-Breakz"),
277  I18N_NOOP("Post-Punk"), // 175
278  I18N_NOOP("Post-Rock"),
279  I18N_NOOP("Psytrance"),
280  I18N_NOOP("Shoegaze"),
281  I18N_NOOP("Space Rock"),
282  I18N_NOOP("Trop Rock"), // 180
283  I18N_NOOP("World Music"),
284  I18N_NOOP("Neoclassical"),
285  I18N_NOOP("Audiobook"),
286  I18N_NOOP("Audio Theatre"),
287  I18N_NOOP("Neue Deutsche Welle"), // 185
288  I18N_NOOP("Podcast"),
289  I18N_NOOP("Indie Rock"),
290  I18N_NOOP("G-Funk"),
291  I18N_NOOP("Dubstep"),
292  I18N_NOOP("Garage Rock"), // 190
293  I18N_NOOP("Psybient")
294  };
295 
296  for (unsigned int i = 0; i < sizeof(map) / sizeof(map[0]); ++i)
297  m_map.insert(i, map[i]);
298 
299  m_map.insert( -1, I18N_NOOP("Unknown"));
300  }
301 
302 }
static QMap< int, const char * > m_map
Definition: GenreType.h:68
Here is the caller graph for this function:

◆ fromID3()

int Kwave::GenreType::fromID3 ( const QString &  tag)
static

parse the numeric id from an ID3 tag

Definition at line 45 of file GenreType.cpp.

References _, fill(), id(), and m_map.

Referenced by Kwave::MP3Encoder::encodeID3Tags(), and Kwave::MP3Decoder::parseID3Tags().

46 {
47  fill();
48 
49  QString s = tag;
50 
51  // remove brackets (optional)
52  if (s.startsWith(_("(")) && s.endsWith(_(")")))
53  s = s.mid(1, tag.length()-2);
54 
55  bool ok = false;
56  int i = s.toInt(&ok);
57  if ((i < 0) || (i >= m_map.count())) ok = false;
58 
59  return (ok) ? i : id(tag);
60 }
static void fill()
Definition: GenreType.cpp:90
static QMap< int, const char * > m_map
Definition: GenreType.h:68
static int id(const QString &name)
Definition: GenreType.cpp:63
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ id()

int Kwave::GenreType::id ( const QString &  name)
static

try to find the numeric id from the name

Definition at line 63 of file GenreType.cpp.

References _, fill(), and m_map.

Referenced by fromID3(), and Kwave::FileInfoDialog::setupContentTab().

64 {
65  fill();
66  QMap<int, const char *>::Iterator it;
67  for (it = m_map.begin(); it != m_map.end(); ++it) {
68  if (!_(it.value()).compare(name, Qt::CaseInsensitive))
69  return it.key();
70  if (i18n(it.value()).compare(name, Qt::CaseInsensitive) == 0)
71  return it.key();
72  }
73 
74  return -1;
75 }
static QString name(int id, bool localized)
Definition: GenreType.cpp:34
static void fill()
Definition: GenreType.cpp:90
static QMap< int, const char * > m_map
Definition: GenreType.h:68
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

QString Kwave::GenreType::name ( int  id,
bool  localized 
)
static

get the localized name from the id

Parameters
idthe numeric id of the genre type
localizedif true, return a localized name, otherwise raw (en)
Returns
name of the genre

Definition at line 34 of file GenreType.cpp.

References _, fill(), and m_map.

Referenced by Kwave::MP3Encoder::encodeID3Tags(), Kwave::MP3Decoder::parseID3Tags(), and Kwave::FileInfoDialog::setupContentTab().

35 {
36  fill();
37 
38  if (m_map.contains(id))
39  return (localized) ? i18n(m_map[id]) : _(m_map[id]);
40  else
41  return QString::number(id);
42 }
static void fill()
Definition: GenreType.cpp:90
static QMap< int, const char * > m_map
Definition: GenreType.h:68
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_map

QMap< int, const char * > Kwave::GenreType::m_map
staticprivate

map with numeric ids and names

Definition at line 68 of file GenreType.h.

Referenced by allTypes(), fill(), fromID3(), id(), and name().


The documentation for this class was generated from the following files: