| 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 | } |