[vlc-devel] [PATCH 3/6] Shuffle button now reverses the order of the songs. This was done to test the chosen method. The code is now ready for the implementation of a random permutation over the songs.

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


---
 .../gui/qt4/components/playlist/standardpanel.cpp  |   24 +++++++++++++++++---
 modules/gui/qt4/dialogs_provider.cpp               |    1 +
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 27af573..738d099 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -65,6 +65,9 @@
 #include <assert.h>
 
 
+#include <iostream>
+#include <string.h>
+
 StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   intf_thread_t *_p_intf,
                                   playlist_item_t *p_root,
@@ -718,6 +721,17 @@ void StandardPLPanel::shufflePlaylist()
 	//playlist_Lock( THEPL );
 	PLModel *p_plModel = PLModel::getPLModel(StandardPLPanel::p_intf);
 	int i_rowCount = p_plModel->rowCount();
+	unsigned int i_max = 0;
+	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);
+		i_max = strlen(p_item->psz_uri) > i_max ? strlen(p_item->psz_uri) : i_max;
+
+	}
+
+	char shuffle[i_rowCount][i_max + 1];
+
 	if( i_rowCount > 1 )
 	{
 
@@ -726,13 +740,17 @@ void StandardPLPanel::shufflePlaylist()
 	    {
 	        QModelIndex indexrecord = p_plModel->index( i, 0, QModelIndex() );
 	        input_item_t * p_item = p_plModel->getInputItem(indexrecord);
-	        //cout <<  p_item->psz_uri;
+	        strcpy( shuffle[i], p_item->psz_uri );
 	        l.append( indexrecord );
 	    }
 	    p_plModel->doDelete(l);
+
+	    for( int i = i_rowCount-1; i > -1; i--)
+	    {
+	    	playlist_Add( THEPL, shuffle[i], NULL, PLAYLIST_APPEND, PLAYLIST_END, true,false );
+	    }
 	}
-	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 );
 
 }
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 2a15d5b..645fcc5 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -62,6 +62,7 @@
 #include <QSignalMapper>
 #include <QFileDialog>
 
+
 #define I_OP_DIR_WINTITLE I_DIR_OR_FOLDER( N_("Open Directory"), \
                                            N_("Open Folder") )
 
-- 
1.7.9.5




More information about the vlc-devel mailing list