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"
24 PlaylistManager
* PlaylistManager::s_instance
= 0;
27 The::playlistManager()
29 return PlaylistManager::instance();
32 PlaylistManager::PlaylistManager()
35 PlaylistManager::~PlaylistManager()
39 PlaylistManager::instance()
41 if ( s_instance
== 0 )
42 s_instance
= new PlaylistManager();
48 PlaylistManager::addProvider( PlaylistProvider
* provider
, PlaylistCategory category
)
51 m_map
.insert( category
, provider
);
52 connect( provider
, SIGNAL(updated()), SLOT(slotUpdated( /*PlaylistProvider **/ )) );
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 **/ )) );
71 PlaylistManager::slotUpdated( /*PlaylistProvider * provider*/ )
78 PlaylistManager::playlistsOfCategory( int playlistCategory
)
80 QList
<PlaylistProvider
*> providers
= m_map
.values( playlistCategory
);
81 QListIterator
<PlaylistProvider
*> i( providers
);
83 Meta::PlaylistList list
;
85 list
<< i
.next()->playlists();
91 PlaylistManager::playlistProvider(int category
, QString name
)
93 QList
<PlaylistProvider
*> providers( m_map
.values( category
) );
95 QListIterator
<PlaylistProvider
*> i(providers
);
98 PlaylistProvider
* p
= static_cast<PlaylistProvider
*>( i
.next() );
99 if( p
->prettyName() == name
)
106 #include "PlaylistManager.moc"