Commit e0ebef02 authored by Scott Wheeler's avatar Scott Wheeler

Adding genre to the tree view mode. This isn't quite like RB as the bug

report requests, but has similar functionality.  This combined with searches
should do the trick.

CCMAIL:56615-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=238681
parent 8ce8f1b0
......@@ -186,6 +186,20 @@ void CollectionList::addAlbum(const QString &album)
previousAlbum = album;
}
void CollectionList::addGenre(const QString &genre)
{
if(genre.isEmpty())
return;
// Do a bit of caching since there will very often be "two in a row" insertions.
static QString previousGenre;
if(genre == previousGenre || m_genres.insert(genre))
m_viewModeItems["genres"].insert(genre);
else
previousGenre = genre;
}
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////
......@@ -214,7 +228,8 @@ void CollectionListItem::slotRefresh()
slotRefreshImpl();
CollectionList::instance()->addArtist(text(ArtistColumn));
CollectionList::instance()->addAlbum(text(AlbumColumn));
CollectionList::instance()->addAlbum(text(AlbumColumn));
CollectionList::instance()->addGenre(text(GenreColumn));
// This is connected to slotRefreshImpl() for all of the items children.
emit signalRefreshed();
......
......@@ -54,6 +54,7 @@ public:
QStringList artists() const { return m_artists.values(); }
QStringList albums() const { return m_albums.values(); }
QStringList genres() const { return m_genres.values(); }
CollectionListItem *lookup(const QString &file) { return m_itemsDict.find(file); }
virtual PlaylistItem *createItem(const QFileInfo &file,
......@@ -92,6 +93,11 @@ protected:
*/
void addAlbum(const QString &album);
/**
* Again, similar to the above, but for genres.
*/
void addGenre(const QString &genre);
void emitNumberOfItemsChanged() { emit signalNumberOfItemsChanged(this); }
void addWatched(const QString &file) { m_dirWatch->addFile(file); }
......@@ -111,6 +117,7 @@ private:
QDict<CollectionListItem> m_itemsDict;
SortedStringList m_artists;
SortedStringList m_albums;
SortedStringList m_genres;
KDirWatch *m_dirWatch;
QMap<QString, SortedStringList> m_viewModeItems;
};
......
......@@ -264,6 +264,10 @@ void TreeViewMode::slotSetupCategories()
m_searchCategories.insert("albums", i);
setupCategory("albums", CollectionList::instance()->viewModeItems()["albums"].values(), 2);
i = new PlaylistBox::Item(collectionItem, "cdimage", i18n("Genres"));
m_searchCategories.insert("genres", i);
setupCategory("genres", CollectionList::instance()->viewModeItems()["genres"].values(), 4);
for(QDictIterator<PlaylistBox::Item> it(m_searchCategories); it.current(); ++it)
it.current()->setSortedFirst(true);
......
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