Ticket #10710: mythmusic_play_tracks_from_playlisteditor_tree.patch

File mythmusic_play_tracks_from_playlisteditor_tree.patch, 2.9 KB (added by trebor_s@…, 12 years ago)
  • mythplugins/mythmusic/mythmusic/playlisteditorview.cpp

    diff --git a/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp b/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
    index 4413aa3..9c730da 100644
    a b bool PlaylistEditorView::keyPressEvent(QKeyEvent *event) 
    449449            if (item)
    450450                treeItemClicked(item);
    451451        }
     452        else if (action == "PLAY")
     453        {
     454            int trackCount = gPlayer->getPlaylist()->getSongs().count();
     455
     456            MythUIButtonListItem *item = m_playlistTree->GetItemCurrent();
     457            if (item)
     458            {
     459                MythGenericTree *node = qVariantValue<MythGenericTree*> (item->GetData());
     460                MusicGenericTree *mnode = dynamic_cast<MusicGenericTree*>(node);
     461
     462                if (mnode)
     463                {
     464                    if (mnode->getAction() == "trackid")
     465                    {
     466                        // A single track was selected, check if the track is
     467                        // already in the playlist and only if not, add track
     468                        // to the current playlist and mark the song as added.
     469                        // The playlist will be updated automatically
     470                        if (!gPlayer->getPlaylist()->checkTrack(mnode->getInt()))
     471                        {
     472                            gPlayer->addTrack(mnode->getInt(), true);
     473                            mnode->setCheck(MythUIButtonListItem::FullChecked);
     474                        }
     475                    }
     476                    else
     477                    {
     478                        // A node (album, genre,...) was selected, add all songs
     479                        // from this one to the playlist. This functionality
     480                        // was previously only available via the menu
     481                        m_songList.clear();
     482                        MetadataPtrList *tracks = qVariantValue<MetadataPtrList*> (mnode->GetData());
     483                        for (int x = 0; x < tracks->count(); x++)
     484                        {
     485                            Metadata *mdata = tracks->at(x);
     486                            if (mdata)
     487                                m_songList.append((int)mdata->ID());
     488                        }
     489
     490                        // Put the selected songs at the end of the playlist
     491                        m_playlistOptions.insertPLOption = PL_INSERTATEND;
     492                        doUpdatePlaylist();
     493                    }
     494
     495                    // Set the track number to the trackcount. This would be the
     496                    // previously last song plus one. This is then either the
     497                    // newly added track or the first track in the album
     498                    gPlayer->setCurrentTrackPos(trackCount);
     499                }
     500            }
     501            handled = true;
     502        }
    452503        else
    453504            handled = false;
    454505    }