]> git.sesse.net Git - vlc/commitdiff
playlist: do not move both tree and non-tree items + restrict move action
authorJakob Leben <jakob.leben@gmail.com>
Sun, 9 Aug 2009 22:04:59 +0000 (00:04 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 13 Aug 2009 15:04:39 +0000 (18:04 +0300)
Items are stored twice, once in a tree structure and once in a one-level list.
This patch removes attempt of the playlist_TreeMove() function to move both tree and
one-level instances of an item.

Firstly the reason is that function was not effective in this attempt.
And secondly, the attempt itself doesn't make sense in some cases: you can always
map moves within the tree to moves within one-level, but you can't always do it
the other way around, it is in most cases ambiguous.

Moreover, this patch restricts moves in the tree to within the present parent of the
item being moved. Again, in most cases, moving an item out of its parent or into another
parent is meaningless.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
src/playlist/item.c

index 23cff64735f6393b2826be72cb9227183a68e6a0..4051a82f7e87ec2c2ad72628622bc540f2252fe3 100644 (file)
@@ -718,47 +718,8 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
     int i_ret;
     PL_ASSERT_LOCKED;
 
-    /* Drop on a top level node. Move in the two trees */
-    if( p_node->p_parent == p_playlist->p_root_category ||
-        p_node->p_parent == p_playlist->p_root_onelevel )
-    {
-        /* Fixme: avoid useless lookups but we need some clean helpers */
-        {
-            /* Fixme: if we try to move a node on a top-level node, it will
-             * fail because the node doesn't exist in onelevel and we will
-             * do some shit in onelevel. We should recursively move all items
-             * within the node */
-            playlist_item_t *p_node_onelevel;
-            playlist_item_t *p_item_onelevel;
-            p_node_onelevel = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_node->p_input,
-                                                p_playlist->p_root_onelevel,
-                                                false );
-            p_item_onelevel = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_item->p_input,
-                                                p_playlist->p_root_onelevel,
-                                                false );
-            if( p_node_onelevel && p_item_onelevel )
-                TreeMove( p_playlist, p_item_onelevel, p_node_onelevel, i_newpos );
-        }
-        {
-            playlist_item_t *p_node_category;
-            playlist_item_t *p_item_category;
-            p_node_category = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_node->p_input,
-                                                p_playlist->p_root_category,
-                                                false );
-            p_item_category = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_item->p_input,
-                                                p_playlist->p_root_category,
-                                                false );
-            if( p_node_category && p_item_category )
-                TreeMove( p_playlist, p_item_category, p_node_category, 0 );
-        }
-        i_ret = VLC_SUCCESS;
-    }
-    else
-        i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
+    if( p_node != p_item->p_parent ) return VLC_SUCCESS;
+    i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
     pl_priv(p_playlist)->b_reset_currently_playing = true;
     vlc_cond_signal( &pl_priv(p_playlist)->signal );
     return i_ret;