Commit 5f33ee90 authored by Scott Wheeler's avatar Scott Wheeler

Ok, so this is sort of working. Adding some stuff so that clicking on the

links shows just the items from that artist / album.  There still needs to
be something to clear this search and there's still a bit of bugginesss with
transfering control of the playing item, but more on that soon...

svn path=/trunk/kdemultimedia/juk/; revision=363028
parent 23235c93
......@@ -18,6 +18,7 @@
#include "dynamicplaylist.h"
#include "collectionlist.h"
#include "playlistcollection.h"
#include "tracksequencemanager.h"
class PlaylistDirtyObserver : public PlaylistObserver
{
......@@ -56,24 +57,15 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists,
setSorting(columns() + 1);
for(PlaylistList::ConstIterator it = playlists.begin(); it != playlists.end(); ++it) {
for(PlaylistList::ConstIterator it = playlists.begin(); it != playlists.end(); ++it)
m_observers.append(new PlaylistDirtyObserver(this, *it));
}
connect(CollectionList::instance(), SIGNAL(signalCollectionChanged()), this, SLOT(slotSetDirty()));
}
DynamicPlaylist::~DynamicPlaylist()
{
if(playing()) {
PlaylistList l;
l.append(this);
for(PlaylistList::Iterator it = m_playlists.begin();
it != m_playlists.end(); ++it)
{
(*it)->synchronizePlayingItems(l, true);
}
}
lower();
for(QValueList<PlaylistObserver *>::ConstIterator it = m_observers.begin();
it != m_observers.end();
......@@ -83,6 +75,12 @@ DynamicPlaylist::~DynamicPlaylist()
}
}
void DynamicPlaylist::setPlaylists(const PlaylistList &playlists)
{
m_playlists = playlists;
updateItems();
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
......@@ -95,6 +93,33 @@ void DynamicPlaylist::slotReload()
checkUpdateItems();
}
void DynamicPlaylist::lower(QWidget *top)
{
if(top == this)
return;
if(playing()) {
PlaylistList l;
l.append(this);
for(PlaylistList::Iterator it = m_playlists.begin();
it != m_playlists.end(); ++it)
{
(*it)->synchronizePlayingItems(l, true);
}
}
PlaylistItemList list = PlaylistItem::playingItems();
for(PlaylistItemList::Iterator it = list.begin(); it != list.end(); ++it) {
if((*it)->playlist() == this) {
list.remove(it);
break;
}
}
if(!list.isEmpty())
TrackSequenceManager::instance()->setCurrentPlaylist(list.front()->playlist());
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
......@@ -132,6 +157,11 @@ void DynamicPlaylist::updateItems()
}
}
bool DynamicPlaylist::synchronizePlaying() const
{
return m_synchronizePlaying;
}
////////////////////////////////////////////////////////////////////////////////
// private methods
////////////////////////////////////////////////////////////////////////////////
......
......@@ -40,6 +40,8 @@ public:
virtual bool canReload() const { return false; }
void setPlaylists(const PlaylistList &playlists);
public slots:
/**
* Reimplemented so that it will reload all of the playlists that are
......@@ -48,6 +50,13 @@ public slots:
virtual void slotReload();
void slotSetDirty() { m_dirty = true; }
/**
* This is called when lowering the widget from the widget stack so that
* it can synchronize the playing item with the one that playlist it was
* create from.
*/
void lower(QWidget *top = 0);
protected:
/**
* Returns true if this list's items need to be updated the next time it's
......@@ -77,6 +86,8 @@ protected:
*/
virtual void updateItems();
bool synchronizePlaying() const;
private:
/**
* Checks to see if the current list of items is "dirty" and if so updates
......
......@@ -656,6 +656,8 @@ void Playlist::synchronizePlayingItems(const PlaylistList &sources, bool setMast
PlaylistItem *item = static_cast<PlaylistItem *>(itemIt.current());
if(base == item->collectionItem()) {
item->setPlaying(true, setMaster);
PlaylistItemList playing = PlaylistItem::playingItems();
TrackSequenceManager::instance()->setCurrent(item);
return;
}
}
......
......@@ -649,14 +649,8 @@ void PlaylistBox::slotPlaylistChanged()
else
action("deleteItemPlaylist")->setText(i18n("R&emove"));
}
else if(!playlists.isEmpty()) {
DynamicPlaylist *p =
new DynamicPlaylist(playlists, this, i18n("Dynamic List"), "midi", false, true);
p->applySharedSettings();
playlistStack()->raiseWidget(p);
TrackSequenceManager::instance()->setCurrentPlaylist(p);
connect(playlistStack(), SIGNAL(aboutToShow(int)), p, SLOT(deleteLater()));
}
else if(!playlists.isEmpty())
createDynamicPlaylist(playlists);
}
void PlaylistBox::slotDoubleClicked()
......
......@@ -31,6 +31,7 @@
#include "directorylist.h"
#include "mediafiles.h"
#include "playermanager.h"
#include "tracksequencemanager.h"
#include <kiconloader.h>
#include <kactionclasses.h>
......@@ -55,7 +56,9 @@ PlaylistCollection::PlaylistCollection(QWidgetStack *playlistStack) :
m_upcomingPlaylist(0),
m_importPlaylists(true),
m_searchEnabled(true),
m_playing(false)
m_playing(false),
m_showMorePlaylist(0),
m_dynamicPlaylist(0)
{
m_actionHandler = new ActionHandler(this);
PlayerManager::instance()->setPlaylistInterface(this);
......@@ -142,17 +145,35 @@ void PlaylistCollection::createPlaylist(const QString &name)
raise(new Playlist(this, name));
}
void PlaylistCollection::createDynamicPlaylist(const PlaylistList &playlists)
{
if(m_dynamicPlaylist)
m_dynamicPlaylist->setPlaylists(playlists);
else
m_dynamicPlaylist =
new DynamicPlaylist(playlists, this, i18n("Dynamic List"), "midi", false, true);
m_dynamicPlaylist->applySharedSettings();
playlistStack()->raiseWidget(m_dynamicPlaylist);
// TrackSequenceManager::instance()->setCurrentPlaylist(m_dynamicPlaylist);
QObject::connect(m_playlistStack, SIGNAL(aboutToShow(int)),
m_dynamicPlaylist, SLOT(lower()));
}
void PlaylistCollection::showMore(const QString &artist, const QString &album)
{
PlaylistList playlists;
PlaylistSearch::ComponentList components;
playlists.append(CollectionList::instance());
if(currentPlaylist() != CollectionList::instance() &&
currentPlaylist() != m_showMore)
currentPlaylist() != m_showMorePlaylist)
{
playlists.append(currentPlaylist());
}
playlists.append(CollectionList::instance());
{ // Just setting off the artist stuff in its own block.
ColumnList columns;
......@@ -172,12 +193,17 @@ void PlaylistCollection::showMore(const QString &artist, const QString &album)
PlaylistSearch search(playlists, components, PlaylistSearch::MatchAll);
m_showMore = new SearchPlaylist(this, search, i18n("Now Playing"), false, true);
if(m_showMorePlaylist)
m_showMorePlaylist->setPlaylistSearch(search);
else
m_showMorePlaylist = new SearchPlaylist(this, search, i18n("Now Playing"), false, true);
m_showMore->applySharedSettings();
m_playlistStack->raiseWidget(m_showMore);
m_showMorePlaylist->applySharedSettings();
m_playlistStack->raiseWidget(m_showMorePlaylist);
TrackSequenceManager::instance()->setCurrentPlaylist(m_showMorePlaylist);
QObject::connect(m_playlistStack, SIGNAL(aboutToShow(int)), m_showMore, SLOT(deleteLater()));
QObject::connect(m_playlistStack, SIGNAL(aboutToShow(QWidget *)),
m_showMorePlaylist, SLOT(lower(QWidget *)));
}
void PlaylistCollection::removeTrack(const QString &playlist, const QStringList &files)
......@@ -574,7 +600,7 @@ bool PlaylistCollection::containsPlaylistFile(const QString &file) const
bool PlaylistCollection::showMoreActive() const
{
return bool(m_showMore);
return visiblePlaylist() == m_showMorePlaylist;
}
void PlaylistCollection::enableDirWatch(bool enable)
......
......@@ -32,7 +32,10 @@ class Playlist;
class PlaylistItem;
class HistoryPlaylist;
class UpcomingPlaylist;
class SearchPlaylist;
class DynamicPlaylist;
typedef QValueList<Playlist *> PlaylistList;
typedef QValueList<PlaylistItem *> PlaylistItemList;
class PlaylistCollection : public PlaylistInterface, CollectionIface
......@@ -58,6 +61,7 @@ public:
virtual QStringList playlists() const;
virtual void createPlaylist(const QString &name);
virtual void createDynamicPlaylist(const PlaylistList &playlists);
virtual void showMore(const QString &artist, const QString &album = QString::null);
virtual void removeTrack(const QString &playlist, const QStringList &files);
......@@ -172,7 +176,8 @@ private:
bool m_searchEnabled;
bool m_playing;
QGuardedPtr<Playlist> m_showMore;
SearchPlaylist *m_showMorePlaylist;
DynamicPlaylist *m_dynamicPlaylist;
};
/**
......
......@@ -40,9 +40,8 @@ SearchPlaylist::SearchPlaylist(PlaylistCollection *collection,
void SearchPlaylist::setPlaylistSearch(const PlaylistSearch &s, bool update)
{
m_search = s;
if(update)
updateItems();
setPlaylists(s.playlists());
}
////////////////////////////////////////////////////////////////////////////////
......@@ -79,6 +78,11 @@ void SearchPlaylist::updateItems()
dataChanged();
createItems(newItems);
if(synchronizePlaying()) {
kdDebug(65432) << k_funcinfo << "synchronizing playing" << endl;
synchronizePlayingItems(m_search.playlists(), true);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment