Commit dec97af8 authored by Scott Wheeler's avatar Scott Wheeler

Make it possible to reload multiple playlists at once.

CCMAIL:60356-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=235890
parent 065bdbcf
......@@ -15,6 +15,8 @@
* *
***************************************************************************/
#include <kdebug.h>
#include "dynamicplaylist.h"
#include "collectionlist.h"
......@@ -40,6 +42,18 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists, QWidget *parent,
connect(CollectionList::instance(), SIGNAL(signalCollectionChanged()), this, SLOT(slotSetDirty()));
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
void DynamicPlaylist::slotReload()
{
for(PlaylistList::Iterator it = m_playlists.begin(); it != m_playlists.end(); ++it)
(*it)->slotReload();
checkUpdateItems();
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
......@@ -55,6 +69,16 @@ PlaylistItemList DynamicPlaylist::items() const
}
void DynamicPlaylist::showEvent(QShowEvent *e)
{
checkUpdateItems();
Playlist::showEvent(e);
}
////////////////////////////////////////////////////////////////////////////////
// private methods
////////////////////////////////////////////////////////////////////////////////
void DynamicPlaylist::checkUpdateItems()
{
if(m_dirty) {
PlaylistItemList newItems = items();
......@@ -64,8 +88,6 @@ void DynamicPlaylist::showEvent(QShowEvent *e)
}
m_dirty = false;
}
Playlist::showEvent(e);
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -33,12 +33,19 @@ public:
*/
DynamicPlaylist(const PlaylistList &lists, QWidget *parent, const QString &name = QString::null);
public slots:
/**
* Reimplemented so that it will reload all of the playlists that are
* associated with the dynamic list.
*/
virtual void slotReload();
protected:
/**
* Returns true if this list's items need to be updated the next time it's
* shown.
*/
bool dirty() { return m_dirty; }
bool dirty() const { return m_dirty; }
/**
* Return a list of the items in this playlist. For example in a search
......@@ -56,6 +63,14 @@ protected:
protected slots:
void slotSetDirty(bool d = true) { m_dirty = d; }
private:
/**
* Checks to see if the current list of items is "dirty" and if so updates
* this dynamic playlist's items to be in sync with the lists that it is a
* wrapper around.
*/
void checkUpdateItems();
private slots:
void slotUpdateItems();
......
......@@ -28,6 +28,7 @@
#include <qheader.h>
#include <qcursor.h>
#include <qdir.h>
#include <qeventloop.h>
#include <stdlib.h>
#include <limits.h>
......@@ -274,6 +275,12 @@ void Playlist::clearItems(const PlaylistItemList &items)
for(PlaylistItemList::ConstIterator it = items.begin(); it != items.end(); ++it)
clearItem(*it, false);
// Since we're using deleteLater() in the above call and calls to this will expect
// those items to have actually gone away.
// kapp->processEvents();
kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
emit signalNumberOfItemsChanged(this);
}
......@@ -290,6 +297,7 @@ QStringList Playlist::files() const
PlaylistItemList Playlist::items()
{
PlaylistItemList list;
for(QListViewItemIterator it(this); it.current(); ++it)
list.append(static_cast<PlaylistItem *>(it.current()));
......@@ -301,6 +309,7 @@ PlaylistItemList Playlist::visibleItems() const
PlaylistItemList list;
PlaylistItem *i = static_cast<PlaylistItem *>(firstChild());
for(; i; i = static_cast<PlaylistItem *>(i->itemBelow())) {
// This check should be removed at some point since those items should
// all be already visible at the time of writing there's a bug that
// leaves some invisible items in the list
......@@ -494,7 +503,7 @@ void Playlist::slotReload()
if(!fileInfo.exists() || !fileInfo.isFile() || !fileInfo.isReadable())
return;
clear();
clearItems(items());
loadFile(m_fileName, fileInfo);
}
......
......@@ -188,7 +188,7 @@ public slots:
/**
* Reload the playlist contents from the m3u file.
*/
void slotReload();
virtual void slotReload();
protected:
/**
......
......@@ -244,6 +244,7 @@ public slots:
void slotRenamePlaylist() { m_playlistBox->rename(); }
void slotDuplicatePlaylist() { m_playlistBox->duplicate(); }
void slotDeletePlaylist();
signals:
void signalActivated();
void signalListBoxDoubleClicked();
......
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