[vlc-devel] [PATCH 2/6] I've modified the dummy shuffle method so that it clears the playlist and then adds one file. This was just to test whether I can work with the items in the playlist and access their respective fields. Next commit will perform the acctual shuffling.

Martin Zeman dileptor at gmail.com
Sat Mar 9 00:17:20 CET 2013


---
 .../gui/qt4/components/playlist/standardpanel.cpp  |   89 ++++++--------------
 .../gui/qt4/components/playlist/standardpanel.hpp  |    2 +-
 2 files changed, 26 insertions(+), 65 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 54e62b1..27af573 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -60,9 +60,11 @@
 #include <QDesktopServices>
 #include <QUrl>
 #include <QFont>
+#include <QModelIndex>
 
 #include <assert.h>
 
+
 StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   intf_thread_t *_p_intf,
                                   playlist_item_t *p_root,
@@ -710,70 +712,29 @@ void StandardPLPanel::cycleViews()
         assert( 0 );
 }
 
-void StandardPLPanel::shufflePlaylist(const QModelIndex &index )
-{
- /*My code to shuffle and fill the Playrlist*/
-    /*playlist_Lock( THEPL );
-
-    playlist_item_t *p_temp;
-    playlist_item_array_t pp_items = THEPL->all_items;
-    p_temp = pp_items[0];
-	pp_items[0] = pp_items[1];
-	pp_items[1] = p_temp;
-	playlist_Unlock( THEPL );*/
-
-	FOREACH_ARRAY( playlist_item_t *p_del, THEPL->all_items )
-	        free( p_del->pp_children );
-	        vlc_gc_decref( p_del->p_input );
-	        free( p_del );
-	    FOREACH_END();
-
-	    vlc_object_release( THEPL );
-
-	//if( currentView->model() == model )
-	   // {
-	        /* If we are not a leaf node */
-	      //  if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
-	        //{
-	         //   if( currentView != treeView )
-	         //       browseInto( index );
-	        //}
-	        //else
-	        //{
-	            /*playlist_Lock( THEPL );
-	            playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
-	            playlist_item_t *p_item_two = playlist_ItemGetById( THEPL, model->itemId( 2 ) );
-	            p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
-	            lastActivatedId = p_item->i_id;
-	            playlist_Unlock( THEPL );
-	            model->activateItem( index );*/
-	        //}
-	   // }
-
-	//FOR INSPECTION
-			/*static inline
-		void playlist_ItemArraySort( unsigned i_items, playlist_item_t **pp_items,
-									 sortfn_t p_sortfn )
-		{
-			if( p_sortfn )
-			{
-				qsort( pp_items, i_items, sizeof( pp_items[0] ), p_sortfn );
-			}
-			else
-			{
-				unsigned i_position;
-				unsigned i_new;
-				playlist_item_t *p_temp;
-
-				for( i_position = i_items - 1; i_position > 0; i_position-- )
-				{
-					i_new = ((unsigned)vlc_mrand48()) % (i_position+1);
-					p_temp = pp_items[i_position];
-					pp_items[i_position] = pp_items[i_new];
-					pp_items[i_new] = p_temp;
-				}
-			}
-		} */
+void StandardPLPanel::shufflePlaylist()
+{
+ /*My code to shuffle and fill the Playlist*/
+	//playlist_Lock( THEPL );
+	PLModel *p_plModel = PLModel::getPLModel(StandardPLPanel::p_intf);
+	int i_rowCount = p_plModel->rowCount();
+	if( i_rowCount > 1 )
+	{
+
+	    QModelIndexList l;
+	    for( int i = 0; i < i_rowCount; i++)
+	    {
+	        QModelIndex indexrecord = p_plModel->index( i, 0, QModelIndex() );
+	        input_item_t * p_item = p_plModel->getInputItem(indexrecord);
+	        //cout <<  p_item->psz_uri;
+	        l.append( indexrecord );
+	    }
+	    p_plModel->doDelete(l);
+	}
+	playlist_Add( THEPL, "file:///media/DATA/Mix%20Playlist/08.%20Beautiful%20South%20-%20Rotterdam%20%28or%20Anywhere%29.mp3", "blabla", PLAYLIST_APPEND, PLAYLIST_END, true,false );
+	//p_plModel->removeItem(0);
+	//playlist_Unlock( THEPL );
+
 }
 
 void StandardPLPanel::activate( const QModelIndex &index )
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index e8e3757..99c2e72 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -140,7 +140,7 @@ private slots:
     void toggleColumnShown( int );
 
     void cycleViews();
-    void shufflePlaylist(const QModelIndex & );
+    void shufflePlaylist();
 
 signals:
     void viewChanged( const QModelIndex& );
-- 
1.7.9.5




More information about the vlc-devel mailing list