}
for( i = 0 ; i< p_parent->i_children ; i++ )
if( p_parent->pp_children[i] == p_target ) break;
- playlist_TreeMove( p_playlist, p_src, p_parent, i );
+ // Move the item to the element after i
+ playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
newParentItem = parentItem;
}
else
i = 0;
newParentItem = targetItem;
}
- /* Remove from source */
- PLItem *srcItem = FindById( rootItem, p_src->i_id );
- // We dropped on the source selector. Ask the dialog to forward
- // to the main view
- if( !srcItem )
- {
- emit shouldRemove( p_src->i_id );
- }
- else
- srcItem->remove( srcItem );
-
- /* Display at new destination */
- PLItem *newItem = new PLItem( p_src, newParentItem, this );
- newParentItem->insertChild( newItem, i, true );
- UpdateTreeItem( p_src, newItem, true );
- if( p_src->i_children != -1 )
- UpdateNodeChildren( newItem );
PL_UNLOCK;
}
+ /*TODO: That's not a good idea to rebuild the playlist */
+ rebuild();
}
return true;
}
}
REMOVE_ELEM( p_detach->pp_children, p_detach->i_children, j );
+ /* If j < i_newpos, we are moving the element from the top to the
+ * down of the playlist. So when removing the element we change have
+ * to change the position as we loose one element
+ */
+ if( j < i_newpos )
+ i_newpos--;
+
/* Attach to new parent */
INSERT_ELEM( p_node->pp_children, p_node->i_children, i_newpos, p_item );
p_item->p_parent = p_node;
p_playlist->p_root_onelevel,
false );
if( p_node_onelevel && p_item_onelevel )
- TreeMove( p_playlist, p_item_onelevel, p_node_onelevel, 0 );
+ TreeMove( p_playlist, p_item_onelevel, p_node_onelevel, i_newpos );
}
{
playlist_item_t *p_node_category;
p_playlist->p_root_category,
false );
if( p_node_category && p_item_category )
- TreeMove( p_playlist, p_item_category, p_node_category, 0 );
+ TreeMove( p_playlist, p_item_category, p_node_category, i_newpos );
}
i_ret = VLC_SUCCESS;
}