[vlc-devel] commit: QT4 playlist: even better DragNDrop policy (Jakob Leben )
git version control
git at videolan.org
Tue Aug 11 17:42:05 CEST 2009
vlc | branch: master | Jakob Leben <jakob.leben at gmail.com> | Sun Aug 9 20:31:40 2009 +0200| [d644a05885b4a976344200b6f97486bd8b77830a] | committer: Rémi Denis-Courmont
QT4 playlist: even better DragNDrop policy
Drop enabled only inside Playlist and Media player, not Podcast and
other Internet sources...
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d644a05885b4a976344200b6f97486bd8b77830a
---
.../gui/qt4/components/playlist/playlist_model.cpp | 34 ++++++++++++++------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 2288e72..1d389ea 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -115,18 +115,32 @@ Qt::DropActions PLModel::supportedDropActions() const
Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
{
- Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
- if( index.isValid() )
+ Qt::ItemFlags flags = QAbstractItemModel::flags( index );
+
+ PLItem *item = index.isValid() ?
+ static_cast<PLItem*>( index.internalPointer() ) :
+ rootItem;
+
+ int pl_input_id = p_playlist->p_local_category->p_input->i_id;
+ int ml_input_id = p_playlist->p_ml_category->p_input->i_id;
+
+ if( rootItem->i_id == p_playlist->p_root_onelevel->i_id
+ || rootItem->i_id == p_playlist->p_root_category->i_id )
+ {
+ if( item->i_input_id == pl_input_id
+ || item->i_input_id == ml_input_id )
+ flags |= Qt::ItemIsDropEnabled;
+ }
+ else
{
- PLItem *item = static_cast<PLItem*>( index.internalPointer() );
- if ( item->b_is_node )
- defaultFlags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
- else defaultFlags |= Qt::ItemIsDragEnabled;
- }
- else if ( rootItem->i_id != p_playlist->p_root_onelevel->i_id
- && rootItem->i_id != p_playlist->p_root_category->i_id )
- defaultFlags |= Qt::ItemIsDropEnabled;
- return defaultFlags;
+ if ( item->b_is_node &&
+ ( rootItem->i_input_id == pl_input_id ||
+ rootItem->i_input_id == ml_input_id ) )
+ flags |= Qt::ItemIsDropEnabled;
+ flags |= Qt::ItemIsDragEnabled;
+ }
+
+ return flags;
}
/* A list of model indexes are a playlist */
More information about the vlc-devel
mailing list