]> git.sesse.net Git - vlc/commitdiff
playlist, Qt: playlist browsing support
authorJakob Leben <jleben@videolan.org>
Sat, 30 Jan 2010 09:07:34 +0000 (10:07 +0100)
committerJakob Leben <jleben@videolan.org>
Sat, 30 Jan 2010 09:18:26 +0000 (10:18 +0100)
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.

include/vlc_playlist.h
modules/gui/qt4/components/playlist/standardpanel.cpp
src/playlist/item.c

index bc82a0520991bd19d252e25c7f8767c9e2830f89..926c48eef23e889b4c4b921e74c79bc07a931940 100644 (file)
@@ -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
index c258f84f65ffd9f05d8b641c3b0edaf16159b380..e4c2f19f579a56d3217635882492599fbf892941 100644 (file)
@@ -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 );
 }
index c935d8c94f189f2200d9b702c113db7d3d8d6683..9faed0d5a6f3c50a713c64de67ae3c7fb0dd9f62 100644 (file)
@@ -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 );
         }