[vlc-devel] commit: playlist, Qt: playlist browsing support (Jakob Leben )

git version control git at videolan.org
Sat Jan 30 10:24:01 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sat Jan 30 10:07:34 2010 +0100| [736cc6b8930b8c97f2cda4d1dc55c7de6f9701a0] | committer: Jakob Leben 

playlist, Qt: playlist browsing support

A new playlist item flag stops playlist after the item gets subitems.
The flag is set only upon user request to play an item from Qt views and only
if he does so in playlist "tree mode" not "one level".
Behavior on items played when playlist advances is unaffected.
This allows for comfortable "browsing" of playlist in tree mode, in particular
when using the Qt interface's icon view.

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

 include/vlc_playlist.h                             |    1 +
 .../gui/qt4/components/playlist/standardpanel.cpp  |   13 ++++++++++---
 src/playlist/item.c                                |   12 +++++++++++-
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index bc82a05..926c48e 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -161,6 +161,7 @@ struct playlist_item_t
 #define PLAYLIST_RO_FLAG        0x0008    /**< Write-enabled ? */
 #define PLAYLIST_REMOVE_FLAG    0x0010    /**< Remove this item at the end */
 #define PLAYLIST_EXPANDED_FLAG  0x0020    /**< Expanded node */
+#define PLAYLIST_SUBITEM_STOP_FLAG 0x0040 /**< Must playlist stop if the item gets subitems ?*/
 
 /** Playlist status */
 typedef enum
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index c258f84..e4c2f19 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -410,7 +410,6 @@ void StandardPLPanel::wheelEvent( QWheelEvent *e )
 
 void StandardPLPanel::activate( const QModelIndex &index )
 {
-    last_activated_id = model->getItem( index )->inputItem()->i_id;
     if( model->hasChildren( index ) )
     {
         if( currentView == iconView ) {
@@ -421,6 +420,11 @@ void StandardPLPanel::activate( const QModelIndex &index )
     }
     else
     {
+        playlist_Lock( THEPL );
+        playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
+        p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
+        last_activated_id = p_item->p_input->i_id;//model->getItem( index )->inputItem()->i_id;
+        playlist_Unlock( THEPL );
         model->activateItem( index );
     }
 }
@@ -435,12 +439,15 @@ void StandardPLPanel::browseInto( input_item_t *p_input )
     playlist_item_t *p_item = playlist_ItemGetByInput( THEPL, p_input );
     assert( p_item != NULL );
 
+    QModelIndex index = model->index( p_item->i_id, 0 );
     if( currentView == iconView ) {
-        QModelIndex index = model->index( p_item->i_id, 0 );
         iconView->setRootIndex( index );
         locationBar->setIndex( index );
     }
-    last_activated_id = p_item->pp_children[0]->p_input->i_id;
+    else
+        treeView->setExpanded( index, true );
+
+    last_activated_id = -1;
 
     playlist_Unlock( THEPL );
 }
diff --git a/src/playlist/item.c b/src/playlist/item.c
index c935d8c..9faed0d 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -82,8 +82,11 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
             return;
         }
 
+        bool b_stop = p_item_in_category->i_flags & PLAYLIST_SUBITEM_STOP_FLAG;
+
         b_play = b_play &&
-            p_item_in_category == get_current_status_item( p_playlist );
+            p_item_in_category == get_current_status_item( p_playlist ) &&
+            p_item_in_category->i_children == -1;
 
         /* If this item is already a node don't transform it */
         if( p_item_in_category->i_children == -1 )
@@ -100,6 +103,13 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
 
         if( i_ret == VLC_SUCCESS && b_play )
         {
+            if( b_stop )
+            {
+                p_item_in_category->i_flags &= ~PLAYLIST_SUBITEM_STOP_FLAG;
+                PL_UNLOCK;
+                playlist_Stop( p_playlist );
+                return;
+            }
             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
                           pl_Locked, p_item_in_category, NULL );
         }




More information about the vlc-devel mailing list