Commit 74f7f010 authored by Scott Wheeler's avatar Scott Wheeler

Added GenreList::findIndex() and fixed TaggerWidget::genreBox to use it.

svn path=/trunk/kdemultimedia/juk/; revision=141942
parent 594de930
......@@ -60,6 +60,32 @@ QString GenreList::name(int id3v1)
return(QString::null);
}
int GenreList::findIndex(QString item)
{
// cache the previous search -- since there are a lot of "two in a row"
// searchs this should optimize things a little
static QString lastItem;
static int lastIndex;
if(!lastItem.isEmpty() && lastItem == item) {
// kdDebug() << "GenreList::findIndex() -- cache hit" << endl;
return(lastIndex);
}
int i = 0;
for(GenreList::Iterator it = begin(); it != end(); ++it) {
if(item == (*it)) {
lastItem = item;
lastIndex = i;
return(i);
}
i++;
}
return(-1);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
......@@ -75,7 +101,6 @@ void GenreList::initializeIndex()
// kdDebug() << "initializeIndex() - " << (*it).getId3v1() << " - "
// << index.size() << " - " << count() << " - " << (*it) << endl;
index[(*it).getId3v1()] = QString(*it);
// kdDebug() << "id3v1 #" << (*it).getId3v1() << ", Size: " << index.size() << endl;
}
}
}
......@@ -32,8 +32,8 @@ public:
~GenreList();
void load(QString file);
QString name(int id3v1);
int findIndex(QString item);
private:
QValueVector<QString> index;
......
......@@ -210,7 +210,12 @@ void TaggerWidget::updateBoxes(FileListItem *item)
artistNameBox->setEditText(tag->getArtist());
trackNameBox->setText(tag->getTrack());
albumNameBox->setEditText(tag->getAlbum());
genreBox->setCurrentItem(tag->getGenreNumber() + 1);
if(genreList && genreList->findIndex(tag->getGenre()) >= 0)
genreBox->setCurrentItem(genreList->findIndex(tag->getGenre()) + 1);
else
genreBox->setCurrentItem(0);
fileNameBox->setText(fileInfo->fileName());
trackSpin->setValue(tag->getTrackNumber());
yearSpin->setValue(tag->getYear());
......
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