diff --git a/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp b/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp index a39302eae59..90dc55033d9 100644 --- a/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp +++ b/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp @@ -205,6 +205,11 @@ void PlaylistEditorView::customEvent(QEvent *event) //TODO should just update the relevent playlist here reloadTree(); } + else if (event->type() == MusicPlayerEvent::CDChangedEvent) + { + //TODO should just update the cd node + reloadTree(); + } else if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = static_cast(event); @@ -501,7 +506,7 @@ void PlaylistEditorView::updateSonglist(MusicGenericTree *node) node->getAction() == "smartplaylistcategory") { } - else if (node->getAction() == "trackid") + else if (node->getAction() == "trackid" || node->getAction() == "cdtrack") { m_songList.append(node->getInt()); } @@ -752,6 +757,13 @@ void PlaylistEditorView::createRootNode(void ) } node->SetData(qVariantFromValue(compTracks)); + if (gMusicData->all_music->getCDTrackCount()) + { + node = new MusicGenericTree(m_rootNode, tr("CD - %1").arg(gMusicData->all_music->getCDTitle()), "cd"); + node->setDrawArrow(true); + node->SetData(qVariantFromValue(gMusicData->all_music->getAllCDMetadata())); + } + node = new MusicGenericTree(m_rootNode, tr("Directory"), "directory"); node->setDrawArrow(true); node->SetData(qVariantFromValue(gMusicData->all_music->getAllMetadata())); @@ -942,6 +954,10 @@ void PlaylistEditorView::treeNodeChanged(MythGenericTree *node) { getPlaylistTracks(mnode, mnode->getInt()); } + else if (mnode->getAction() == "cd") + { + getCDTracks(mnode); + } else filterTracks(mnode); } @@ -1549,6 +1565,22 @@ void PlaylistEditorView::getPlaylists(MusicGenericTree *node) } } +void PlaylistEditorView::getCDTracks(MusicGenericTree *node) +{ + MetadataPtrList *tracks = gMusicData->all_music->getAllCDMetadata(); + + for (int x = 0; x < tracks->count(); x++) + { + MusicMetadata *mdata = tracks->at(x); + QString title = QString("%1 - %2").arg(mdata->Track()).arg(mdata->FormatTitle()); + MusicGenericTree *newnode = new MusicGenericTree(node, title, "trackid"); + newnode->setInt(mdata->ID()); + newnode->setDrawArrow(false); + bool hasTrack = gPlayer->getPlaylist()->checkTrack(mdata->ID()); + newnode->setCheck(hasTrack ? MythUIButtonListItem::FullChecked : MythUIButtonListItem::NotChecked); + } +} + void PlaylistEditorView::getPlaylistTracks(MusicGenericTree *node, int playlistID) { Playlist *playlist = gMusicData->all_playlists->getPlaylist(playlistID); diff --git a/mythplugins/mythmusic/mythmusic/playlisteditorview.h b/mythplugins/mythmusic/mythmusic/playlisteditorview.h index 1972c26a5c7..5a55985e66d 100644 --- a/mythplugins/mythmusic/mythmusic/playlisteditorview.h +++ b/mythplugins/mythmusic/mythmusic/playlisteditorview.h @@ -94,6 +94,8 @@ class PlaylistEditorView : public MusicCommon void getSmartPlaylists(MusicGenericTree *node); void getSmartPlaylistTracks(MusicGenericTree *node, int playlistID); + void getCDTracks(MusicGenericTree *node); + void updateSelectedTracks(void); void updateSelectedTracks(MusicGenericTree *node); void updateSonglist(MusicGenericTree *node);