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

Doing some clean up so that there's a clean split between the visible item

and the current item in the PlaylistCollection.  The current item should
always correspond to the playlist-like methods -- playing things, advancing
tracks, etc.  The visible playlist is useful for things like the tag editor
and k3b exporter.

svn path=/trunk/kdemultimedia/juk/; revision=353246
parent a04623d0
......@@ -222,8 +222,8 @@ KAction *K3bPlaylistExporter::action()
void K3bPlaylistExporter::slotExport()
{
if(m_playlistBox) {
setPlaylist(m_playlistBox->currentPlaylist());
exportPlaylistItems(m_playlistBox->currentPlaylist()->items());
setPlaylist(m_playlistBox->visiblePlaylist());
exportPlaylistItems(m_playlistBox->visiblePlaylist()->items());
}
}
......
......@@ -221,7 +221,9 @@ Playlist *PlaylistBox::currentPlaylist() const
if(m_dynamicPlaylist)
return m_dynamicPlaylist;
if(currentItem() && static_cast<Item *>(currentItem())->playlist())
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();
......@@ -365,7 +367,7 @@ Playlist *PlaylistBox::visiblePlaylist() const
if(m_dynamicPlaylist)
return m_dynamicPlaylist;
return PlaylistCollection::currentPlaylist();
return selectedItems().front()->playlist();
}
void PlaylistBox::slotPlaylistDestroyed(Playlist *p)
......@@ -573,11 +575,12 @@ void PlaylistBox::keyReleaseEvent(QKeyEvent *e)
KListView::keyReleaseEvent(e);
}
PlaylistBox::ItemList PlaylistBox::selectedItems()
PlaylistBox::ItemList PlaylistBox::selectedItems() const
{
ItemList l;
for(QListViewItemIterator it(this, QListViewItemIterator::Selected); it.current(); ++it)
for(QListViewItemIterator it(const_cast<PlaylistBox *>(this),
QListViewItemIterator::Selected); it.current(); ++it)
l.append(static_cast<Item *>(*it));
return l;
......
......@@ -92,7 +92,7 @@ private:
virtual void keyPressEvent(QKeyEvent *e);
virtual void keyReleaseEvent(QKeyEvent *e);
QValueList<Item *> selectedItems();
QValueList<Item *> selectedItems() const;
void setSingleItem(QListViewItem *item);
void setupItem(Item *item);
......
......@@ -97,8 +97,8 @@ void PlaylistSplitter::setupLayout()
connect(m_playlistBox->object(), SIGNAL(signalSelectedItemsChanged()),
this, SLOT(slotPlaylistSelectionChanged()));
connect(m_playlistBox, SIGNAL(signalPlaylistDestroyed(Playlist*)),
m_editor, SLOT(slotPlaylistDestroyed(Playlist*)));
connect(m_playlistBox, SIGNAL(signalPlaylistDestroyed(Playlist *)),
m_editor, SLOT(slotPlaylistDestroyed(Playlist *)));
moveToFirst(m_playlistBox);
......@@ -157,7 +157,7 @@ void PlaylistSplitter::slotShowSearchResults()
void PlaylistSplitter::slotPlaylistSelectionChanged()
{
m_editor->slotSetItems(static_cast<PlaylistCollection *>(m_playlistBox)->selectedItems());
m_editor->slotSetItems(visiblePlaylist()->selectedItems());
}
void PlaylistSplitter::slotPlaylistChanged(QWidget *w)
......
......@@ -28,8 +28,6 @@
#include "playlistinterface.h"
#include "actioncollection.h"
#include "tag.h"
#include "playlist.h"
#include "playlistitem.h"
using namespace ActionCollection;
......@@ -101,16 +99,8 @@ StatusLabel::~StatusLabel()
void StatusLabel::updateCurrent()
{
kdDebug(65432) << k_funcinfo << endl;
// Use a hack to always show the currently playing playlist in the status
// bar. We can't change PlaylistBox::currentPlaylist() to do this as that
// has too many sideeffects at this point.
if(Playlist::playingItem()) {
PlaylistInterface *playlist = Playlist::playingItem()->playlist();
FileHandle file = playlist->currentFile();
if(playlist()->playing()) {
FileHandle file = playlist()->currentFile();
QString mid = file.tag()->artist().isEmpty() || file.tag()->title().isEmpty()
? QString::null : QString(" - ");
......@@ -118,15 +108,13 @@ void StatusLabel::updateCurrent()
QString text = file.tag()->artist() + mid + file.tag()->title();
m_trackLabel->setText(text);
m_playlistLabel->setText(playlist->name().simplifyWhiteSpace());
m_playlistLabel->setText(playlist()->name().simplifyWhiteSpace());
}
else
updateData();
}
void StatusLabel::updateData()
{
kdDebug(65432) << k_funcinfo << endl;
updateCurrent();
if(!playlist()->playing()) {
setItemTotalTime(0);
......@@ -151,8 +139,6 @@ void StatusLabel::updateData()
m_playlistLabel->setText(playlist()->name());
m_trackLabel->setText(i18n("1 item", "%n items", playlist()->count()) + " - " + time);
}
else if(Playlist::playingItem())
updateCurrent();
}
////////////////////////////////////////////////////////////////////////////////
......
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