Commit ccaa86fb authored by Michael Pyne's avatar Michael Pyne
Browse files

Fix bug 162068 (drag and drop does not work in juk) in trunk.

BUG:162068

svn path=/trunk/KDE/kdemultimedia/juk/; revision=807601
parent 2638194b
......@@ -277,8 +277,8 @@ void CollectionList::contentsDropEvent(QDropEvent *e)
void CollectionList::contentsDragMoveEvent(QDragMoveEvent *e)
{
if(canDecode(e) && e->source() != this)
e->setAccepted(true);
if(e->source() != this)
Playlist::contentsDragMoveEvent(e);
else
e->setAccepted(false);
}
......
......@@ -734,7 +734,17 @@ void Playlist::synchronizePlayingItems(const PlaylistList &sources, bool setMast
void Playlist::copy()
{
QApplication::clipboard()->setMimeData(drag(0)->mimeData(), QClipboard::Clipboard);
PlaylistItemList items = selectedItems();
KUrl::List urls;
foreach(PlaylistItem *item, items) {
urls << KUrl::fromPath(item->file().absFilePath());
}
QMimeData *mimeData = new QMimeData;
urls.populateMimeData(mimeData);
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
}
void Playlist::paste()
......@@ -994,24 +1004,20 @@ void Playlist::removeFromDisk(const PlaylistItemList &items)
}
}
QDrag *Playlist::drag(QWidget *parent)
Q3DragObject *Playlist::dragObject(QWidget *parent)
{
PlaylistItemList items = selectedItems();
KUrl::List urls;
for(PlaylistItemList::Iterator it = items.begin(); it != items.end(); ++it) {
KUrl url;
url.setPath((*it)->file().absFilePath());
urls.append(url);
foreach(PlaylistItem *item, items) {
urls << KUrl::fromPath(item->file().absFilePath());
}
QDrag *drag = new QDrag( parent );
QMimeData *md = new QMimeData;
drag->setMimeData( md );
urls.populateMimeData( md );
K3URLDrag *urlDrag = new K3URLDrag(urls, parent);
drag->setPixmap(BarIcon("sound"));
urlDrag->setPixmap(BarIcon("sound"));
return drag;
return urlDrag;
}
void Playlist::contentsDragEnterEvent(QDragEnterEvent *e)
......@@ -1044,16 +1050,6 @@ bool Playlist::acceptDrag(QDropEvent *e) const
return CoverDrag::canDecode(e) || K3URLDrag::canDecode(e);
}
bool Playlist::canDecode(QMimeSource *s)
{
KUrl::List urls;
if(CoverDrag::canDecode(s))
return true;
return K3URLDrag::decode(s, urls) && !urls.isEmpty();
}
void Playlist::decode(const QMimeData *s, PlaylistItem *item)
{
KUrl::List urls;
......
......@@ -423,9 +423,8 @@ protected:
virtual bool eventFilter(QObject *watched, QEvent *e);
virtual void keyPressEvent(QKeyEvent *e);
virtual QDrag *drag(QWidget *parent);
virtual QDrag *drag() { return drag(this); }
virtual bool canDecode(QMimeSource *s);
virtual Q3DragObject *dragObject(QWidget *parent);
virtual Q3DragObject *dragObject() { return dragObject(this); }
virtual void decode(const QMimeData *s, PlaylistItem *item = 0);
virtual void contentsDropEvent(QDropEvent *e);
virtual void contentsMouseDoubleClickEvent(QMouseEvent *e);
......
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