Make plasma libs build.
[amarok.git] / src / playlistmanager / PlaylistManager.cpp
blobfa92eb182e62c081412bcbb952e6cb75f6fff006
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Bart Cerneels <bart.cerneels@gmail.com>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "PlaylistManager.h"
20 #include "TheInstances.h"
22 #include "debug.h"
24 PlaylistManager * PlaylistManager::s_instance = 0;
26 PlaylistManager*
27 The::playlistManager()
29 return PlaylistManager::instance();
32 PlaylistManager::PlaylistManager()
35 PlaylistManager::~PlaylistManager()
38 PlaylistManager *
39 PlaylistManager::instance()
41 if ( s_instance == 0 )
42 s_instance = new PlaylistManager();
44 return s_instance;
47 void
48 PlaylistManager::addProvider( PlaylistProvider * provider, PlaylistCategory category )
50 DEBUG_BLOCK
51 m_map.insert( category, provider );
52 connect( provider, SIGNAL(updated()), SLOT(slotUpdated( /*PlaylistProvider **/ )) );
53 emit(updated());
56 void
57 PlaylistManager::addCustomProvider( PlaylistProvider * provider, int customCategory )
59 m_map.insert( customCategory, provider );
60 if ( !m_customCategories.contains( customCategory ) )
62 m_customCategories << customCategory;
63 //notify PlaylistBrowser of new custom category.
65 connect( provider, SIGNAL(updated()), SLOT(slotUpdated( /*PlaylistProvider **/ )) );
66 emit(updated());
70 void
71 PlaylistManager::slotUpdated( /*PlaylistProvider * provider*/ )
73 DEBUG_BLOCK
74 emit(updated());
77 Meta::PlaylistList
78 PlaylistManager::playlistsOfCategory( int playlistCategory )
80 QList<PlaylistProvider *> providers = m_map.values( playlistCategory );
81 QListIterator<PlaylistProvider *> i( providers );
83 Meta::PlaylistList list;
84 while ( i.hasNext() )
85 list << i.next()->playlists();
87 return list;
90 PlaylistProvider *
91 PlaylistManager::playlistProvider(int category, QString name)
93 QList<PlaylistProvider *> providers( m_map.values( category ) );
95 QListIterator<PlaylistProvider *> i(providers);
96 while( i.hasNext() )
98 PlaylistProvider * p = static_cast<PlaylistProvider *>( i.next() );
99 if( p->prettyName() == name )
100 return p;
103 return 0;
106 #include "PlaylistManager.moc"