KCDDB

categories.cpp
1 /*
2  SPDX-FileCopyrightText: 2005 Shaheed Haque <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "categories.h"
8 
9 #include "kcddbi18n.h"
10 
11 class KCDDB::Categories::Private
12 {
13 public:
14  QStringList cddb;
16 };
17 
18 KCDDB::Categories::Categories()
19  : d(new Private)
20 {
21  // These are only 11 Category values defined by CDDB. See
22  //
23  // http://www.freedb.org/en/faq.3.html#26
24  //
25  d->cddb << QLatin1String( "blues" ) << QLatin1String( "classical" ) << QLatin1String( "country" ) <<
26  QLatin1String( "data" ) << QLatin1String( "folk" ) << QLatin1String( "jazz" ) << QLatin1String( "misc" ) <<
27  QLatin1String( "newage" ) << QLatin1String( "reggae" ) << QLatin1String( "rock" ) << QLatin1String( "soundtrack" );
28  d->i18n << i18n("Blues") << i18n("Classical") << i18nc("music genre", "Country") <<
29  i18n("Data") << i18n("Folk") << i18n("Jazz") << i18n("Miscellaneous") <<
30  i18n("New Age") << i18n("Reggae") << i18n("Rock") << i18n("Soundtrack");
31 }
32 
33 KCDDB::Categories::~Categories()
34 {
35  delete d;
36 }
37 
38 KCDDB::Categories::Categories(const Categories& other)
39  :d(new Private)
40 {
41  *d = *other.d;
42 }
43 
44 KCDDB::Categories& KCDDB::Categories::operator=(const Categories& other)
45 {
46  *d = *other.d;
47  return *this;
48 }
49 
50 const QStringList &KCDDB::Categories::cddbList() const
51 {
52  return d->cddb;
53 }
54 
55 const QStringList &KCDDB::Categories::i18nList() const
56 {
57  return d->i18n;
58 }
59 
60 const QString KCDDB::Categories::cddb2i18n(const QString &category) const
61 {
62  int index = d->cddb.indexOf(category.trimmed());
63  if (index != -1)
64  {
65  return d->i18n[index];
66  }
67  else
68  {
69  return cddb2i18n(QLatin1String( "misc" ));
70  }
71 }
72 
73 const QString KCDDB::Categories::i18n2cddb(const QString &category) const
74 {
75  int index = d->i18n.indexOf(category.trimmed());
76  if (index != -1)
77  {
78  return d->cddb[index];
79  }
80  else
81  {
82  return QLatin1String( "misc" );
83  }
84 }
Category values defined by CDDB.
Definition: categories.h:19
const QString cddb2i18n(const QString &category) const
Lookup the CDDB category, and return the i18n&#39;d version.
Definition: categories.cpp:60
const QString i18n2cddb(const QString &category) const
Lookup the i18n category, and return the CDDB version.
Definition: categories.cpp:73
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString trimmed() const const
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:22:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.