extragear/multimedia/amarok/src
Bart Cerneels
bart.cerneels at kde.org
Sun May 10 16:48:39 CEST 2009
SVN commit 966174 by shanachie:
Implement drag'n'drop for the grouped playlists.
It's not working because I don't know QDrag'n'Drop yet this is a release blocker.
Please look at it.
CCMAIL:amarok-devel at kde.org
M +15 -17 AmarokMimeData.cpp
M +4 -4 AmarokMimeData.h
M +63 -1 browsers/playlistbrowser/PlaylistsInGroupsProxy.cpp
M +5 -0 browsers/playlistbrowser/PlaylistsInGroupsProxy.h
--- trunk/extragear/multimedia/amarok/src/AmarokMimeData.cpp #966173:966174
@@ -27,7 +27,7 @@
const QString AmarokMimeData::TRACK_MIME = "application/x-amarok-tracks";
const QString AmarokMimeData::PLAYLIST_MIME = "application/x-amarok-playlists";
-// const QString AmarokMimeData::PLAYLISTBROWSERGROUP_MIME = "application/x-amarok-playlistbrowsergroup";
+const QString AmarokMimeData::PLAYLISTBROWSERGROUP_MIME = "application/x-amarok-playlistbrowsergroup";
const QString AmarokMimeData::PODCASTCHANNEL_MIME = "application/x-amarok-podcastchannel";
const QString AmarokMimeData::PODCASTEPISODE_MIME = "application/x-amarok-podcastepisode";
const QString AmarokMimeData::AMAROKURL_MIME = "application/x-amarok-amarokurl";
@@ -48,7 +48,7 @@
Meta::TrackList tracks;
Meta::PlaylistList playlists;
-// SqlPlaylistGroupList playlistGroups;
+ QStringList playlistGroups;
Meta::PodcastChannelList m_podcastChannels;
Meta::PodcastEpisodeList m_podcastEpisodes;
QList<QueryMaker*> queryMakers;
@@ -80,11 +80,11 @@
DEBUG_BLOCK
QStringList formats( QMimeData::formats() );
- if( !d->tracks.isEmpty() || !d->queryMakers.isEmpty() /*|| !d->playlistGroups.isEmpty()*/ || !d->bookmarks.isEmpty() || !d->bookmarkGroups.isEmpty() )
+ if( !d->tracks.isEmpty() || !d->queryMakers.isEmpty() || !d->playlistGroups.isEmpty() || !d->bookmarks.isEmpty() || !d->bookmarkGroups.isEmpty() )
{
formats.append( TRACK_MIME );
formats.append( PLAYLIST_MIME );
-// formats.append( PLAYLISTBROWSERGROUP_MIME );
+ formats.append( PLAYLISTBROWSERGROUP_MIME );
formats.append( PODCASTCHANNEL_MIME );
formats.append( PODCASTEPISODE_MIME );
formats.append( BOOKMARKGROUP_MIME );
@@ -107,8 +107,8 @@
return !d->tracks.isEmpty() || !d->queryMakers.isEmpty();
else if( mimeType == PLAYLIST_MIME )
return !d->playlists.isEmpty() || !d->queryMakers.isEmpty();
-// else if( mimeType == PLAYLISTBROWSERGROUP_MIME )
-// return !d->playlistGroups.isEmpty();
+ else if( mimeType == PLAYLISTBROWSERGROUP_MIME )
+ return !d->playlistGroups.isEmpty();
else if( mimeType == PODCASTCHANNEL_MIME )
return !d->m_podcastChannels.isEmpty();
else if( mimeType == PODCASTEPISODE_MIME )
@@ -181,11 +181,6 @@
QCoreApplication::instance()->processEvents( QEventLoop::AllEvents );
}
Meta::PlaylistList result = d->playlists;
-// foreach( QueryMaker *qm, d->queryMakers )
-// {
-// if( d->trackMap.contains( qm ) )
-// result << d->trackMap.value( qm );
-// }
return result;
}
@@ -200,21 +195,24 @@
{
d->playlists << playlists;
}
-/*
-SqlPlaylistGroupList AmarokMimeData::sqlPlaylistsGroups() const
+
+QStringList
+AmarokMimeData::playlistGroups() const
{
return d->playlistGroups;
}
-void AmarokMimeData::setPlaylistGroups( const SqlPlaylistGroupList & groups )
+void
+AmarokMimeData::setPlaylistGroups( const QStringList &groups )
{
d->playlistGroups = groups;
}
-void AmarokMimeData::addPlaylistGroups(const SqlPlaylistGroupList & groups)
+void
+AmarokMimeData::addPlaylistGroup( const QString &group )
{
- d->playlistGroups << groups;
-}*/
+ d->playlistGroups << group;
+}
Meta::PodcastChannelList
AmarokMimeData::podcastChannels() const
--- trunk/extragear/multimedia/amarok/src/AmarokMimeData.h #966173:966174
@@ -38,7 +38,7 @@
static const QString TRACK_MIME;
static const QString PLAYLIST_MIME;
-// static const QString PLAYLISTBROWSERGROUP_MIME;
+ static const QString PLAYLISTBROWSERGROUP_MIME;
static const QString PODCASTCHANNEL_MIME;
static const QString PODCASTEPISODE_MIME;
@@ -60,9 +60,9 @@
void setPlaylists( const Meta::PlaylistList &playlists );
void addPlaylists( const Meta::PlaylistList &playlists );
-// SqlPlaylistGroupList sqlPlaylistsGroups() const;
-// void setPlaylistGroups( const SqlPlaylistGroupList &groups );
-// void addPlaylistGroups( const SqlPlaylistGroupList &groups );
+ QStringList playlistGroups() const;
+ void setPlaylistGroups( const QStringList &groups );
+ void addPlaylistGroup( const QString &group );
Meta::PodcastChannelList podcastChannels() const;
void setPodcastChannels( const Meta::PodcastChannelList &channels );
--- trunk/extragear/multimedia/amarok/src/browsers/playlistbrowser/PlaylistsInGroupsProxy.cpp #966173:966174
@@ -18,6 +18,7 @@
#include "PlaylistsInGroupsProxy.h"
+#include "AmarokMimeData.h"
#include "context/popupdropper/libpud/PopupDropperAction.h"
#include "Debug.h"
#include "meta/Playlist.h"
@@ -216,6 +217,66 @@
return m_model->removeRow( originalIdx.row(), originalIdx.parent() );
}
+QStringList
+PlaylistsInGroupsProxy::mimeTypes() const
+{
+ DEBUG_BLOCK
+ return QStringList();
+}
+
+QMimeData *
+PlaylistsInGroupsProxy::mimeData( const QModelIndexList &indexes ) const
+{
+ DEBUG_BLOCK
+ AmarokMimeData* mime = new AmarokMimeData();
+ QModelIndexList sourceIndexes;
+ foreach( const QModelIndex &idx, indexes )
+ {
+ debug() << idx;
+ if( isGroup( idx ) )
+ {
+ debug() << "is a group, add mimeData of all children";
+ }
+ else
+ {
+ debug() << "is original item, add mimeData from source model";
+ sourceIndexes << mapToSource( idx );
+ }
+ }
+
+ if( !sourceIndexes.isEmpty() )
+ return m_model->mimeData( sourceIndexes );
+
+ return mime;
+}
+
+bool
+PlaylistsInGroupsProxy::dropMimeData( const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent )
+{
+ DEBUG_BLOCK
+ if( action == Qt::IgnoreAction )
+ return true;
+
+ QModelIndex idx = index( row, column, parent );
+
+ if( isGroup( idx ) )
+ {
+ if( data->hasFormat( AmarokMimeData::PLAYLIST_MIME ) )
+ {
+ debug() << "playlist dropped on group";
+ }
+ else if( data->hasFormat( AmarokMimeData::PLAYLISTBROWSERGROUP_MIME ) )
+ {
+ debug() << "playlistgroup dropped on group";
+ //TODO: multilevel group support
+ debug() << "ignore drop until we have multilevel group support";
+ }
+ }
+
+ return false;
+}
+
int
PlaylistsInGroupsProxy::columnCount( const QModelIndex& index ) const
{
@@ -297,7 +358,8 @@
PlaylistsInGroupsProxy::flags( const QModelIndex &index ) const
{
if( isGroup( index ) )
- return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
+ return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable |
+ Qt::ItemIsDropEnabled );
QModelIndex originalIdx = mapToSource( index );
return m_model->flags( originalIdx );
--- trunk/extragear/multimedia/amarok/src/browsers/playlistbrowser/PlaylistsInGroupsProxy.h #966173:966174
@@ -47,6 +47,11 @@
QVariant data( const QModelIndex &index, int role ) const;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() );
+ virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction; }
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
+ virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent );
QList<PopupDropperAction *> actionsFor( const QModelIndexList &indexes );
More information about the Amarok-devel
mailing list