Commit 4a901ae9 authored by Scott Wheeler's avatar Scott Wheeler

Make it possible to select multiple lists and merge them on the fly.

CCMAIL:56258-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=219412
parent ce21c877
......@@ -138,6 +138,8 @@ protected:
*/
void checkCurrent();
virtual CollectionListItem *collectionItem() { return this; }
private:
QString m_path;
};
......
......@@ -65,8 +65,8 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const char *name) : KListBox(
setAcceptDrops(true);
setSelectionMode(Extended);
connect(this, SIGNAL(currentChanged(QListBoxItem *)),
this, SLOT(slotPlaylistChanged(QListBoxItem *)));
connect(this, SIGNAL(selectionChanged()),
this, SLOT(slotPlaylistChanged()));
connect(this, SIGNAL(doubleClicked(QListBoxItem *)),
this, SLOT(slotDoubleClicked(QListBoxItem *)));
......@@ -362,7 +362,7 @@ QValueList<PlaylistBox::Item *> PlaylistBox::selectedItems() const
// PlaylistBox private slots
////////////////////////////////////////////////////////////////////////////////
void PlaylistBox::slotPlaylistChanged(QListBoxItem *)
void PlaylistBox::slotPlaylistChanged()
{
QValueList<Item *> items = selectedItems();
if(m_updatePlaylistStack && !items.isEmpty()) {
......
......@@ -96,7 +96,7 @@ private slots:
* Catches QListBox::currentChanged(QListBoxItem *), does a cast and then re-emits
* the signal as currentChanged(Item *).
*/
void slotPlaylistChanged(QListBoxItem *);
void slotPlaylistChanged();
void slotDoubleClicked(QListBoxItem *);
void slotShowContextMenu(QListBoxItem *item, const QPoint &point);
......
......@@ -123,20 +123,22 @@ void PlaylistItem::slotRefreshFromDisk()
// PlaylistItem protected methods
////////////////////////////////////////////////////////////////////////////////
PlaylistItem::PlaylistItem(CollectionListItem *item, Playlist *parent) : QObject(parent), KListViewItem(parent),
m_playing(false)
PlaylistItem::PlaylistItem(CollectionListItem *item, Playlist *parent) :
QObject(parent), KListViewItem(parent),
m_playing(false)
{
setup(item, parent);
}
PlaylistItem::PlaylistItem(CollectionListItem *item, Playlist *parent, QListViewItem *after) : QObject(parent), KListViewItem(parent, after),
m_playing(false)
PlaylistItem::PlaylistItem(CollectionListItem *item, Playlist *parent, QListViewItem *after) :
QObject(parent), KListViewItem(parent, after),
m_playing(false)
{
setup(item, parent);
}
PlaylistItem::PlaylistItem(Playlist *parent) : QObject(parent), KListViewItem(parent),
m_playing(false)
m_collectionItem(0), m_data(0), m_playing(false)
{
setDragEnabled(true);
}
......@@ -282,6 +284,8 @@ void PlaylistItem::slotRefreshImpl()
void PlaylistItem::setup(CollectionListItem *item, Playlist *parent)
{
m_collectionItem = item;
if(item) {
m_data = item->data()->newUser();
item->addChildItem(this);
......
......@@ -44,6 +44,7 @@ typedef QValueList<PlaylistItem *> PlaylistItemList;
class PlaylistItem : public QObject, public KListViewItem
{
friend class Playlist;
friend class PlaylistSplitter;
friend class CollectionList;
/**
......@@ -100,6 +101,10 @@ protected:
*/
PlaylistItem(CollectionListItem *item, Playlist *parent);
PlaylistItem(CollectionListItem *item, Playlist *parent, QListViewItem *after);
/**
* This is the constructor that shold be used by subclasses.
*/
PlaylistItem(Playlist *parent);
/**
......@@ -120,6 +125,8 @@ protected:
bool isValid() const;
virtual CollectionListItem *collectionItem() { return m_collectionItem; }
protected slots:
void slotRefreshImpl();
......@@ -129,6 +136,7 @@ signals:
private:
void setup(CollectionListItem *item, Playlist *parent);
CollectionListItem *m_collectionItem;
Data *m_data;
bool m_playing;
};
......
......@@ -53,7 +53,8 @@ void processEvents()
////////////////////////////////////////////////////////////////////////////////
PlaylistSplitter::PlaylistSplitter(QWidget *parent, bool restore, const char *name) : QSplitter(Qt::Horizontal, parent, name),
m_playingItem(0), m_restore(restore), m_nextPlaylistItem(0)
m_playingItem(0), m_dynamicList(0),
m_restore(restore), m_nextPlaylistItem(0)
{
if(!m_mediaExtensions && !m_listExtensions) {
m_mediaExtensions = new QStringList();
......@@ -166,7 +167,9 @@ void PlaylistSplitter::stop()
Playlist *p = static_cast<Playlist *>(m_playingItem->listView());
p->setPlaying(m_playingItem, false);
if(p)
p->setPlaying(m_playingItem, false);
m_playingItem = 0;
}
......@@ -549,7 +552,8 @@ void PlaylistSplitter::setupPlaylist(Playlist *p, bool raise, const char *icon)
connect(p, SIGNAL(signalSetNext(PlaylistItem *)),
this, SLOT(slotSetNextItem(PlaylistItem *)));
m_playlistBox->createItem(p, icon, raise);
if(icon)
m_playlistBox->createItem(p, icon, raise);
if(raise)
m_playlistStack->raiseWidget(p);
......@@ -596,12 +600,36 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
if(l.isEmpty())
return;
Playlist *current = m_dynamicList;
m_searchWidget->clear();
m_nextPlaylistItem = 0;
m_playlistStack->raiseWidget(l.first());
m_editor->slotSetItems(playlistSelection());
emit signalPlaylistChanged();
if(l.count() == 1) {
m_playlistStack->raiseWidget(l.first());
m_editor->slotSetItems(playlistSelection());
m_dynamicList = 0;
emit signalPlaylistChanged();
}
else {
m_dynamicList = new Playlist(m_playlistStack, i18n("Dynamic List"));
setupPlaylist(m_dynamicList, true, 0);
// unsorted...
m_dynamicList->setSorting(m_dynamicList->columns() + 1);
PlaylistItem *previous = 0;
for(PlaylistList::ConstIterator it = l.begin(); it != l.end(); ++it) {
if(*it) {
PlaylistItemList items = (*it)->items();
for(PlaylistItemList::Iterator itemIt = items.begin(); itemIt != items.end(); ++itemIt)
previous = new PlaylistItem((*itemIt)->collectionItem(), m_dynamicList, previous);
}
}
}
if(current)
delete current;
}
void PlaylistSplitter::slotPlaylistCountChanged(Playlist *p)
......
......@@ -252,6 +252,9 @@ private:
void readConfig();
void saveConfig();
void addImpl(const QString &file, Playlist *list);
/**
* If NULL is passed for the icon, no entry is created in the PlaylistBox
*/
void setupPlaylist(Playlist *p, bool raise = false, const char *icon = "midi");
/**
......@@ -302,6 +305,7 @@ private:
TagEditor *m_editor;
CollectionList *m_collection;
Playlist *m_dynamicList;
StringHash m_playlistFiles;
......
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