Commit 1f3b8e66 authored by Scott Wheeler's avatar Scott Wheeler

Clean up all of the mess with the visible / current playlist split. This

should finally make all of the actions and stuff work properly.

BUG:91504

svn path=/trunk/kdemultimedia/juk/; revision=359661
parent 69f43660
...@@ -216,19 +216,6 @@ void PlaylistBox::paste() ...@@ -216,19 +216,6 @@ void PlaylistBox::paste()
// PlaylistBox protected methods // PlaylistBox protected methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Playlist *PlaylistBox::currentPlaylist() const
{
if(m_dynamicPlaylist)
return m_dynamicPlaylist;
if(Playlist::playingItem())
return Playlist::playingItem()->playlist();
else if(currentItem() && static_cast<Item *>(currentItem())->playlist())
return static_cast<Item *>(currentItem())->playlist();
else
return PlaylistCollection::currentPlaylist();
}
void PlaylistBox::slotFreezePlaylists() void PlaylistBox::slotFreezePlaylists()
{ {
setCanDeletePlaylist(false); setCanDeletePlaylist(false);
...@@ -370,14 +357,6 @@ void PlaylistBox::setCanDeletePlaylist(bool canDelete) ...@@ -370,14 +357,6 @@ void PlaylistBox::setCanDeletePlaylist(bool canDelete)
treeView->slotCanDeletePlaylist(canDelete); treeView->slotCanDeletePlaylist(canDelete);
} }
Playlist *PlaylistBox::visiblePlaylist() const
{
if(m_dynamicPlaylist)
return m_dynamicPlaylist;
return selectedItems().front()->playlist();
}
void PlaylistBox::slotPlaylistDestroyed(Playlist *p) void PlaylistBox::slotPlaylistDestroyed(Playlist *p)
{ {
emit signalPlaylistDestroyed(p); emit signalPlaylistDestroyed(p);
......
...@@ -62,12 +62,10 @@ public: ...@@ -62,12 +62,10 @@ public:
virtual void setCanDeletePlaylist(bool canDelete); virtual void setCanDeletePlaylist(bool canDelete);
Item *dropItem() const { return m_dropItem; } Item *dropItem() const { return m_dropItem; }
Playlist *visiblePlaylist() const;
public slots: public slots:
void paste(); void paste();
void clear() {} void clear() {}
virtual Playlist *currentPlaylist() const;
void slotFreezePlaylists(); void slotFreezePlaylists();
void slotUnfreezePlaylists(); void slotUnfreezePlaylists();
......
...@@ -129,7 +129,7 @@ QStringList PlaylistCollection::playlists() const ...@@ -129,7 +129,7 @@ QStringList PlaylistCollection::playlists() const
QObjectList *childList = m_playlistStack->queryList("Playlist"); QObjectList *childList = m_playlistStack->queryList("Playlist");
QObject *obj; QObject *obj;
for(obj = childList->first(); obj; obj = childList->next()) { for(obj = childList->first(); obj; obj = childList->next()) {
Playlist *p = static_cast<Playlist*>(obj); Playlist *p = static_cast<Playlist *>(obj);
l.append(p->name()); l.append(p->name());
} }
...@@ -204,7 +204,7 @@ void PlaylistCollection::open(const QStringList &l) ...@@ -204,7 +204,7 @@ void PlaylistCollection::open(const QStringList &l)
if(files.isEmpty()) if(files.isEmpty())
return; return;
if(currentPlaylist() == CollectionList::instance() || if(visiblePlaylist() == CollectionList::instance() ||
KMessageBox::questionYesNo( KMessageBox::questionYesNo(
widget, widget,
i18n("Do you want to add these items to the current list or to the collection list?"), i18n("Do you want to add these items to the current list or to the collection list?"),
...@@ -215,7 +215,7 @@ void PlaylistCollection::open(const QStringList &l) ...@@ -215,7 +215,7 @@ void PlaylistCollection::open(const QStringList &l)
CollectionList::instance()->addFiles(files, m_importPlaylists); CollectionList::instance()->addFiles(files, m_importPlaylists);
} }
else else
currentPlaylist()->addFiles(files, m_importPlaylists); visiblePlaylist()->addFiles(files, m_importPlaylists);
dataChanged(); dataChanged();
} }
...@@ -260,7 +260,7 @@ void PlaylistCollection::addFolder() ...@@ -260,7 +260,7 @@ void PlaylistCollection::addFolder()
void PlaylistCollection::rename() void PlaylistCollection::rename()
{ {
QString old = currentPlaylist()->name(); QString old = visiblePlaylist()->name();
QString name = playlistNameDialog(i18n("Rename"), old, false); QString name = playlistNameDialog(i18n("Rename"), old, false);
m_playlistNames.remove(old); m_playlistNames.remove(old);
...@@ -268,25 +268,25 @@ void PlaylistCollection::rename() ...@@ -268,25 +268,25 @@ void PlaylistCollection::rename()
if(name.isNull()) if(name.isNull())
return; return;
currentPlaylist()->setName(name); visiblePlaylist()->setName(name);
} }
void PlaylistCollection::duplicate() void PlaylistCollection::duplicate()
{ {
QString name = playlistNameDialog(i18n("Duplicate"), currentPlaylist()->name()); QString name = playlistNameDialog(i18n("Duplicate"), visiblePlaylist()->name());
if(name.isNull()) if(name.isNull())
return; return;
raise(new Playlist(this, currentPlaylist()->items(), name)); raise(new Playlist(this, visiblePlaylist()->items(), name));
} }
void PlaylistCollection::save() void PlaylistCollection::save()
{ {
currentPlaylist()->save(); visiblePlaylist()->save();
} }
void PlaylistCollection::saveAs() void PlaylistCollection::saveAs()
{ {
currentPlaylist()->saveAs(); visiblePlaylist()->saveAs();
} }
void PlaylistCollection::remove() void PlaylistCollection::remove()
...@@ -296,16 +296,16 @@ void PlaylistCollection::remove() ...@@ -296,16 +296,16 @@ void PlaylistCollection::remove()
void PlaylistCollection::reload() void PlaylistCollection::reload()
{ {
if(currentPlaylist() == CollectionList::instance()) if(visiblePlaylist() == CollectionList::instance())
CollectionList::instance()->addFiles(m_folderList, m_importPlaylists); CollectionList::instance()->addFiles(m_folderList, m_importPlaylists);
else else
currentPlaylist()->slotReload(); visiblePlaylist()->slotReload();
} }
void PlaylistCollection::editSearch() void PlaylistCollection::editSearch()
{ {
SearchPlaylist *p = dynamic_cast<SearchPlaylist *>(currentPlaylist()); SearchPlaylist *p = dynamic_cast<SearchPlaylist *>(visiblePlaylist());
if(!p) if(!p)
return; return;
...@@ -326,22 +326,22 @@ void PlaylistCollection::setCanDeletePlaylist(bool) ...@@ -326,22 +326,22 @@ void PlaylistCollection::setCanDeletePlaylist(bool)
void PlaylistCollection::removeItems() void PlaylistCollection::removeItems()
{ {
currentPlaylist()->slotRemoveSelectedItems(); visiblePlaylist()->slotRemoveSelectedItems();
} }
void PlaylistCollection::refreshItems() void PlaylistCollection::refreshItems()
{ {
currentPlaylist()->slotRefresh(); visiblePlaylist()->slotRefresh();
} }
void PlaylistCollection::renameItems() void PlaylistCollection::renameItems()
{ {
currentPlaylist()->slotRenameFile(); visiblePlaylist()->slotRenameFile();
} }
PlaylistItemList PlaylistCollection::selectedItems() PlaylistItemList PlaylistCollection::selectedItems()
{ {
return currentPlaylist()->selectedItems(); return visiblePlaylist()->selectedItems();
} }
void PlaylistCollection::scanFolders() void PlaylistCollection::scanFolders()
...@@ -386,12 +386,12 @@ void PlaylistCollection::createFolderPlaylist() ...@@ -386,12 +386,12 @@ void PlaylistCollection::createFolderPlaylist()
void PlaylistCollection::guessTagFromFile() void PlaylistCollection::guessTagFromFile()
{ {
currentPlaylist()->slotGuessTagInfo(TagGuesser::FileName); visiblePlaylist()->slotGuessTagInfo(TagGuesser::FileName);
} }
void PlaylistCollection::guessTagFromInternet() void PlaylistCollection::guessTagFromInternet()
{ {
currentPlaylist()->slotGuessTagInfo(TagGuesser::MusicBrainz); visiblePlaylist()->slotGuessTagInfo(TagGuesser::MusicBrainz);
} }
void PlaylistCollection::setSearchEnabled(bool enable) void PlaylistCollection::setSearchEnabled(bool enable)
...@@ -401,7 +401,7 @@ void PlaylistCollection::setSearchEnabled(bool enable) ...@@ -401,7 +401,7 @@ void PlaylistCollection::setSearchEnabled(bool enable)
m_searchEnabled = enable; m_searchEnabled = enable;
currentPlaylist()->setSearchEnabled(enable); visiblePlaylist()->setSearchEnabled(enable);
} }
HistoryPlaylist *PlaylistCollection::historyPlaylist() const HistoryPlaylist *PlaylistCollection::historyPlaylist() const
...@@ -468,15 +468,23 @@ QObject *PlaylistCollection::object() const ...@@ -468,15 +468,23 @@ QObject *PlaylistCollection::object() const
return m_actionHandler; return m_actionHandler;
} }
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
Playlist *PlaylistCollection::currentPlaylist() const Playlist *PlaylistCollection::currentPlaylist() const
{
if(Playlist::playingItem())
return Playlist::playingItem()->playlist();
else
return visiblePlaylist();
}
Playlist *PlaylistCollection::visiblePlaylist() const
{ {
return static_cast<Playlist *>(m_playlistStack->visibleWidget()); return static_cast<Playlist *>(m_playlistStack->visibleWidget());
} }
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
QWidgetStack *PlaylistCollection::playlistStack() const QWidgetStack *PlaylistCollection::playlistStack() const
{ {
return m_playlistStack; return m_playlistStack;
......
...@@ -114,10 +114,22 @@ public: ...@@ -114,10 +114,22 @@ public:
void newItems(const KFileItemList &list) const; void newItems(const KFileItemList &list) const;
/**
* This is the current playlist in all things relating to the player. It
* represents the playlist that either should be played from or is currently
* playing.
*/
virtual Playlist *currentPlaylist() const;
/**
* This is the currently visible playlist and should be used for all user
* interaction elements.
*/
virtual Playlist *visiblePlaylist() const;
class ActionHandler; class ActionHandler;
protected: protected:
virtual Playlist *currentPlaylist() const;
virtual QWidgetStack *playlistStack() const; virtual QWidgetStack *playlistStack() const;
virtual void raise(Playlist *playlist); virtual void raise(Playlist *playlist);
virtual void setupPlaylist(Playlist *playlist, const QString &iconName); virtual void setupPlaylist(Playlist *playlist, const QString &iconName);
......
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