Commit 3b69f66d authored by Scott Wheeler's avatar Scott Wheeler

This is a complete rewrite of the genre system to be based on XML.

Currently this just supports reading XML genre lists.

svn path=/trunk/kdemultimedia/juk/; revision=141257
parent f1fde603
......@@ -3,12 +3,12 @@ bin_PROGRAMS = juk
## INCLUDES were found outside kdevelop specific part
juk_SOURCES = genre.cpp player.cpp MPEGHeader.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp
juk_SOURCES = genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp MPEGHeader.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp
juk_LDADD = -lid3 -lsoundserver_idl $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
SUBDIRS = pics
SUBDIRS = pics data
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc taggerwidget.cpp taggerwidget.h slideraction.cpp slideraction.h playlistwidget.cpp playlistwidget.h customaction.h customaction.cpp filelist.cpp filelist.h tag.cpp tag.h filelistitem.cpp filelistitem.h MPEGHeader.cpp MPEGHeader.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc taggerwidget.cpp taggerwidget.h slideraction.cpp slideraction.h playlistwidget.cpp playlistwidget.h customaction.h customaction.cpp filelist.cpp filelist.h tag.cpp tag.h filelistitem.cpp filelistitem.h MPEGHeader.cpp MPEGHeader.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png genrelist.cpp genrelist.h genrelistlist.cpp genrelistlist.h genrelistreader.cpp genrelistreader.h
install-data-local:
$(mkinstalldirs) $(kde_appsdir)/Multimedia/
......
......@@ -228,12 +228,12 @@ x_libraries = @x_libraries@
bin_PROGRAMS = juk
juk_SOURCES = genre.cpp player.cpp MPEGHeader.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp
juk_SOURCES = genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp MPEGHeader.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp
juk_LDADD = -lid3 -lsoundserver_idl $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
SUBDIRS = pics
SUBDIRS = pics data
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc taggerwidget.cpp taggerwidget.h slideraction.cpp slideraction.h playlistwidget.cpp playlistwidget.h customaction.h customaction.cpp filelist.cpp filelist.h tag.cpp tag.h filelistitem.cpp filelistitem.h MPEGHeader.cpp MPEGHeader.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc taggerwidget.cpp taggerwidget.h slideraction.cpp slideraction.h playlistwidget.cpp playlistwidget.h customaction.h customaction.cpp filelist.cpp filelist.h tag.cpp tag.h filelistitem.cpp filelistitem.h MPEGHeader.cpp MPEGHeader.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png genrelist.cpp genrelist.h genrelistlist.cpp genrelistlist.h genrelistreader.cpp genrelistreader.h
####### kdevelop will overwrite this part!!! (end)############
......@@ -259,16 +259,20 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
#>- juk_OBJECTS = genre.$(OBJEXT) player.$(OBJEXT) MPEGHeader.$(OBJEXT) \
#>- filelistitem.$(OBJEXT) tag.$(OBJEXT) filelist.$(OBJEXT) \
#>- customaction.$(OBJEXT) playlistwidget.$(OBJEXT) slideraction.$(OBJEXT) \
#>- taggerwidget.$(OBJEXT) juk.$(OBJEXT) main.$(OBJEXT)
#>+ 9
#>- juk_OBJECTS = genrelistreader.$(OBJEXT) genrelistlist.$(OBJEXT) \
#>- genrelist.$(OBJEXT) genre.$(OBJEXT) player.$(OBJEXT) \
#>- MPEGHeader.$(OBJEXT) filelistitem.$(OBJEXT) tag.$(OBJEXT) \
#>- filelist.$(OBJEXT) customaction.$(OBJEXT) playlistwidget.$(OBJEXT) \
#>- slideraction.$(OBJEXT) taggerwidget.$(OBJEXT) juk.$(OBJEXT) \
#>- main.$(OBJEXT)
#>+ 11
juk_final_OBJECTS = juk.all_cpp.o
juk_nofinal_OBJECTS = genre.$(OBJEXT) player.$(OBJEXT) MPEGHeader.$(OBJEXT) \
filelistitem.$(OBJEXT) tag.$(OBJEXT) filelist.$(OBJEXT) \
customaction.$(OBJEXT) playlistwidget.$(OBJEXT) slideraction.$(OBJEXT) \
taggerwidget.$(OBJEXT) juk.$(OBJEXT) main.$(OBJEXT)\
juk_nofinal_OBJECTS = genrelistreader.$(OBJEXT) genrelistlist.$(OBJEXT) \
genrelist.$(OBJEXT) genre.$(OBJEXT) player.$(OBJEXT) \
MPEGHeader.$(OBJEXT) filelistitem.$(OBJEXT) tag.$(OBJEXT) \
filelist.$(OBJEXT) customaction.$(OBJEXT) playlistwidget.$(OBJEXT) \
slideraction.$(OBJEXT) taggerwidget.$(OBJEXT) juk.$(OBJEXT) \
main.$(OBJEXT)\
slideraction.moc.o customaction.moc.o juk.moc.o taggerwidget.moc.o \
juk_meta_unload.o
@KDE_USE_FINAL_FALSE@juk_OBJECTS = $(juk_nofinal_OBJECTS)
......@@ -287,30 +291,28 @@ CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link --tag=CXX $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) $(LDFLAGS) -o $@
DATA = $(rc_DATA)
DIST_COMMON = Makefile.am Makefile.in TODO
DIST_COMMON = Makefile.am Makefile.in
#>- DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
#>+ 4
KDE_DIST=juk
DISTFILES= $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST)
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
#>- DEP_FILES = .deps/MPEGHeader.P .deps/customaction.P .deps/filelist.P \
#>- .deps/filelistitem.P .deps/genre.P .deps/juk.P .deps/main.P \
#>- .deps/filelistitem.P .deps/genre.P .deps/genrelist.P \
#>- .deps/genrelistlist.P .deps/genrelistreader.P .deps/juk.P .deps/main.P \
#>- .deps/player.P .deps/playlistwidget.P .deps/slideraction.P .deps/tag.P \
#>- .deps/taggerwidget.P
#>+ 10
#>+ 12
@KDE_USE_FINAL_TRUE@DEP_FILES = $(DEPDIR)/slideraction.moc.P $(DEPDIR)/customaction.moc.P $(DEPDIR)/juk.moc.P $(DEPDIR)/taggerwidget.moc.P $(DEPDIR)/juk_meta_unload.P $(DEPDIR)/juk.all_cpp.P \
.deps/MPEGHeader.P .deps/customaction.P .deps/filelist.P \
.deps/filelistitem.P .deps/genre.P .deps/juk.P .deps/main.P \
.deps/filelistitem.P .deps/genre.P .deps/genrelist.P \
.deps/genrelistlist.P .deps/genrelistreader.P .deps/juk.P .deps/main.P \
.deps/player.P .deps/playlistwidget.P .deps/slideraction.P .deps/tag.P \
.deps/taggerwidget.P
@KDE_USE_FINAL_FALSE@DEP_FILES = $(DEPDIR)/slideraction.moc.P $(DEPDIR)/customaction.moc.P $(DEPDIR)/juk.moc.P $(DEPDIR)/taggerwidget.moc.P $(DEPDIR)/juk_meta_unload.P .deps/MPEGHeader.P .deps/customaction.P .deps/filelist.P \
.deps/filelistitem.P .deps/genre.P .deps/juk.P .deps/main.P \
.deps/filelistitem.P .deps/genre.P .deps/genrelist.P \
.deps/genrelistlist.P .deps/genrelistreader.P .deps/juk.P .deps/main.P \
.deps/player.P .deps/playlistwidget.P .deps/slideraction.P .deps/tag.P \
.deps/taggerwidget.P
......@@ -769,11 +771,11 @@ clean-moc-classes:
-rm -f juk_meta_unload.cpp
#>+ 11
juk.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/genre.cpp $(srcdir)/player.cpp $(srcdir)/MPEGHeader.cpp $(srcdir)/filelistitem.cpp $(srcdir)/tag.cpp $(srcdir)/filelist.cpp $(srcdir)/customaction.cpp $(srcdir)/playlistwidget.cpp $(srcdir)/slideraction.cpp $(srcdir)/taggerwidget.cpp $(srcdir)/juk.cpp $(srcdir)/main.cpp $(srcdir)/juk_meta_unload.cpp slideraction.moc.cpp customaction.moc.cpp juk.moc.cpp taggerwidget.moc.cpp
juk.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/genrelistreader.cpp $(srcdir)/genrelistlist.cpp $(srcdir)/genrelist.cpp $(srcdir)/genre.cpp $(srcdir)/player.cpp $(srcdir)/MPEGHeader.cpp $(srcdir)/filelistitem.cpp $(srcdir)/tag.cpp $(srcdir)/filelist.cpp $(srcdir)/customaction.cpp $(srcdir)/playlistwidget.cpp $(srcdir)/slideraction.cpp $(srcdir)/taggerwidget.cpp $(srcdir)/juk.cpp $(srcdir)/main.cpp juk_meta_unload.cpp slideraction.moc.cpp customaction.moc.cpp juk.moc.cpp taggerwidget.moc.cpp
@echo 'creating juk.all_cpp.cpp ...'; \
rm -f juk.all_cpp.files juk.all_cpp.final; \
echo "#define KDE_USE_FINAL 1" >> juk.all_cpp.final; \
for file in genre.cpp player.cpp MPEGHeader.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp juk_meta_unload.cpp slideraction.moc.cpp customaction.moc.cpp juk.moc.cpp taggerwidget.moc.cpp; do \
for file in genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp MPEGHeader.cpp filelistitem.cpp tag.cpp filelist.cpp customaction.cpp playlistwidget.cpp slideraction.cpp taggerwidget.cpp juk.cpp main.cpp juk_meta_unload.cpp slideraction.moc.cpp customaction.moc.cpp juk.moc.cpp taggerwidget.moc.cpp; do \
echo "#include \"$$file\"" >> juk.all_cpp.files; \
test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> juk.all_cpp.final; \
done; \
......
####### kdevelop will overwrite this part!!! (begin)##########
EXTRA_DIST = id3v1.genreml
####### kdevelop will overwrite this part!!! (end)############
datadir = $(kde_datadir)/juk
data_DATA = id3v1.genreml
This diff is collapsed.
<genreList name="id3v1">
<genre id3v1="0">Blues</genre>
<genre id3v1="1">Classic Rock</genre>
<genre id3v1="2">Country</genre>
<genre id3v1="3">Dance</genre>
<genre id3v1="4">Disco </genre>
<genre id3v1="5">Funk</genre>
<genre id3v1="6">Grunge</genre>
<genre id3v1="7">Hip-Hop</genre>
<genre id3v1="8">Jazz</genre>
<genre id3v1="9">Metal</genre>
<genre id3v1="10">New Age</genre>
<genre id3v1="11">Oldies</genre>
<genre id3v1="12">Other</genre>
<genre id3v1="13">Pop</genre>
<genre id3v1="14">R&amp;B</genre>
<genre id3v1="15">Rap</genre>
<genre id3v1="16">Reggae</genre>
<genre id3v1="17">Rock</genre>
<genre id3v1="18">Techno</genre>
<genre id3v1="19">Industrial</genre>
<genre id3v1="20">Alternative</genre>
<genre id3v1="21">Ska</genre>
<genre id3v1="22">Death Metal</genre>
<genre id3v1="23">Pranks</genre>
<genre id3v1="24">Soundtrack</genre>
<genre id3v1="25">Euro-Techno</genre>
<genre id3v1="26">Ambient</genre>
<genre id3v1="27">Trip-Hop</genre>
<genre id3v1="28">Vocal</genre>
<genre id3v1="29">Jazz+Funk</genre>
<genre id3v1="30">Fusion</genre>
<genre id3v1="31">Trance</genre>
<genre id3v1="32">Classical</genre>
<genre id3v1="33">Instrumental</genre>
<genre id3v1="34">Acid</genre>
<genre id3v1="35">House</genre>
<genre id3v1="36">Game</genre>
<genre id3v1="37">Sound Clip</genre>
<genre id3v1="38">Gospel</genre>
<genre id3v1="39">Noise</genre>
<genre id3v1="40">Alt. Rock</genre>
<genre id3v1="41">Bass</genre>
<genre id3v1="42">Soul</genre>
<genre id3v1="43">Punk</genre>
<genre id3v1="44">Space</genre>
<genre id3v1="45">Meditative</genre>
<genre id3v1="46">Instrum. Pop</genre>
<genre id3v1="47">Instrum. Rock</genre>
<genre id3v1="48">Ethnic</genre>
<genre id3v1="49">Gothic</genre>
<genre id3v1="50">Darkwave</genre>
<genre id3v1="51">Techno-Indust.</genre>
<genre id3v1="52">Electronic</genre>
<genre id3v1="53">Pop-Folk</genre>
<genre id3v1="54">Eurodance</genre>
<genre id3v1="55">Dream</genre>
<genre id3v1="56">Southern Rock</genre>
<genre id3v1="57">Comedy</genre>
<genre id3v1="58">Cult</genre>
<genre id3v1="59">Gangsta</genre>
<genre id3v1="60">Top 40</genre>
<genre id3v1="61">Christian Rap</genre>
<genre id3v1="62">Pop/Funk</genre>
<genre id3v1="63">Jungle</genre>
<genre id3v1="64">Native American</genre>
<genre id3v1="65">Cabaret</genre>
<genre id3v1="66">New Wave</genre>
<genre id3v1="67">Psychadelic</genre>
<genre id3v1="68">Rave</genre>
<genre id3v1="69">Showtunes</genre>
<genre id3v1="70">Trailer</genre>
<genre id3v1="71">Lo-Fi</genre>
<genre id3v1="72">Tribal</genre>
<genre id3v1="73">Acid Punk</genre>
<genre id3v1="74">Acid Jazz</genre>
<genre id3v1="75">Polka</genre>
<genre id3v1="76">Retro</genre>
<genre id3v1="77">Musical</genre>
<genre id3v1="78">Rock &amp; Roll</genre>
<genre id3v1="79">Hard Rock</genre>
<genre id3v1="80">Folk</genre>
<genre id3v1="81">Folk/Rock</genre>
<genre id3v1="82">National Folk</genre>
<genre id3v1="83">Swing</genre>
<genre id3v1="84">Fusion</genre>
<genre id3v1="85">Bebob</genre>
<genre id3v1="86">Latin</genre>
<genre id3v1="87">Revival</genre>
<genre id3v1="88">Celtic</genre>
<genre id3v1="89">Bluegrass</genre>
<genre id3v1="90">Avantgarde</genre>
<genre id3v1="91">Gothic Rock</genre>
<genre id3v1="92">Progress. Rock</genre>
<genre id3v1="93">Psychadel. Rock</genre>
<genre id3v1="94">Symphonic Rock</genre>
<genre id3v1="95">Slow Rock</genre>
<genre id3v1="96">Big Band</genre>
<genre id3v1="97">Chorus</genre>
<genre id3v1="98">Easy Listening</genre>
<genre id3v1="99">Acoustic</genre>
<genre id3v1="100">Humour</genre>
<genre id3v1="101">Speech</genre>
<genre id3v1="102">Chanson</genre>
<genre id3v1="103">Opera</genre>
<genre id3v1="104">Chamber Music</genre>
<genre id3v1="105">Sonata</genre>
<genre id3v1="106">Symphony</genre>
<genre id3v1="107">Booty Bass</genre>
<genre id3v1="108">Primus</genre>
<genre id3v1="109">Porn Groove</genre>
<genre id3v1="110">Satire</genre>
<genre id3v1="111">Slow Jam</genre>
<genre id3v1="112">Club</genre>
<genre id3v1="113">Tango</genre>
<genre id3v1="114">Samba</genre>
<genre id3v1="115">Folklore</genre>
<genre id3v1="116">Ballad</genre>
<genre id3v1="117">Power Ballad</genre>
<genre id3v1="118">Rhythmic Soul</genre>
<genre id3v1="119">Freestyle</genre>
<genre id3v1="120">Duet</genre>
<genre id3v1="121">Punk Rock</genre>
<genre id3v1="122">Drum Solo</genre>
<genre id3v1="123">A Capella</genre>
<genre id3v1="124">Euro-House</genre>
<genre id3v1="125">Dance Hall</genre>
<genre id3v1="126">Goa</genre>
<genre id3v1="127">Drum &amp; Bass</genre>
<genre id3v1="128">Club-House</genre>
<genre id3v1="129">Hardcore</genre>
<genre id3v1="130">Terror</genre>
<genre id3v1="131">Indie</genre>
<genre id3v1="132">BritPop</genre>
<genre id3v1="133">Negerpunk</genre>
<genre id3v1="134">Polsk Punk</genre>
<genre id3v1="135">Beat</genre>
<genre id3v1="136">Christian Gangsta Rap</genre>
<genre id3v1="137">Heavy Metal</genre>
<genre id3v1="138">Black Metal</genre>
<genre id3v1="139">Crossover</genre>
<genre id3v1="140">Contemporary Christian</genre>
<genre id3v1="141">Christian Rock</genre>
<genre id3v1="142">Merengue</genre>
<genre id3v1="143">Salsa</genre>
<genre id3v1="144">Thrash Metal</genre>
<genre id3v1="145">Anime</genre>
<genre id3v1="146">Jpop</genre>
<genre id3v1="147">Synthpop</genre>
</genreList>
......@@ -17,162 +17,38 @@
#include "genre.h"
QString Genre::getGenreName(int index)
{
if(index >= 0 && index <= NUM_GENRES)
return genreTable[index];
else
return(QString::null);
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
Genre::Genre()
{
name = QString::null;
id3v1 = 255;
}
Genre::Genre(QString genreName, int id3v1Number)
{
name = genreName;
id3v1 = id3v1Number;
}
const QString Genre::genreTable[] = {
"Blues",
"Classic Rock",
"Country",
"Dance",
"Disco",
"Funk",
"Grunge",
"Hip-Hop",
"Jazz",
"Metal",
"New Age",
"Oldies",
"Other",
"Pop",
"R&B",
"Rap",
"Reggae",
"Rock",
"Techno",
"Industrial",
"Alternative",
"Ska",
"Death Metal",
"Pranks",
"Soundtrack",
"Euro-Techno",
"Ambient",
"Trip-Hop",
"Vocal",
"Jazz+Funk",
"Fusion",
"Trance",
"Classical",
"Instrumental",
"Acid",
"House",
"Game",
"Sound Clip",
"Gospel",
"Noise",
"Alt. Rock",
"Bass",
"Soul",
"Punk",
"Space",
"Meditative",
"Instrum. Pop",
"Instrum. Rock",
"Ethnic",
"Gothic",
"Darkwave",
"Techno-Indust.",
"Electronic",
"Pop-Folk",
"Eurodance",
"Dream",
"Southern Rock",
"Comedy",
"Cult",
"Gangsta",
"Top 40",
"Christian Rap",
"Pop/Funk",
"Jungle",
"Native American",
"Cabaret",
"New Wave",
"Psychadelic",
"Rave",
"Showtunes",
"Trailer",
"Lo-Fi",
"Tribal",
"Acid Punk",
"Acid Jazz",
"Polka",
"Retro",
"Musical",
"Rock & Roll",
"Hard Rock",
"Folk",
"Folk/Rock",
"National Folk",
"Swing",
"Fusion",
"Bebob",
"Latin",
"Revival",
"Celtic",
"Bluegrass",
"Avantgarde",
"Gothic Rock",
"Progress. Rock",
"Psychadel. Rock",
"Symphonic Rock",
"Slow Rock",
"Big Band",
"Chorus",
"Easy Listening",
"Acoustic",
"Humour",
"Speech",
"Chanson",
"Opera",
"Chamber Music",
"Sonata",
"Symphony",
"Booty Bass",
"Primus",
"Porn Groove",
"Satire",
"Slow Jam",
"Club",
"Tango",
"Samba",
"Folklore",
"Ballad",
"Power Ballad",
"Rhythmic Soul",
"Freestyle",
"Duet",
"Punk Rock",
"Drum Solo",
"A Capella",
"Euro-House",
"Dance Hall",
"Goa",
"Drum & Bass",
"Club-House",
"Hardcore",
"Terror",
"Indie",
"BritPop",
"Negerpunk",
"Polsk Punk",
"Beat",
"Christian Gangsta Rap",
"Heavy Metal",
"Black Metal",
"Crossover",
"Contemporary Christian",
"Christian Rock",
"Merengue",
"Salsa",
"Thrash Metal",
"Anime",
"Jpop",
"Synthpop"
};
QString Genre::getName()
{
return(name);
}
int Genre::getId3v1()
{
return(id3v1);
}
void Genre::setName(QString genreName)
{
name = genreName;
}
void Genre::setId3v1(int id3v1Number)
{
id3v1 = id3v1Number;
}
......@@ -15,21 +15,26 @@
* *
***************************************************************************/
#ifndef PLAYER_H
#define PLAYER_H
#ifndef GENRE_H
#define GENRE_H
#include <qstring.h>
#define NUM_GENRES 147
class Genre
{
public:
static QString getGenreName(int index);
static const int getGenreCount() { return NUM_GENRES; }
Genre();
Genre(QString genreName, int id3v1Number);
QString getName();
int getId3v1();
void setName(QString genreName);
void setId3v1(int number);
private:
static const QString genreTable[NUM_GENRES + 1];
QString name;
int id3v1;
};
#endif
/***************************************************************************
genrelist.cpp - description
-------------------
begin : Sun Mar 3 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* 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 <kdebug.h>
#include "genrelist.h"
#include "genrelistreader.h"
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
GenreList::GenreList()
{
// index = 0;
}
GenreList::GenreList(QString file, bool createIndex = false)
{
// index = 0;
load(file);
if(createIndex)
initializeIndex();
}
GenreList::~GenreList()
{
}
void GenreList::load(QString file)
{
GenreListReader *handler = new GenreListReader(this);
QFile input(file);
QXmlInputSource source(input);
QXmlSimpleReader reader;
reader.setContentHandler(handler);
reader.parse(source);
}
QString GenreList::name(int id3v1)
{
if(id3v1 >= 0 && id3v1 < int(index.size()))
return(index[id3v1]);
else
return(QString::null);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void GenreList::initializeIndex()
{
index.clear();
index.resize(count());
for(GenreList::Iterator it = begin(); it != end(); ++it) {
index[(*it).getId3v1()] = (*it).getName();
}
}
/***************************************************************************
genrelist.h - description
-------------------
begin : Sun Mar 3 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef GENRELIST_H
#define GENRELIST_H
#include <qvaluelist.h>
#include <qstring.h>
#include <qvaluevector.h>
#include "genre.h"
class GenreList : public QValueList<Genre>
{
public:
GenreList();
GenreList(QString file, bool createIndex = false);
~GenreList();
void load(QString file);
QString name(int id3v1);
private:
QValueVector<QString> index;
void initializeIndex();
};
#endif
/***************************************************************************
genrelistlist.cpp - description
-------------------
begin : Sun Mar 3 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* 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 <kstandarddirs.h>
#include "genrelistlist.h"
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
// public
GenreList GenreListList::id3v1List()
{
return(id3v1);
}
// private
GenreList GenreListList::id3v1 = GenreList(locate("data", "juk/id3v1.genreml"), true);
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
GenreListList::GenreListList()
{
}
GenreListList::~GenreListList()
{
}
/***************************************************************************
genrelistlist.h - description
-------------------
begin : Sun Mar 3 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef GENRELISTLIST_H
#define GENRELISTLIST_H
#include <qvaluelist.h>
#include "genrelist.h"
class GenreListList : public QValueList<GenreList>
{
public:
GenreListList();
~GenreListList();
static GenreList id3v1List();
private:
static GenreList id3v1;
};
#endif
/***************************************************************************
genrelistreader.cpp - description
-------------------
begin : Mon Mar 4 2002
copyright : (C) 2002 by Scott Wheeler
email : scott@slackorama.net
***************************************************************************/
/***************************************************************************
* *
* 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 "genrelistreader.h"
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
GenreListReader::GenreListReader(GenreList *genreList)
{
list = genreList;
}
GenreListReader::~GenreListReader()
{
}
bool GenreListReader::startElement(const QString&, const QString&, const QString& element, const QXmlAttributes& attributes)
{
if(element.lower() == "genre") {
inGenreTag = true;
if(attributes.index("id3v1") != -1)
id3v1 = attributes.value("id3v1").toInt();
else
id3v1 = 255;
}
else {