Commit d644a058 authored by Jakob Leben's avatar Jakob Leben Committed by 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: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 0f9541fa
...@@ -115,18 +115,32 @@ Qt::DropActions PLModel::supportedDropActions() const ...@@ -115,18 +115,32 @@ Qt::DropActions PLModel::supportedDropActions() const
Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
{ {
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index ); Qt::ItemFlags flags = QAbstractItemModel::flags( index );
if( index.isValid() )
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 &&
if ( item->b_is_node ) ( rootItem->i_input_id == pl_input_id ||
defaultFlags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; rootItem->i_input_id == ml_input_id ) )
else defaultFlags |= Qt::ItemIsDragEnabled; flags |= Qt::ItemIsDropEnabled;
} flags |= 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 flags;
return defaultFlags;
} }
/* A list of model indexes are a playlist */ /* A list of model indexes are a playlist */
......
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