[vlc-commits] commit: adjustments to playlist API changes (Jakob Leben )

git at videolan.org git at videolan.org
Sat Mar 13 17:17:49 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Fri Mar 12 09:27:31 2010 +0100| [873e5edb26e043859d184d10a818ba984706f850] | committer: Jakob Leben 

adjustments to playlist API changes

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

 modules/gui/macosx/playlist.m                      |    2 +-
 .../gui/qt4/components/playlist/playlist_model.cpp |   41 +++-----------------
 .../gui/qt4/components/playlist/playlist_model.hpp |    3 +-
 modules/gui/qt4/components/playlist/selector.cpp   |    6 +-
 modules/services_discovery/upnp_cc.cpp             |    4 +-
 src/playlist/engine.c                              |    6 +-
 src/playlist/services_discovery.c                  |    4 +-
 7 files changed, 18 insertions(+), 48 deletions(-)

diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index ba92964..53ab716 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -1522,7 +1522,7 @@
 
     PL_LOCK;
     playlist_NodeCreate( p_playlist, _("Empty Folder"),
-                                      p_playlist->p_local_category, 0, NULL );
+                                      p_playlist->p_local_category, PLAYLIST_END, 0, NULL );
     PL_UNLOCK;
 
     [self playlistUpdated];
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index c3c960e..0c4f57f 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -197,14 +197,14 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
     if( plMimeData )
     {
         if( copy )
-            dropAppendCopy( plMimeData, getItem( parent ) );
+            dropAppendCopy( plMimeData, getItem( parent ), row );
         else
             dropMove( plMimeData, getItem( parent ), row );
     }
     return true;
 }
 
-void PLModel::dropAppendCopy( const PlMimeData *plMimeData, PLItem *target )
+void PLModel::dropAppendCopy( const PlMimeData *plMimeData, PLItem *target, int pos )
 {
     PL_LOCK;
 
@@ -212,49 +212,20 @@ void PLModel::dropAppendCopy( const PlMimeData *plMimeData, PLItem *target )
             playlist_ItemGetByInput( p_playlist, target->p_input );
     if( !p_parent ) return;
 
-    bool b_flat = p_parent == p_playlist->p_playing &&
-                  !var_InheritBool( p_intf, "playlist-tree" );
+    if( pos == -1 ) pos = PLAYLIST_END;
 
     QList<input_item_t*> inputItems = plMimeData->inputItems();
+
     foreach( input_item_t* p_input, inputItems )
     {
         playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
         if( !p_item ) continue;
-
-        recursiveAppendCopy( p_playlist, p_item, p_parent, b_flat );
+        pos = playlist_NodeAddCopy( p_playlist, p_item, p_parent, pos );
     }
 
     PL_UNLOCK;
 }
 
-/* Must be entered WITH playlist lock! */
-void PLModel::recursiveAppendCopy( playlist_t *p_playlist, playlist_item_t *source,
-                                   playlist_item_t *target, bool b_flat )
-{
-    input_item_t *srcInput = source->p_input;
-
-    if( !(source->i_children != -1 && b_flat) )
-    {
-        vlc_mutex_lock( &srcInput->lock );
-        input_item_t *newInput =
-            input_item_NewWithType( VLC_OBJECT(p_playlist),
-                                    srcInput->psz_uri, srcInput->psz_name,
-                                    srcInput->i_options, srcInput->ppsz_options,
-                                    srcInput->optflagc, srcInput->i_duration,
-                                    srcInput->i_type );
-        vlc_mutex_unlock( &srcInput->lock );
-
-        if( source->i_children != -1 )
-            target = playlist_NodeCreate( p_playlist, newInput->psz_name, target, 0, newInput );
-        else
-            playlist_NodeAddInput( p_playlist, newInput, target,
-                                   PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                   PLAYLIST_END, pl_Locked );
-    }
-    for( int i = 0; i < source->i_children; i++ )
-        recursiveAppendCopy( p_playlist, source->pp_children[i], target, b_flat );
-}
-
 void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
 {
     QList<input_item_t*> inputItems = plMimeData->inputItems();
@@ -1109,7 +1080,7 @@ void PLModel::popupAddNode()
                                                     i_popup_parent );
     if( p_item )
     {
-        playlist_NodeCreate( p_playlist, qtu( name ), p_item, 0, NULL );
+        playlist_NodeCreate( p_playlist, qtu( name ), p_item, PLAYLIST_END, 0, NULL );
     }
     PL_UNLOCK;
 }
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 99f8299..364234a 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -142,8 +142,7 @@ private:
     void updateChildren( playlist_item_t *, PLItem * );
 
     /* Deep actions (affect core playlist) */
-    static void recursiveAppendCopy( playlist_t *, playlist_item_t *, playlist_item_t *, bool );
-    void dropAppendCopy( const PlMimeData * data, PLItem *target );
+    void dropAppendCopy( const PlMimeData * data, PLItem *target, int pos );
     void dropMove( const PlMimeData * data, PLItem *target, int new_pos );
 
     /* Popup */
diff --git a/modules/gui/qt4/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp
index e5db968..25e92aa 100644
--- a/modules/gui/qt4/components/playlist/selector.cpp
+++ b/modules/gui/qt4/components/playlist/selector.cpp
@@ -362,9 +362,9 @@ bool PLSelector::dropMimeData ( QTreeWidgetItem * parent, int index,
         playlist_item_t *p_item = playlist_ItemGetByInput( THEPL, p_input );
         if( !p_item ) continue;
 
-        PLModel::recursiveAppendCopy( THEPL, p_item,
-                                      to_pl ? THEPL->p_playing : THEPL->p_media_library,
-                                      to_pl && !var_InheritBool( p_intf, "playlist-tree" ) );
+        playlist_NodeAddCopy( THEPL, p_item,
+                              to_pl ? THEPL->p_playing : THEPL->p_media_library,
+                              PLAYLIST_END );
     }
 
     playlist_Unlock( THEPL );
diff --git a/modules/services_discovery/upnp_cc.cpp b/modules/services_discovery/upnp_cc.cpp
index 2c8b54a..08df6e2 100644
--- a/modules/services_discovery/upnp_cc.cpp
+++ b/modules/services_discovery/upnp_cc.cpp
@@ -170,7 +170,7 @@ playlist_item_t *UPnPHandler::AddDevice( Device *dev )
      */
     char *str = strdup( dev->getFriendlyName( ) );
 
-    p_item = playlist_NodeCreate( p_playlist, str, p_sd->p_cat, 0, NULL );
+    p_item = playlist_NodeCreate( p_playlist, str, p_sd->p_cat, PLAYLIST_END, 0, NULL );
     p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
     msg_Dbg( p_sd, "device %s added", str );
     free( str );
@@ -214,7 +214,7 @@ void UPnPHandler::AddContent( playlist_item_t *p_parent, ContentNode *node )
 
         char* p_name = strdup(title); /* See other comment on strdup */
         playlist_item_t* p_node = playlist_NodeCreate( p_playlist, p_name,
-                                                       p_parent, 0, NULL );
+                                                       p_parent, PLAYLIST_END, 0, NULL );
         free(p_name);
 
         unsigned nContentNodes = conNode->getNContentNodes();
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 0da2997..9367e17 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -121,7 +121,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     /* Create the root node */
     PL_LOCK;
     p_playlist->p_root = playlist_NodeCreate( p_playlist, NULL, NULL,
-                                    0, NULL );
+                                    PLAYLIST_END, 0, NULL );
     PL_UNLOCK;
     if( !p_playlist->p_root ) return NULL;
 
@@ -129,7 +129,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     PL_LOCK;
     p_playlist->p_playing = playlist_NodeCreate(
         p_playlist, _( "Playlist" ), p_playlist->p_root,
-        PLAYLIST_RO_FLAG, NULL );
+        PLAYLIST_END, PLAYLIST_RO_FLAG, NULL );
 
     PL_UNLOCK;
 
@@ -142,7 +142,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
         PL_LOCK;
         p_playlist->p_media_library = playlist_NodeCreate(
             p_playlist, _( "Media Library" ), p_playlist->p_root,
-            PLAYLIST_RO_FLAG, NULL );
+            PLAYLIST_END, PLAYLIST_RO_FLAG, NULL );
         PL_UNLOCK;
 
         if(!p_playlist->p_media_library ) return NULL;
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 2afb024..916f0b5 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -263,7 +263,7 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat
         if( !p_cat )
         {
             p_cat = playlist_NodeCreate( p_playlist, psz_cat,
-                                         p_parent, 0, NULL );
+                                         p_parent, PLAYLIST_END, 0, NULL );
             p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG;
         }
         p_parent = p_cat;
@@ -339,7 +339,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
 
     PL_LOCK;
     p_node = playlist_NodeCreate( p_playlist, psz_longname,
-                                  p_playlist->p_root, 0, NULL );
+                                  p_playlist->p_root, PLAYLIST_END, 0, NULL );
     PL_UNLOCK;
 
     vlc_event_manager_t *em = services_discovery_EventManager( p_sd );



More information about the vlc-commits mailing list