- Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
- if( index.isValid() )
- return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
- else
- return Qt::ItemIsDropEnabled | defaultFlags;
+ Qt::ItemFlags flags = QAbstractItemModel::flags( index );
+
+ PLItem *item = index.isValid() ?
+ static_cast<PLItem*>( index.internalPointer() ) :
+ rootItem;
+
+ input_item_t *pl_input = p_playlist->p_local_category->p_input;
+ input_item_t *ml_input = p_playlist->p_ml_category->p_input;
+
+ if( rootItem->i_id == p_playlist->p_root_onelevel->i_id
+ || rootItem->i_id == p_playlist->p_root_category->i_id )
+ {
+ if( item->p_input == pl_input
+ || item->p_input == ml_input)
+ flags |= Qt::ItemIsDropEnabled;
+ }
+ else if( rootItem->p_input == pl_input ||
+ rootItem->p_input == ml_input )
+ {
+ PL_LOCK;
+ playlist_item_t *plItem =
+ playlist_ItemGetById( p_playlist, item->i_id );
+
+ if ( plItem && ( plItem->i_children > -1 ) )
+ flags |= Qt::ItemIsDropEnabled;
+
+ PL_UNLOCK;
+
+ }
+ flags |= Qt::ItemIsDragEnabled;
+
+ return flags;