Commit 30e31ecb authored by Scott Wheeler's avatar Scott Wheeler

dded the first part of support for selecting multiple playlists at once.

More to come soon...

svn path=/trunk/kdemultimedia/juk/; revision=217953
parent 952fcd08
......@@ -62,6 +62,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const char *name) : KListBox(
SLOT(slotContextDeleteItem()));
setAcceptDrops(true);
setSelectionMode(Extended);
connect(this, SIGNAL(currentChanged(QListBoxItem *)),
this, SLOT(slotPlaylistChanged(QListBoxItem *)));
......@@ -338,15 +339,32 @@ void PlaylistBox::mousePressEvent(QMouseEvent *e)
}
}
QValueList<PlaylistBox::Item *> PlaylistBox::selectedItems() const
{
QValueList<Item *> l;
int c = count();
for(int i = 0; i < c; i++)
if(isSelected(i))
l.append(static_cast<Item *>(item(i)));
return l;
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistBox private slots
////////////////////////////////////////////////////////////////////////////////
void PlaylistBox::slotPlaylistChanged(QListBoxItem *item)
void PlaylistBox::slotPlaylistChanged(QListBoxItem *)
{
Item *i = dynamic_cast<Item *>(item);
if(m_updatePlaylistStack && i && i->playlist())
emit signalCurrentChanged(i->playlist());
QValueList<Item *> items = selectedItems();
if(m_updatePlaylistStack && !items.isEmpty()) {
QValueList<Playlist *> playlists;
for(QValueList<Item *>::iterator i = items.begin(); i != items.end(); ++i)
playlists.append((*i)->playlist());
emit signalCurrentChanged(playlists);
}
}
void PlaylistBox::slotDoubleClicked(QListBoxItem *)
......
......@@ -68,7 +68,7 @@ public slots:
void clear() {} // override the (destructive) default
signals:
void signalCurrentChanged(Playlist *);
void signalCurrentChanged(const QValueList<Playlist *> &);
void signalDoubleClicked();
private:
......@@ -89,12 +89,14 @@ private:
*/
void addName(const QString &name) { m_names.append(name); }
QValueList<Item *> selectedItems() const;
private slots:
/**
* Catches QListBox::currentChanged(QListBoxItem *), does a cast and then re-emits
* the signal as currentChanged(Item *).
*/
void slotPlaylistChanged(QListBoxItem *item);
void slotPlaylistChanged(QListBoxItem *);
void slotDoubleClicked(QListBoxItem *);
void slotShowContextMenu(QListBoxItem *item, const QPoint &point);
......
......@@ -367,8 +367,8 @@ void PlaylistSplitter::setupLayout()
// Make the connection that will update the selected playlist when a
// selection is made in the playlist box.
connect(m_playlistBox, SIGNAL(signalCurrentChanged(Playlist *)),
this, SLOT(slotChangePlaylist(Playlist *)));
connect(m_playlistBox, SIGNAL(signalCurrentChanged(const QValueList<Playlist *> &)),
this, SLOT(slotChangePlaylist(const QValueList<Playlist *> &)));
connect(m_playlistBox, SIGNAL(signalDoubleClicked()), this, SIGNAL(signalListBoxDoubleClicked()));
......@@ -542,15 +542,15 @@ QString PlaylistSplitter::play(PlaylistItem *item)
// private slots
////////////////////////////////////////////////////////////////////////////////
void PlaylistSplitter::slotChangePlaylist(Playlist *p)
void PlaylistSplitter::slotChangePlaylist(const QValueList<Playlist *> &l)
{
if(!p)
if(l.isEmpty())
return;
m_nextPlaylistItem = 0;
m_playlistStack->raiseWidget(p);
m_playlistStack->raiseWidget(l.first());
m_editor->slotSetItems(playlistSelection());
emit signalPlaylistChanged();
emit signalPlaylistChanged();
}
void PlaylistSplitter::slotPlaylistCountChanged(Playlist *p)
......
......@@ -263,7 +263,7 @@ private:
QString play(PlaylistItem *item);
private slots:
void slotChangePlaylist(Playlist *p);
void slotChangePlaylist(const QValueList<Playlist *> &l);
void slotPlaylistCountChanged(Playlist *p);
/**
* Add a directory to the directory list queue. We need to queue these
......
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