Commit c17957c4 authored by Michael Pyne's avatar Michael Pyne

Implement bug 69486 (add custom genres to tag editor dropdown).

Reason it took so long is because it involves merging two different lists of genres.

CCMAIL:69486-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=342371
parent b0b8d19c
......@@ -37,6 +37,7 @@
#include <qvalidator.h>
#include <qtooltip.h>
#include <qeventloop.h>
#include <qdict.h>
#include <id3v1genres.h>
......@@ -365,6 +366,40 @@ void TagEditor::updateCollection()
m_albumNameBox->listBox()->clear();
m_albumNameBox->listBox()->insertStringList(albumList);
m_albumNameBox->completionObject()->setItems(albumList);
// That was simple, now comes the fun part where we merge the user's list
// of genres with the list that comes with TagLib. We use a hash table
// for the fast insertion/search properties, and the fact that we can query
// the key values later.
QDict<int> dict(5003);
int *tempPtr = new int (0);
m_genreList = list->uniqueSet(CollectionList::Genres);
for(QStringList::ConstIterator it = m_genreList.begin(); it != m_genreList.end(); ++it)
dict.replace(*it, tempPtr);
TagLib::StringList genres = TagLib::ID3v1::genreList();
for(TagLib::StringList::ConstIterator it = genres.begin(); it != genres.end(); ++it)
dict.replace(TStringToQString((*it)), tempPtr);
m_genreList.clear();
QDictIterator<int> dictIt(dict);
while(dictIt.current()) {
m_genreList += dictIt.currentKey();
++dictIt;
}
m_genreList.sort();
m_genreBox->clear();
m_genreBox->insertItem(QString::null);
m_genreBox->insertStringList(m_genreList);
m_genreBox->completionObject()->setItems(m_genreList);
dict.clear();
delete tempPtr;
}
////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment