children.insert( i_pos, item );
}
-void PLItem::remove( PLItem *removed, int i_depth )
-{
- if( i_depth == 1 /* DEPTH_SEL */ || parentItem )
- {
- int i_index = parentItem->children.indexOf( removed );
- parentItem->children.removeAt( i_index );
- }
-}
-
/* This function is used to get one's parent's row number in the model */
int PLItem::row() const
{
children.insert( children.count(), item );
};
- void remove( PLItem *removed, int i_depth );
-
PLItem *child( int row ) { return children.value( row ); };
int childCount() const { return children.count(); };
void PLModel::removeItem( int i_id )
{
PLItem *item = FindById( rootItem, i_id );
- if( currentItem && item && currentItem->p_input == item->p_input ) currentItem = NULL;
- if( item ) item->remove( item, i_depth );
+ RemoveItem( item );
}
/* callbacks and slots */
addCallbacks();
}
+void PLModel::RemoveItem( PLItem *item )
+{
+ if( !item ) return;
+ if( currentItem && currentItem->p_input == item->p_input )
+ {
+ currentItem = NULL;
+ emit currentChanged( QModelIndex() );
+ }
+ PLItem *parent = item->parentItem;
+ assert( parent );
+ int i_index = parent->children.indexOf( item );
+ parent->children.removeAt( i_index );
+ delete item;
+}
void PLModel::RemoveChildren( PLItem *root )
{
if( root->children.size() )
/* And finally, remove it from the tree */
int itemIndex = item->parentItem->children.indexOf( item );
beginRemoveRows( index( item->parentItem, 0), itemIndex, itemIndex );
- item->remove( item, i_depth );
+ RemoveItem( item );
endRemoveRows();
}
void doDeleteItem( PLItem *item, QModelIndexList *fullList );
void UpdateTreeItem( PLItem *, bool, bool force = false );
/* The following actions will not signal the view! */
+ void RemoveItem ( PLItem * );
void RemoveChildren( PLItem * );
void UpdateChildren( PLItem * );
void UpdateChildren( playlist_item_t *, PLItem * );