[vlc-devel] commit: Fix #1768 ( Rémi Duraffort )

git version control git at videolan.org
Fri Aug 22 23:52:12 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Aug 22 23:50:13 2008 +0200| [683c41a59990d1ec0bfe703a01d5bddcebbc3081] | committer: Rémi Duraffort 

Fix #1768

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=683c41a59990d1ec0bfe703a01d5bddcebbc3081
---

 .../gui/qt4/components/playlist/playlist_model.cpp |   22 +++----------------
 src/playlist/item.c                                |   11 ++++++++-
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 2a55d95..f09a4a7 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -191,7 +191,8 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
                 }
                 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
@@ -201,25 +202,10 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
                 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;
 }
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 70924e4..eba3006 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -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 );
 
+    /* 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;
@@ -742,7 +749,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
                                                 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;
@@ -756,7 +763,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
                                                 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;
     }




More information about the vlc-devel mailing list