summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index c0d3108..d53c423 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -52,16 +52,18 @@
52//only needed for the random play 52//only needed for the random play
53#include <stdlib.h> 53#include <stdlib.h>
54 54
55#include "audiowidget.h" 55#include "audiowidget.h"
56#include "videowidget.h" 56#include "videowidget.h"
57 57
58extern MediaPlayerState *mediaPlayerState; 58extern MediaPlayerState *mediaPlayerState;
59 59
60QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
61// no m3u's here please
60 62
61PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 63PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
62 : PlayListWidgetGui( parent, name, fl ) { 64 : PlayListWidgetGui( parent, name, fl ) {
63 65
64 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 66 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
65 "opieplayer2/add_to_playlist", 67 "opieplayer2/add_to_playlist",
66 this , SLOT(addSelected() ) ); 68 this , SLOT(addSelected() ) );
67 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 69 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
@@ -200,17 +202,17 @@ void PlayListWidget::writeDefaultPlaylist() {
200} 202}
201 203
202void PlayListWidget::addToSelection( const DocLnk& lnk ) { 204void PlayListWidget::addToSelection( const DocLnk& lnk ) {
203 d->setDocumentUsed = FALSE; 205 d->setDocumentUsed = FALSE;
204 if ( mediaPlayerState->playlist() ) { 206 if ( mediaPlayerState->playlist() ) {
205 if( QFileInfo( lnk.file() ).exists() || 207 if( QFileInfo( lnk.file() ).exists() ||
206 lnk.file().left(4) == "http" ) 208 lnk.file().left(4) == "http" )
207 d->selectedFiles->addToSelection( lnk ); 209 d->selectedFiles->addToSelection( lnk );
208 writeCurrentM3u(); 210// writeCurrentM3u();
209 } 211 }
210 else 212 else
211 mediaPlayerState->setPlaying( TRUE ); 213 mediaPlayerState->setPlaying( TRUE );
212} 214}
213 215
214 216
215void PlayListWidget::clearList() { 217void PlayListWidget::clearList() {
216 while ( first() ) { 218 while ( first() ) {
@@ -247,39 +249,43 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
247 } 249 }
248 break; 250 break;
249 } 251 }
250} 252}
251 253
252 254
253void PlayListWidget::addAllToList() { 255void PlayListWidget::addAllToList() {
254 DocLnkSet filesAll; 256 DocLnkSet filesAll;
255 Global::findDocuments(&filesAll, "video/*;audio/*"); 257 Global::findDocuments(&filesAll, "video/*;"+audioMimes);
256 QListIterator<DocLnk> Adit( filesAll.children() ); 258 QListIterator<DocLnk> Adit( filesAll.children() );
257 for ( ; Adit.current(); ++Adit ) { 259 for ( ; Adit.current(); ++Adit ) {
258 if( QFileInfo( Adit.current()->file() ).exists() ) { 260 if( QFileInfo( Adit.current()->file() ).exists() ) {
259 d->selectedFiles->addToSelection( **Adit ); 261 d->selectedFiles->addToSelection( **Adit );
260 } 262 }
261 } 263 }
262 writeCurrentM3u(); 264 writeCurrentM3u();
263} 265}
264 266
265 267
266void PlayListWidget::addAllMusicToList() { 268void PlayListWidget::addAllMusicToList() {
269 if(!audioScan)
270 scanForAudio();
267 QListIterator<DocLnk> dit( files.children() ); 271 QListIterator<DocLnk> dit( files.children() );
268 for ( ; dit.current(); ++dit ) { 272 for ( ; dit.current(); ++dit ) {
269 if( QFileInfo(dit.current()->file() ).exists() ) { 273 if( QFileInfo(dit.current()->file() ).exists() ) {
270 d->selectedFiles->addToSelection( **dit ); 274 d->selectedFiles->addToSelection( **dit );
271 } 275 }
272 } 276 }
273 writeCurrentM3u(); 277 writeCurrentM3u();
274} 278}
275 279
276 280
277void PlayListWidget::addAllVideoToList() { 281void PlayListWidget::addAllVideoToList() {
282 if(!videoScan)
283 scanForVideo();
278 QListIterator<DocLnk> dit( vFiles.children() ); 284 QListIterator<DocLnk> dit( vFiles.children() );
279 for ( ; dit.current(); ++dit ) { 285 for ( ; dit.current(); ++dit ) {
280 if( QFileInfo( dit.current()->file() ).exists() ) { 286 if( QFileInfo( dit.current()->file() ).exists() ) {
281 d->selectedFiles->addToSelection( **dit ); 287 d->selectedFiles->addToSelection( **dit );
282 } 288 }
283 } 289 }
284 writeCurrentM3u(); 290 writeCurrentM3u();
285} 291}
@@ -301,16 +307,18 @@ void PlayListWidget::setDocument( const QString& fileref ) {
301 readm3u( DocLnk( fileref).file() ); 307 readm3u( DocLnk( fileref).file() );
302 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 308 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
303 readPls( fileref ); 309 readPls( fileref );
304 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 310 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
305 readPls( DocLnk( fileref).file() ); 311 readPls( DocLnk( fileref).file() );
306 } else { 312 } else {
307 clearList(); 313 clearList();
308 addToSelection( DocLnk( fileref ) ); 314 addToSelection( DocLnk( fileref ) );
315 writeCurrentM3u();
316
309 d->setDocumentUsed = TRUE; 317 d->setDocumentUsed = TRUE;
310 mediaPlayerState->setPlaying( FALSE ); 318 mediaPlayerState->setPlaying( FALSE );
311 mediaPlayerState->setPlaying( TRUE ); 319 mediaPlayerState->setPlaying( TRUE );
312 } 320 }
313} 321}
314 322
315 323
316void PlayListWidget::useSelectedDocument() { 324void PlayListWidget::useSelectedDocument() {
@@ -607,17 +615,17 @@ void PlayListWidget::playSelected() {
607void PlayListWidget::scanForAudio() { 615void PlayListWidget::scanForAudio() {
608// qDebug("scan for audio"); 616// qDebug("scan for audio");
609 files.detachChildren(); 617 files.detachChildren();
610 QListIterator<DocLnk> sdit( files.children() ); 618 QListIterator<DocLnk> sdit( files.children() );
611 for ( ; sdit.current(); ++sdit ) { 619 for ( ; sdit.current(); ++sdit ) {
612 delete sdit.current(); 620 delete sdit.current();
613 } 621 }
614// Global::findDocuments( &files, "audio/*"); 622// Global::findDocuments( &files, "audio/*");
615 Global::findDocuments( &files, "audio/mpeg;audio/x-wav;audio/x-ogg"); 623 Global::findDocuments( &files, audioMimes);
616 audioScan = TRUE; 624 audioScan = TRUE;
617} 625}
618 626
619void PlayListWidget::scanForVideo() { 627void PlayListWidget::scanForVideo() {
620// qDebug("scan for video"); 628// qDebug("scan for video");
621 vFiles.detachChildren(); 629 vFiles.detachChildren();
622 QListIterator<DocLnk> sdit( vFiles.children() ); 630 QListIterator<DocLnk> sdit( vFiles.children() );
623 for ( ; sdit.current(); ++sdit ) { 631 for ( ; sdit.current(); ++sdit ) {
@@ -839,26 +847,27 @@ void PlayListWidget::readPls( const QString &filename ) {
839 847
840/* 848/*
841 writes current playlist to current m3u file */ 849 writes current playlist to current m3u file */
842void PlayListWidget::writeCurrentM3u() { 850void PlayListWidget::writeCurrentM3u() {
843 qDebug("writing to current m3u"); 851 qDebug("writing to current m3u");
844 Config cfg( "OpiePlayer" ); 852 Config cfg( "OpiePlayer" );
845 cfg.setGroup("PlayList"); 853 cfg.setGroup("PlayList");
846 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 854 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
847 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 855
848 Om3u *m3uList; 856 Om3u *m3uList;
849 m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate ); 857 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
850 d->selectedFiles->first(); 858 d->selectedFiles->first();
851 859 qDebug( d->selectedFiles->current()->file());
852 do { 860 do {
853 m3uList->add( d->selectedFiles->current()->file()); 861 qDebug( d->selectedFiles->current()->file());
862 m3uList->add( d->selectedFiles->current()->file() );
854 } 863 }
855 while ( d->selectedFiles->next() ); 864 while ( d->selectedFiles->next() );
856// qDebug( list ); 865 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
857 m3uList->write(); 866 m3uList->write();
858 m3uList->close(); 867 m3uList->close();
859 868
860 if(m3uList) delete m3uList; 869 if(m3uList) delete m3uList;
861} 870}
862 871
863 /* 872 /*
864 writes current playlist to m3u file */ 873 writes current playlist to m3u file */