playlist_item_t * p_root,
/*playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
and THEPL->p_root_category for SelectPL */
- int _i_depth, /* -1 for StandPL, 1 for SelectPL */
QObject *parent ) /* Basic Qt parent */
: QAbstractItemModel( parent )
{
- i_depth = _i_depth;
- assert( i_depth == DEPTH_SEL || i_depth == DEPTH_PL );
p_intf = _p_intf;
p_playlist = _p_playlist;
i_cached_id = -1;
p_playlist->p_ml_category ?
p_playlist->p_ml_category->p_input : NULL;
- if( i_depth == DEPTH_SEL )
- {
- if( ( pl_input && item->p_input == pl_input ) ||
- ( ml_input && item->p_input == ml_input ) )
- flags |= Qt::ItemIsDropEnabled;
- }
- else if( ( pl_input && rootItem->p_input == pl_input ) ||
+ if( ( pl_input && rootItem->p_input == pl_input ) ||
( ml_input && rootItem->p_input == ml_input ) )
{
PL_LOCK;
PLItem *item = getItem( index );
if( role == Qt::DisplayRole )
{
- if( i_depth == DEPTH_SEL )
- {
- vlc_mutex_lock( &item->p_input->lock );
- QString returninfo = QString( qfu( item->p_input->psz_name ) );
- vlc_mutex_unlock( &item->p_input->lock );
- return QVariant(returninfo);
- }
-
int metadata = columnToMeta( index.column() );
if( metadata == COLUMN_END ) return QVariant();
if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
return QVariant();
- if( i_depth == DEPTH_SEL ) return QVariant( QString("") );
-
int meta_col = columnToMeta( section );
if( meta_col == COLUMN_END ) return QVariant();
int PLModel::columnCount( const QModelIndex &i) const
{
- return i_depth == DEPTH_SEL ? 1 : columnFromMeta( COLUMN_END );
+ return columnFromMeta( COLUMN_END );
}
int PLModel::rowCount( const QModelIndex &parent ) const
if( !p_item || p_item->i_id <= 0 ) return;
PLItem *item = findByInput( rootItem, p_item->i_id );
if( item )
- updateTreeItem( item, true, true);
+ updateTreeItem( item );
}
void PLModel::processItemRemoval( int i_id )
PL_LOCK;
p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
- if( i_depth == DEPTH_SEL && p_item->p_parent &&
- p_item->p_parent->i_id != rootItem->i_id )
- goto end;
newItem = new PLItem( p_item, nodeItem );
PL_UNLOCK;
beginInsertRows( index( nodeItem, 0 ), nodeItem->childCount(), nodeItem->childCount() );
nodeItem->appendChild( newItem );
endInsertRows();
- updateTreeItem( newItem, true );
+ updateTreeItem( newItem );
return;
end:
PL_UNLOCK;
currentItem = newItem;
emit currentChanged( index( currentItem, 0 ) );
}
- if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
+ if( p_node->pp_children[i]->i_children != -1 )
updateChildren( p_node->pp_children[i], newItem );
}
}
/* Function doesn't need playlist-lock, as we don't touch playlist_item_t stuff here*/
-void PLModel::updateTreeItem( PLItem *item, bool signal, bool force )
+void PLModel::updateTreeItem( PLItem *item )
{
- if ( !item || !item->p_input )
- return;
- if( !force && i_depth == DEPTH_SEL && item->parentItem &&
- item->parentItem->p_input != rootItem->p_input )
- return;
- if( signal )
- emit dataChanged( index( item, 0 ) , index( item, columnCount( QModelIndex() ) ) );
+ if( !item ) return;
+ emit dataChanged( index( item, 0 ) , index( item, columnCount( QModelIndex() ) ) );
}
/************************* Actions ******************************/
public:
PLModel( playlist_t *, intf_thread_t *,
- playlist_item_t *, int, QObject *parent = 0 );
+ playlist_item_t *, QObject *parent = 0 );
~PLModel();
/*** QModel subclassing ***/
/* Actions */
void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
void doDeleteItem( PLItem *item, QModelIndexList *fullList );
- void updateTreeItem( PLItem *, bool, bool force = false );
+ void updateTreeItem( PLItem * );
void takeItem( PLItem * ); //will not delete item
void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
void dropAppendCopy( QByteArray& data, PLItem *target );