[Patch+Problem] Enabling drag&drop from the albums applet

Seb Ruiz ruiz at kde.org
Sun Oct 12 04:58:40 CEST 2008


2008/10/11 Andreas Mützel <andreas.muetzel at gmx.net>:
> Hi,
>
> i'm trying to implement dragging functions in the albums applet so that you
> can drag albums and/or songs to the playlist from there.
>
> It's almost working but one issue prevents me from finishing the work: If i
> simply enable dragging in the albums applet the dragged items won't be
> recognized by the playlist because of the missing mimedata, so i wrote an
> AlbumsModel that should take care of this.
> That seems to work, but there is a strange problem with the treeview in the
> albums applet:
> If you drag something, qt/amarok/whatever seems to request the mime data of
> the parent entry. I.e. if you drag an album to the playlist nothing happens
> but if you drag a single track to the playlist the whole album is added.
>
> My work up to this point is attached as a patch.
> The file "context/applets/albums/AlbumsModel.cpp" contains debug output that
> tells you whether mime data for a TrackItem or an AlbumItem is requested so
> you can verify that mime data for the parent entry seems to be fetched.
>
> Has anybody already experienced a similar problem when doing drag&drop from a
> treeview?


I've been playing around with your patch, and I've seen the same
problem. Seems like when dragging a track item, the QModelIndex is the
album, and when dragging the album there is no QModelIndex at all.
This seems totally counter intuitive.

Creating the AlbumsModel is certainly the way to go about implement
dragging of files from the applet, we just need to iron out the kinks.


> I'm posting this because i hope that someone knows a solution for this or that
> it could be useful for someone who wants to work on the dragging stuff (to
> avoid duplicate effort etc.).

Yep, and as I said earlier I have commit this to subversion. I've made
a few small changes to the patch already so make sure you svn up :).

> P.s.: This patch is not really good from a usability point of view, for
> example if it worked and you selected an album and some tracks of it the
> complete album + the selected tracks would be added to the playlist,
> resulting in duplicate entries.
> I'm not sure if my problem has an easy fix so i didn't want to waste my time
> on writing code that possibly would be useless because a completely different
> approach could be needed...

I don't think there are any major usability concerns here - d&d
support is generally considered a usability improvement. As for the
functionality, it shouldn't be too difficult to do some checking to
make sure that we aren't dropping duplicates (the collection browser
does this).

Considering that it works correctly from the collection browser, the
problems you're having aren't insurmountable and they have been
tackled before it seems. I'd recommend taking a look at the collection
view model as a reference.

Cheers,
Seb

-- 
Seb Ruiz

http://www.sebruiz.net/
http://amarok.kde.org/


More information about the Amarok-devel mailing list