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()
// 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()
{
setCanDeletePlaylist(false);
......@@ -370,14 +357,6 @@ void PlaylistBox::setCanDeletePlaylist(bool canDelete)
treeView->slotCanDeletePlaylist(canDelete);
}
Playlist *PlaylistBox::visiblePlaylist() const
{
if(m_dynamicPlaylist)
return m_dynamicPlaylist;
return selectedItems().front()->playlist();
}
void PlaylistBox::slotPlaylistDestroyed(Playlist *p)
{
emit signalPlaylistDestroyed(p);
......
......@@ -62,12 +62,10 @@ public:
virtual void setCanDeletePlaylist(bool canDelete);
Item *dropItem() const { return m_dropItem; }
Playlist *visiblePlaylist() const;
public slots:
void paste();
void clear() {}
virtual Playlist *currentPlaylist() const;
void slotFreezePlaylists();
void slotUnfreezePlaylists();
......
......@@ -129,7 +129,7 @@ QStringList PlaylistCollection::playlists() const
QObjectList *childList = m_playlistStack->queryList("Playlist");
QObject *obj;
for(obj = childList->first(); obj; obj = childList->next()) {
Playlist *p = static_cast<Playlist*>(obj);
Playlist *p = static_cast<Playlist *>(obj);
l.append(p->name());
}
......@@ -204,7 +204,7 @@ void PlaylistCollection::open(const QStringList &l)
if(files.isEmpty())
return;
if(currentPlaylist() == CollectionList::instance() ||
if(visiblePlaylist() == CollectionList::instance() ||
KMessageBox::questionYesNo(
widget,
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)
CollectionList::instance()->addFiles(files, m_importPlaylists);
}
else
currentPlaylist()->addFiles(files, m_importPlaylists);
visiblePlaylist()->addFiles(files, m_importPlaylists);
dataChanged();
}
......@@ -260,7 +260,7 @@ void PlaylistCollection::addFolder()
void PlaylistCollection::rename()
{
QString old = currentPlaylist()->name();
QString old = visiblePlaylist()->name();
QString name = playlistNameDialog(i18n("Rename"), old, false);
m_playlistNames.remove(old);
......@@ -268,25 +268,25 @@ void PlaylistCollection::rename()
if(name.isNull())
return;
currentPlaylist()->setName(name);
visiblePlaylist()->setName(name);
}
void PlaylistCollection::duplicate()
{
QString name = playlistNameDialog(i18n("Duplicate"), currentPlaylist()->name());
QString name = playlistNameDialog(i18n("Duplicate"), visiblePlaylist()->name());
if(name.isNull())
return;
raise(new Playlist(this, currentPlaylist()->items(), name));
raise(new Playlist(this, visiblePlaylist()->items(), name));
}
void PlaylistCollection::save()
{
currentPlaylist()->save();
visiblePlaylist()->save();
}
void PlaylistCollection::saveAs()
{
currentPlaylist()->saveAs();
visiblePlaylist()->saveAs();
}
void PlaylistCollection::remove()
......@@ -296,16 +296,16 @@ void PlaylistCollection::remove()
void PlaylistCollection::reload()
{
if(currentPlaylist() == CollectionList::instance())
if(visiblePlaylist() == CollectionList::instance())
CollectionList::instance()->addFiles(m_folderList, m_importPlaylists);
else
currentPlaylist()->slotReload();
visiblePlaylist()->slotReload();
}
void PlaylistCollection::editSearch()
{
SearchPlaylist *p = dynamic_cast<SearchPlaylist *>(currentPlaylist());
SearchPlaylist *p = dynamic_cast<SearchPlaylist *>(visiblePlaylist());
if(!p)
return;
......@@ -326,22 +326,22 @@ void PlaylistCollection::setCanDeletePlaylist(bool)
void PlaylistCollection::removeItems()
{
currentPlaylist()->slotRemoveSelectedItems();
visiblePlaylist()->slotRemoveSelectedItems();
}
void PlaylistCollection::refreshItems()
{
currentPlaylist()->slotRefresh();
visiblePlaylist()->slotRefresh();
}
void PlaylistCollection::renameItems()
{
currentPlaylist()->slotRenameFile();
visiblePlaylist()->slotRenameFile();
}
PlaylistItemList PlaylistCollection::selectedItems()
{
return currentPlaylist()->selectedItems();
return visiblePlaylist()->selectedItems();
}
void PlaylistCollection::scanFolders()
......@@ -386,12 +386,12 @@ void PlaylistCollection::createFolderPlaylist()
void PlaylistCollection::guessTagFromFile()
{
currentPlaylist()->slotGuessTagInfo(TagGuesser::FileName);
visiblePlaylist()->slotGuessTagInfo(TagGuesser::FileName);
}
void PlaylistCollection::guessTagFromInternet()
{
currentPlaylist()->slotGuessTagInfo(TagGuesser::MusicBrainz);
visiblePlaylist()->slotGuessTagInfo(TagGuesser::MusicBrainz);
}
void PlaylistCollection::setSearchEnabled(bool enable)
......@@ -401,7 +401,7 @@ void PlaylistCollection::setSearchEnabled(bool enable)
m_searchEnabled = enable;
currentPlaylist()->setSearchEnabled(enable);
visiblePlaylist()->setSearchEnabled(enable);
}
HistoryPlaylist *PlaylistCollection::historyPlaylist() const
......@@ -468,15 +468,23 @@ QObject *PlaylistCollection::object() const
return m_actionHandler;
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
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());
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
QWidgetStack *PlaylistCollection::playlistStack() const
{
return m_playlistStack;
......
......@@ -114,10 +114,22 @@ public:
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;
protected:
virtual Playlist *currentPlaylist() const;
virtual QWidgetStack *playlistStack() const;
virtual void raise(Playlist *playlist);
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