Skip to content

Commit 5932419

Browse files
author
Paul Harrison
committed
Merge branch 'compartist'
2 parents 5206271 + bd68156 commit 5932419

File tree

5 files changed

+165
-34
lines changed

5 files changed

+165
-34
lines changed

mythplugins/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,9 @@ if test "$music" != "no" ; then
471471

472472
if test "$cdio" != "no" ; then
473473
cdio="no"
474-
if has_header cdio/cdio.h && has_library libcdio && has_library libcdio_cdda && has_library libcdio_paranoia ; then
474+
if has_header cdio/cdio.h && has_header cdio/cdda.h && has_header cdio/paranoia.h && has_library libcdio && has_library libcdio_cdda && has_library libcdio_paranoia ; then
475475
cdio="yes"
476+
echo "cdio=yes"
476477
fi
477478
fi
478479

mythplugins/mythmusic/mythmusic/musiccommon.cpp

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ bool MusicCommon::CreateCommon(void)
231231
connect(m_visualModeTimer, SIGNAL(timeout()), this, SLOT(visEnable()));
232232
}
233233

234-
m_mainvisual->setVisual(m_visualModes[m_currentVisual]);
235-
236-
if (m_visualText)
237-
m_visualText->SetText(m_visualModes[m_currentVisual]);
234+
switchVisualizer(m_currentVisual);
238235

239236
if (gPlayer->isPlaying())
240237
startVisualizer();
@@ -616,6 +613,16 @@ bool MusicCommon::keyPressEvent(QKeyEvent *e)
616613
}
617614
else if (action == "CYCLEVIS")
618615
cycleVisualizer();
616+
else if (action == "BLANKSCR")
617+
{
618+
// change to the blank visualizer
619+
if (m_mainvisual)
620+
switchVisualizer("Blank");
621+
622+
// switch to the full screen visualiser view
623+
if (m_currentView != MV_VISUALIZER)
624+
switchView(MV_VISUALIZER);
625+
}
619626
else if (action == "VOLUMEDOWN")
620627
changeVolume(false);
621628
else if (action == "VOLUMEUP")
@@ -816,6 +823,29 @@ void MusicCommon::resetVisualiserTimer()
816823
m_visualModeTimer->start(m_visualModeDelay * 1000);
817824
}
818825

826+
void MusicCommon::switchVisualizer(const QString &visual)
827+
{
828+
switchVisualizer(m_visualModes.indexOf(visual));
829+
}
830+
831+
void MusicCommon::switchVisualizer(int visual)
832+
{
833+
if (!m_mainvisual)
834+
return;
835+
836+
if (visual < 0 || visual > m_visualModes.count() - 1)
837+
visual = 0;
838+
839+
m_currentVisual = visual;
840+
841+
resetVisualiserTimer();
842+
843+
m_mainvisual->setVisual(m_visualModes[m_currentVisual]);
844+
845+
if (m_visualText)
846+
m_visualText->SetText(m_visualModes[m_currentVisual]);
847+
}
848+
819849
void MusicCommon::cycleVisualizer(void)
820850
{
821851
if (!m_mainvisual)
@@ -842,22 +872,8 @@ void MusicCommon::cycleVisualizer(void)
842872
}
843873

844874
//Change to the new visualizer
845-
resetVisualiserTimer();
846-
m_mainvisual->setVisual("Blank");
847-
m_mainvisual->setVisual(m_visualModes[m_currentVisual]);
875+
switchVisualizer(m_currentVisual);
848876
}
849-
else if (m_visualModes.count() == 1 && m_visualModes[m_currentVisual] == "AlbumArt")
850-
{
851-
// If only the AlbumArt visualization is selected, then go ahead and
852-
// restart the visualization. This will give AlbumArt the opportunity
853-
// to change images if there are multiple images available.
854-
resetVisualiserTimer();
855-
m_mainvisual->setVisual("Blank");
856-
m_mainvisual->setVisual(m_visualModes[m_currentVisual]);
857-
}
858-
859-
if (m_visualText)
860-
m_visualText->SetText(m_visualModes[m_currentVisual]);
861877
}
862878

863879
void MusicCommon::startVisualizer(void)
@@ -1420,11 +1436,7 @@ void MusicCommon::customEvent(QEvent *event)
14201436
m_currentVisual = dce->GetData().toInt();
14211437

14221438
//Change to the new visualizer
1423-
resetVisualiserTimer();
1424-
m_mainvisual->setVisual(m_visualModes[m_currentVisual]);
1425-
1426-
if (m_visualText)
1427-
m_visualText->SetText(m_visualModes[m_currentVisual]);
1439+
switchVisualizer(m_currentVisual);
14281440
}
14291441
}
14301442
else if (resultid == "addplaylist")

mythplugins/mythmusic/mythmusic/musiccommon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class MPUBLIC MusicCommon : public MythScreenType
127127
void startVisualizer(void);
128128
void stopVisualizer(void);
129129
void cycleVisualizer(void);
130+
void switchVisualizer(const QString &visual);
131+
void switchVisualizer(int visual);
130132
void resetVisualiserTimer(void);
131133

132134
void playFirstTrack();

mythplugins/mythmusic/mythmusic/playlisteditorview.cpp

Lines changed: 120 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ PlaylistEditorView::~PlaylistEditorView()
101101
{
102102
saveTreePosition();
103103

104+
for (int x = 0; x < m_deleteList.count(); x++)
105+
delete m_deleteList.at(x);
106+
m_deleteList.clear();
107+
104108
if (m_rootNode)
105109
delete m_rootNode;
106110
}
@@ -370,6 +374,25 @@ void PlaylistEditorView::createRootNode(void )
370374
node = new MusicGenericTree(m_rootNode, tr("Years"), "years");
371375
node->setDrawArrow(true);
372376
node->SetData(qVariantFromValue(gMusicData->all_music->getAllMetadata()));
377+
378+
node = new MusicGenericTree(m_rootNode, tr("Compilations"), "compilations");
379+
node->setDrawArrow(true);
380+
381+
MetadataPtrList *alltracks = gMusicData->all_music->getAllMetadata();
382+
MetadataPtrList *compTracks = new MetadataPtrList;
383+
m_deleteList.append(compTracks);
384+
385+
for (int x = 0; x < alltracks->count(); x++)
386+
{
387+
Metadata *mdata = alltracks->at(x);
388+
if (mdata)
389+
{
390+
if (mdata->Compilation())
391+
compTracks->append(mdata);
392+
}
393+
}
394+
node->SetData(qVariantFromValue(compTracks));
395+
373396
#if 0
374397
node = new MusicGenericTree(m_rootNode, tr("Directory"), "directory");
375398
node->setDrawArrow(true);
@@ -430,8 +453,8 @@ void PlaylistEditorView::treeItemClicked(MythUIButtonListItem *item)
430453
showPlaylistOptionsMenu();
431454
}
432455
else if (mnode->getAction() == "album" || mnode->getAction() == "artist" ||
433-
mnode->getAction() == "genre" || mnode->getAction() == "year" ||
434-
mnode->getAction() == "rating")
456+
mnode->getAction() == "compartist" || mnode->getAction() == "genre" ||
457+
mnode->getAction() == "year" || mnode->getAction() == "rating")
435458
{
436459
MetadataPtrList *tracks = qVariantValue<MetadataPtrList*> (node->GetData());
437460
for (int x = 0; x < tracks->count(); x++)
@@ -496,6 +519,11 @@ void PlaylistEditorView::treeItemVisible(MythUIButtonListItem *item)
496519
{
497520
artFile = "mm_artists.png";
498521
}
522+
else if (mnode->getAction() == "compartists")
523+
{
524+
//TODO add a compilation artist icon
525+
artFile = "mm_artists.png";
526+
}
499527
else if (mnode->getAction() == "ratings")
500528
{
501529
artFile = "mm_ratings.png";
@@ -634,6 +662,7 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
634662
else
635663
{
636664
MetadataPtrList *filteredTracks = new MetadataPtrList;
665+
m_deleteList.append(filteredTracks);
637666
filteredTracks->append(mdata);
638667
map.insert(mdata->Artist(), filteredTracks);
639668
}
@@ -648,6 +677,41 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
648677
++i;
649678
}
650679
}
680+
else if (node->getAction() == "compartists")
681+
{
682+
QMap<QString, MetadataPtrList*> map;
683+
684+
for (int x = 0; x < tracks->count(); x++)
685+
{
686+
Metadata *mdata = tracks->at(x);
687+
if (mdata)
688+
{
689+
if (mdata->CompilationArtist() != mdata->Artist())
690+
{
691+
if (map.contains(mdata->CompilationArtist()))
692+
{
693+
MetadataPtrList *filteredTracks = map.value(mdata->CompilationArtist());
694+
filteredTracks->append(mdata);
695+
}
696+
else
697+
{
698+
MetadataPtrList *filteredTracks = new MetadataPtrList;
699+
m_deleteList.append(filteredTracks);
700+
filteredTracks->append(mdata);
701+
map.insert(mdata->CompilationArtist(), filteredTracks);
702+
}
703+
}
704+
}
705+
}
706+
707+
QMap<QString, MetadataPtrList*>::const_iterator i = map.constBegin();
708+
while (i != map.constEnd())
709+
{
710+
MusicGenericTree *newnode = new MusicGenericTree(node, i.key(), "compartist");
711+
newnode->SetData(qVariantFromValue(i.value()));
712+
++i;
713+
}
714+
}
651715
else if (node->getAction() == "albums")
652716
{
653717
QMap<QString, MetadataPtrList*> map;
@@ -665,6 +729,7 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
665729
else
666730
{
667731
MetadataPtrList *filteredTracks = new MetadataPtrList;
732+
m_deleteList.append(filteredTracks);
668733
filteredTracks->append(mdata);
669734
map.insert(mdata->Album(), filteredTracks);
670735
}
@@ -697,6 +762,7 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
697762
else
698763
{
699764
MetadataPtrList *filteredTracks = new MetadataPtrList;
765+
m_deleteList.append(filteredTracks);
700766
filteredTracks->append(mdata);
701767
map.insert(mdata->Genre(), filteredTracks);
702768
}
@@ -729,6 +795,7 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
729795
else
730796
{
731797
MetadataPtrList *filteredTracks = new MetadataPtrList;
798+
m_deleteList.append(filteredTracks);
732799
filteredTracks->append(mdata);
733800
map.insert(ratingStr, filteredTracks);
734801
}
@@ -762,6 +829,7 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
762829
else
763830
{
764831
MetadataPtrList *filteredTracks = new MetadataPtrList;
832+
m_deleteList.append(filteredTracks);
765833
filteredTracks->append(mdata);
766834
map.insert(yearStr, filteredTracks);
767835
}
@@ -777,9 +845,10 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
777845
}
778846

779847
}
780-
else if (node->getAction() == "artist" || node->getAction() == "album" ||
781-
node->getAction() == "genre" || node->getAction() == "rating" ||
782-
node->getAction() == "year")
848+
else if (node->getAction() == "artist" || node->getAction() == "compartist" ||
849+
node->getAction() == "album" || node->getAction() == "genre" ||
850+
node->getAction() == "rating" || node->getAction() == "year" ||
851+
node->getAction() == "compilations")
783852
{
784853
// which fields have we already filtered by
785854
QStringList fields;
@@ -801,14 +870,54 @@ void PlaylistEditorView::filterTracks(MusicGenericTree *node)
801870
newnode->SetData(node->GetData());
802871
}
803872

804-
805873
if (!fields.contains("artists"))
806874
{
807875
newnode = new MusicGenericTree(node, tr("Artists"), "artists");
808876
newnode->setDrawArrow(true);
809877
newnode->SetData(node->GetData());
810878
}
811879

880+
if (!fields.contains("compartists"))
881+
{
882+
// only show the Compilation Artists node if we are one the Compilations branch
883+
bool showCompArtists = false;
884+
MusicGenericTree *mnode = node;
885+
do
886+
{
887+
if (mnode->getAction() == "compilations")
888+
{
889+
showCompArtists = true;
890+
break;
891+
}
892+
893+
mnode = (MusicGenericTree *) mnode->getParent();
894+
895+
} while (mnode);
896+
897+
// only show the Comp. Artist if it differs from the Artist
898+
bool found = false;
899+
MetadataPtrList *tracks = qVariantValue<MetadataPtrList*> (node->GetData());
900+
for (int x = 0; x < tracks->count(); x++)
901+
{
902+
Metadata *mdata = tracks->at(x);
903+
if (mdata)
904+
{
905+
if (mdata->Artist() != mdata->CompilationArtist())
906+
{
907+
found = true;
908+
break;
909+
}
910+
}
911+
}
912+
913+
if (showCompArtists && found)
914+
{
915+
newnode = new MusicGenericTree(node, tr("Compilation Artists"), "compartists");
916+
newnode->setDrawArrow(true);
917+
newnode->SetData(node->GetData());
918+
}
919+
}
920+
812921
if (!fields.contains("genres"))
813922
{
814923
newnode = new MusicGenericTree(node, tr("Genres"), "genres");
@@ -1070,6 +1179,11 @@ void PlaylistEditorView::reloadTree(void)
10701179
QStringList route = m_playlistTree->GetCurrentNode()->getRouteByString();
10711180

10721181
m_playlistTree->Reset();
1182+
1183+
for (int x = 0; x < m_deleteList.count(); x++)
1184+
delete m_deleteList.at(x);
1185+
m_deleteList.clear();
1186+
10731187
m_rootNode->deleteAllChildren();
10741188
createRootNode();
10751189
m_playlistTree->AssignTree(m_rootNode);

mythplugins/mythmusic/mythmusic/playlisteditorview.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ class PlaylistEditorView : public MusicCommon
9999
void restoreTreePosition(const QStringList &route);
100100

101101
private:
102-
QString m_layout;
103-
bool m_restorePosition;
104-
MusicGenericTree *m_rootNode;
102+
QString m_layout;
103+
bool m_restorePosition;
104+
MusicGenericTree *m_rootNode;
105+
QList<MetadataPtrList*> m_deleteList;
106+
105107
MythUIButtonTree *m_playlistTree;
106108
MythUIText *m_breadcrumbsText;
107109
MythUIText *m_positionText;

0 commit comments

Comments
 (0)