Commit 64e54886 authored by Scott Wheeler's avatar Scott Wheeler

Make it such that dragging items to the whitespace in the playlist list will

create a new playlist.

59808-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=236205
parent 5a639c26
......@@ -306,7 +306,7 @@ void PlaylistBox::deleteItem(Item *item)
void PlaylistBox::decode(QMimeSource *s, Item *item)
{
if(!s || !item || !item->playlist())
if(!s)
return;
KURL::List urls;
......@@ -316,8 +316,11 @@ void PlaylistBox::decode(QMimeSource *s, Item *item)
for(KURL::List::Iterator it = urls.begin(); it != urls.end(); it++)
files.append((*it).path());
m_splitter->slotAddToPlaylist(files, item->playlist());
if(item && item->playlist())
m_splitter->slotAddToPlaylist(files, item->playlist());
else
emit signalCreatePlaylist(files);
}
}
......@@ -335,7 +338,12 @@ void PlaylistBox::contentsDragMoveEvent(QDragMoveEvent *e)
//
// Otherwise, do not accept the event.
if(KURLDrag::canDecode(e) && itemAt(e->pos())) {
if(!KURLDrag::canDecode(e)) {
e->accept(false);
return;
}
if(itemAt(e->pos())) {
Item *target = static_cast<Item *>(itemAt(e->pos()));
// This is a semi-dirty hack to check if the items are coming from within
......@@ -344,16 +352,25 @@ void PlaylistBox::contentsDragMoveEvent(QDragMoveEvent *e)
// coming from outside of JuK.
if(dynamic_cast<Playlist *>(e->source())) {
if(target->playlist() && target->playlist() != CollectionList::instance() && !target->isSelected())
if(target->playlist() &&
target->playlist() != CollectionList::instance() &&
!target->isSelected())
{
e->accept(true);
}
else
e->accept(false);
}
else // the dropped items are coming from outside of JuK
e->accept(true);
}
else
e->accept(false);
else {
// We're dragging over the whitespace. We'll use this case to make it
// possible to create new lists.
e->accept(true);
}
}
QValueList<PlaylistBox::Item *> PlaylistBox::selectedItems()
......
......@@ -84,6 +84,7 @@ public slots:
signals:
void signalCurrentChanged(const PlaylistList &);
void signalDoubleClicked();
void signalCreatePlaylist(const QStringList &files);
void signalCreateSearchList(const PlaylistSearch &search,
const QString &searchCategory,
const QString &name);
......
......@@ -424,6 +424,9 @@ void PlaylistSplitter::setupLayout()
connect(m_playlistBox, SIGNAL(signalCreateSearchList(const PlaylistSearch &, const QString &, const QString &)),
this, SLOT(slotCreateSearchList(const PlaylistSearch &, const QString &, const QString &)));
connect(m_playlistBox, SIGNAL(signalCreatePlaylist(const QStringList &)),
this, SLOT(slotCreatePlaylist(const QStringList &)));
// Create a splitter to go between the playlists and the editor.
QSplitter *editorSplitter = new QSplitter(Qt::Vertical, this, "editorSplitter");
......
......@@ -339,6 +339,10 @@ private slots:
* are loaded and current (i.e. the cache is in sync with the file system).
*/
void slotScanDirectories() { open(m_directoryList); }
/**
* Set the next item to be played to item.
*/
void slotSetNextItem(PlaylistItem *item = 0) { m_nextPlaylistItem = item; }
/**
......@@ -347,6 +351,11 @@ private slots:
*/
void slotDirChanged(const QString &dir) { slotAddToPlaylist(dir, m_collection); }
/**
* Create a playlist that contains the specified files.
*/
void slotCreatePlaylist(const QStringList &files) { slotAddToPlaylist(files, slotCreatePlaylist()); }
/**
* This slot creates a playlist that contains the listed items. It is
* private since we want to encapsulate the PlaylistItem handling.
......
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