Commit 683c41a5 authored by Rémi Duraffort's avatar Rémi Duraffort

Fix #1768

parent f01abf1d
...@@ -191,7 +191,8 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -191,7 +191,8 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
} }
for( i = 0 ; i< p_parent->i_children ; i++ ) for( i = 0 ; i< p_parent->i_children ; i++ )
if( p_parent->pp_children[i] == p_target ) break; 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; newParentItem = parentItem;
} }
else else
...@@ -201,25 +202,10 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -201,25 +202,10 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
i = 0; i = 0;
newParentItem = targetItem; 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; PL_UNLOCK;
} }
/*TODO: That's not a good idea to rebuild the playlist */
rebuild();
} }
return true; return true;
} }
......
...@@ -697,6 +697,13 @@ static int TreeMove( playlist_t *p_playlist, playlist_item_t *p_item, ...@@ -697,6 +697,13 @@ static int TreeMove( playlist_t *p_playlist, playlist_item_t *p_item,
} }
REMOVE_ELEM( p_detach->pp_children, p_detach->i_children, j ); 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 */ /* Attach to new parent */
INSERT_ELEM( p_node->pp_children, p_node->i_children, i_newpos, p_item ); INSERT_ELEM( p_node->pp_children, p_node->i_children, i_newpos, p_item );
p_item->p_parent = p_node; p_item->p_parent = p_node;
...@@ -742,7 +749,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item, ...@@ -742,7 +749,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
p_playlist->p_root_onelevel, p_playlist->p_root_onelevel,
false ); false );
if( p_node_onelevel && p_item_onelevel ) 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; playlist_item_t *p_node_category;
...@@ -756,7 +763,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item, ...@@ -756,7 +763,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
p_playlist->p_root_category, p_playlist->p_root_category,
false ); false );
if( p_node_category && p_item_category ) 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; i_ret = VLC_SUCCESS;
} }
......
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