Skip to content

Commit

Permalink
MythMusic: Add a CD node to the playlist editor
Browse files Browse the repository at this point in the history
If a CD is inserted add a node to the playlist editor tree showing the CD's
tracks which can be added/replaced to the active playlist the same as other
tracks.
  • Loading branch information
Paul Harrison committed May 27, 2013
1 parent e838c27 commit d44fd08
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 33 additions & 1 deletion mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
Expand Up @@ -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<DialogCompletionEvent*>(event);
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -942,6 +954,10 @@ void PlaylistEditorView::treeNodeChanged(MythGenericTree *node)
{
getPlaylistTracks(mnode, mnode->getInt());
}
else if (mnode->getAction() == "cd")
{
getCDTracks(mnode);
}
else
filterTracks(mnode);
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions mythplugins/mythmusic/mythmusic/playlisteditorview.h
Expand Up @@ -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);
Expand Down

0 comments on commit d44fd08

Please sign in to comment.