summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-21 01:34:05 (UTC)
committer llornkcor <llornkcor>2002-06-21 01:34:05 (UTC)
commit40d079bad7c5bce23031f7e9610b402cf88438c0 (patch) (unidiff)
treeeb6e18d32754f135a0e395aa371a3a9ba842da56
parent3f1129f79e945135828191679559da70cf4ac6fa (diff)
downloadopie-40d079bad7c5bce23031f7e9610b402cf88438c0.zip
opie-40d079bad7c5bce23031f7e9610b402cf88438c0.tar.gz
opie-40d079bad7c5bce23031f7e9610b402cf88438c0.tar.bz2
export playlist to m3u
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp479
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h2
2 files changed, 256 insertions, 225 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index eeaed33..ae25fe3 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -100,14 +100,14 @@ public:
100class ToolButton : public QToolButton { 100class ToolButton : public QToolButton {
101public: 101public:
102 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 102 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
103 : QToolButton( parent, name ) { 103 : QToolButton( parent, name ) {
104 setTextLabel( name ); 104 setTextLabel( name );
105 setPixmap( Resource::loadPixmap( icon ) ); 105 setPixmap( Resource::loadPixmap( icon ) );
106 setAutoRaise( TRUE ); 106 setAutoRaise( TRUE );
107 setFocusPolicy( QWidget::NoFocus ); 107 setFocusPolicy( QWidget::NoFocus );
108 setToggleButton( t ); 108 setToggleButton( t );
109 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 109 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
110 QPEMenuToolFocusManager::manager()->addWidget( this ); 110 QPEMenuToolFocusManager::manager()->addWidget( this );
111 } 111 }
112}; 112};
113 113
@@ -115,15 +115,15 @@ public:
115class MenuItem : public QAction { 115class MenuItem : public QAction {
116public: 116public:
117 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 117 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
118 : QAction( text, QString::null, 0, 0 ) { 118 : QAction( text, QString::null, 0, 0 ) {
119 connect( this, SIGNAL( activated() ), handler, slot ); 119 connect( this, SIGNAL( activated() ), handler, slot );
120 addTo( parent ); 120 addTo( parent );
121 } 121 }
122}; 122};
123 123
124 124
125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
126 : QMainWindow( parent, name, fl ) { 126 : QMainWindow( parent, name, fl ) {
127 127
128 d = new PlayListWidgetPrivate; 128 d = new PlayListWidgetPrivate;
129 d->setDocumentUsed = FALSE; 129 d->setDocumentUsed = FALSE;
@@ -142,11 +142,11 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
142 142
143 setToolBarsMovable( FALSE ); 143 setToolBarsMovable( FALSE );
144 144
145 // Create Toolbar 145 // Create Toolbar
146 QPEToolBar *toolbar = new QPEToolBar( this ); 146 QPEToolBar *toolbar = new QPEToolBar( this );
147 toolbar->setHorizontalStretchable( TRUE ); 147 toolbar->setHorizontalStretchable( TRUE );
148 148
149 // Create Menubar 149 // Create Menubar
150 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 150 QPEMenuBar *menu = new QPEMenuBar( toolbar );
151 menu->setMargin( 0 ); 151 menu->setMargin( 0 );
152 152
@@ -177,8 +177,9 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
180// pmPlayList->insertSeparator(-1); 180 pmPlayList->insertSeparator(-1);
181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
182 pmPlayList->insertSeparator(-1); 183 pmPlayList->insertSeparator(-1);
183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 184 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
184 pmPlayList->insertSeparator(-1); 185 pmPlayList->insertSeparator(-1);
@@ -208,7 +209,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
208 tabWidget->insertTab( pTab,"Playlist"); 209 tabWidget->insertTab( pTab,"Playlist");
209 210
210 211
211 // Add the playlist area 212 // Add the playlist area
212 213
213 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 214 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
214 d->playListFrame = vbox3; 215 d->playListFrame = vbox3;
@@ -223,11 +224,11 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
223 224
224 225
225 226
226 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
227 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
228 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
229 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
230 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
231 232
232 QWidget *aTab; 233 QWidget *aTab;
233 aTab = new QWidget( tabWidget, "aTab" ); 234 aTab = new QWidget( tabWidget, "aTab" );
@@ -293,7 +294,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
293 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 294 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
294 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 295 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
295 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 296 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
296 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 297 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
297 298
298 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 299 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
299 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 300 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
@@ -306,19 +307,19 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
306 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
307 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 308 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
308 this,SLOT( playIt( QListViewItem *)) ); 309 this,SLOT( playIt( QListViewItem *)) );
309 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 310 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
310 311
311 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 312 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
312 313
313 314
314 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 315 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
315 316
316 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 317 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
317 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 318 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
318 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 319 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
319 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 320 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
320 321
321 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 322 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
322// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 323// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
323 324
324 setCentralWidget( vbox5 ); 325 setCentralWidget( vbox5 );
@@ -340,7 +341,7 @@ PlayListWidget::~PlayListWidget() {
340 341
341 342
342 if ( d->current ) 343 if ( d->current )
343 delete d->current; 344 delete d->current;
344 delete d; 345 delete d;
345} 346}
346 347
@@ -354,7 +355,7 @@ void PlayListWidget::initializeStates() {
354// d->tbScale->setOn( mediaPlayerState->scaled() ); 355// d->tbScale->setOn( mediaPlayerState->scaled() );
355// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
356// setPlaylist( mediaPlayerState->playlist() ); 357// setPlaylist( mediaPlayerState->playlist() );
357 setPlaylist( true); 358 setPlaylist( true);
358// d->selectedFiles->first(); 359// d->selectedFiles->first();
359 360
360} 361}
@@ -373,7 +374,7 @@ void PlayListWidget::readConfig( Config& cfg ) {
373 d->selectedFiles->addToSelection( lnk ); 374 d->selectedFiles->addToSelection( lnk );
374 } 375 }
375 } 376 }
376 d->selectedFiles->setSelectedItem( currentString); 377 d->selectedFiles->setSelectedItem( currentString);
377// d->selectedFiles->setSelectedItem( (const QString &)currentString); 378// d->selectedFiles->setSelectedItem( (const QString &)currentString);
378} 379}
379 380
@@ -434,7 +435,7 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
434 435
435void PlayListWidget::clearList() { 436void PlayListWidget::clearList() {
436 while ( first() ) 437 while ( first() )
437 d->selectedFiles->removeSelected(); 438 d->selectedFiles->removeSelected();
438} 439}
439 440
440 441
@@ -452,7 +453,7 @@ void PlayListWidget::addAllMusicToList() {
452 QListIterator<DocLnk> dit( files.children() ); 453 QListIterator<DocLnk> dit( files.children() );
453 for ( ; dit.current(); ++dit ) 454 for ( ; dit.current(); ++dit )
454 if(QFileInfo(dit.current()->file()).exists()) 455 if(QFileInfo(dit.current()->file()).exists())
455 d->selectedFiles->addToSelection( **dit ); 456 d->selectedFiles->addToSelection( **dit );
456} 457}
457 458
458 459
@@ -472,12 +473,12 @@ void PlayListWidget::setDocument(const QString& fileref) {
472 return; 473 return;
473 } 474 }
474// qDebug("setDocument "+fileref); 475// qDebug("setDocument "+fileref);
475 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
476 readm3u( fileref); 477 readm3u( fileref);
477 } 478 }
478 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
479 readPls( fileref); 480 readPls( fileref);
480 } 481 }
481 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
482 clearList(); 483 clearList();
483 loadList(DocLnk(fileref)); 484 loadList(DocLnk(fileref));
@@ -496,7 +497,7 @@ void PlayListWidget::setDocument(const QString& fileref) {
496 497
497 498
498void PlayListWidget::setActiveWindow() { 499void PlayListWidget::setActiveWindow() {
499 // When we get raised we need to ensure that it switches views 500 // When we get raised we need to ensure that it switches views
500 char origView = mediaPlayerState->view(); 501 char origView = mediaPlayerState->view();
501 mediaPlayerState->setView( 'l' ); // invalidate 502 mediaPlayerState->setView( 'l' ); // invalidate
502 mediaPlayerState->setView( origView ); // now switch back 503 mediaPlayerState->setView( origView ); // now switch back
@@ -639,8 +640,8 @@ void PlayListWidget::saveList() {
639 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 640 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
640 fileDlg->exec(); 641 fileDlg->exec();
641 if( fileDlg->result() == 1 ) { 642 if( fileDlg->result() == 1 ) {
642 if ( d->current ) 643 if ( d->current )
643 delete d->current; 644 delete d->current;
644 filename = fileDlg->LineEdit1->text();//+".playlist"; 645 filename = fileDlg->LineEdit1->text();//+".playlist";
645// qDebug("saving playlist "+filename+".playlist"); 646// qDebug("saving playlist "+filename+".playlist");
646 Config cfg( filename +".playlist"); 647 Config cfg( filename +".playlist");
@@ -655,13 +656,13 @@ void PlayListWidget::saveList() {
655// qDebug(filename); 656// qDebug(filename);
656 if(!lnk.writeLink()) 657 if(!lnk.writeLink())
657 qDebug("Writing doclink did not work"); 658 qDebug("Writing doclink did not work");
658 } 659 }
659 Config config( "OpiePlayer" ); 660 Config config( "OpiePlayer" );
660 config.writeEntry("CurrentPlaylist",filename); 661 config.writeEntry("CurrentPlaylist",filename);
661 setCaption(tr("OpiePlayer: ")+filename); 662 setCaption(tr("OpiePlayer: ")+filename);
662 d->selectedFiles->first(); 663 d->selectedFiles->first();
663 if(fileDlg) 664 if(fileDlg)
664 delete fileDlg; 665 delete fileDlg;
665} 666}
666 667
667void PlayListWidget::loadList( const DocLnk & lnk) { 668void PlayListWidget::loadList( const DocLnk & lnk) {
@@ -685,63 +686,63 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
685 686
686void PlayListWidget::setPlaylist( bool shown ) { 687void PlayListWidget::setPlaylist( bool shown ) {
687 if ( shown ) 688 if ( shown )
688 d->playListFrame->show(); 689 d->playListFrame->show();
689 else 690 else
690 d->playListFrame->hide(); 691 d->playListFrame->hide();
691} 692}
692 693
693void PlayListWidget::setView( char view ) { 694void PlayListWidget::setView( char view ) {
694 if ( view == 'l' ) 695 if ( view == 'l' )
695 showMaximized(); 696 showMaximized();
696 else 697 else
697 hide(); 698 hide();
698} 699}
699 700
700void PlayListWidget::addSelected() { 701void PlayListWidget::addSelected() {
701 702
702 Config cfg( "OpiePlayer" ); 703 Config cfg( "OpiePlayer" );
703 cfg.setGroup("PlayList"); 704 cfg.setGroup("PlayList");
704 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 705 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
705 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 706 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
706 707
707 switch (tabWidget->currentPageIndex()) { 708 switch (tabWidget->currentPageIndex()) {
708 case 0: //playlist 709 case 0: //playlist
709 break; 710 break;
710 case 1: { //audio 711 case 1: { //audio
711// QString entryName; 712// QString entryName;
712// entryName.sprintf( "File%i", i + 1 ); 713// entryName.sprintf( "File%i", i + 1 );
713// QString linkFile = cfg.readEntry( entryName ); 714// QString linkFile = cfg.readEntry( entryName );
714 QListViewItemIterator it( audioView ); 715 QListViewItemIterator it( audioView );
715 // iterate through all items of the listview 716 // iterate through all items of the listview
716 for ( ; it.current(); ++it ) { 717 for ( ; it.current(); ++it ) {
717 if ( it.current()->isSelected() ) { 718 if ( it.current()->isSelected() ) {
718 QListIterator<DocLnk> dit( files.children() ); 719 QListIterator<DocLnk> dit( files.children() );
719 for ( ; dit.current(); ++dit ) { 720 for ( ; dit.current(); ++dit ) {
720 if( dit.current()->name() == it.current()->text(0) ) { 721 if( dit.current()->name() == it.current()->text(0) ) {
721 d->selectedFiles->addToSelection( **dit ); 722 d->selectedFiles->addToSelection( **dit );
722 } 723 }
723 } 724 }
724 audioView->setSelected( it.current(),FALSE); 725 audioView->setSelected( it.current(),FALSE);
725 } 726 }
726 } 727 }
727 tabWidget->setCurrentPage(0); 728 tabWidget->setCurrentPage(0);
728 } 729 }
729 break; 730 break;
730 case 2: { // video 731 case 2: { // video
731 QListViewItemIterator it( videoView ); 732 QListViewItemIterator it( videoView );
732 // iterate through all items of the listview 733 // iterate through all items of the listview
733 for ( ; it.current(); ++it ) { 734 for ( ; it.current(); ++it ) {
734 if ( it.current()->isSelected() ) { 735 if ( it.current()->isSelected() ) {
735 QListIterator<DocLnk> dit( vFiles.children() ); 736 QListIterator<DocLnk> dit( vFiles.children() );
736 for ( ; dit.current(); ++dit ) { 737 for ( ; dit.current(); ++dit ) {
737 if( dit.current()->name() == it.current()->text(0) ) { 738 if( dit.current()->name() == it.current()->text(0) ) {
738 d->selectedFiles->addToSelection( **dit ); 739 d->selectedFiles->addToSelection( **dit );
739 } 740 }
740 } 741 }
741 742
742 videoView->setSelected( it.current(),FALSE); 743 videoView->setSelected( it.current(),FALSE);
743 } 744 }
744 } 745 }
745// for ( int i = 0; i < noOfFiles; i++ ) { 746// for ( int i = 0; i < noOfFiles; i++ ) {
746// QString entryName; 747// QString entryName;
747// entryName.sprintf( "File%i", i + 1 ); 748// entryName.sprintf( "File%i", i + 1 );
@@ -755,10 +756,10 @@ void PlayListWidget::addSelected() {
755// } 756// }
756// } 757// }
757// addToSelection( videoView->selectedItem() ); 758// addToSelection( videoView->selectedItem() );
758 tabWidget->setCurrentPage(0); 759 tabWidget->setCurrentPage(0);
759 } 760 }
760 break; 761 break;
761 }; 762 };
762} 763}
763 764
764void PlayListWidget::removeSelected() { 765void PlayListWidget::removeSelected() {
@@ -768,10 +769,10 @@ void PlayListWidget::removeSelected() {
768void PlayListWidget::playIt( QListViewItem *it) { 769void PlayListWidget::playIt( QListViewItem *it) {
769// d->setDocumentUsed = FALSE; 770// d->setDocumentUsed = FALSE;
770// mediaPlayerState->curPosition =0; 771// mediaPlayerState->curPosition =0;
771 qDebug("playIt"); 772 qDebug("playIt");
772 mediaPlayerState->setPlaying(FALSE); 773 mediaPlayerState->setPlaying(FALSE);
773 mediaPlayerState->setPlaying(TRUE); 774 mediaPlayerState->setPlaying(TRUE);
774 d->selectedFiles->unSelect(); 775 d->selectedFiles->unSelect();
775} 776}
776 777
777void PlayListWidget::addToSelection( QListViewItem *it) { 778void PlayListWidget::addToSelection( QListViewItem *it) {
@@ -787,7 +788,7 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
787 } 788 }
788 } 789 }
789 } 790 }
790 break; 791 break;
791 case 2: { 792 case 2: {
792 QListIterator<DocLnk> dit( vFiles.children() ); 793 QListIterator<DocLnk> dit( vFiles.children() );
793 for ( ; dit.current(); ++dit ) { 794 for ( ; dit.current(); ++dit ) {
@@ -796,7 +797,7 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
796 } 797 }
797 } 798 }
798 } 799 }
799 break; 800 break;
800 case 0: 801 case 0:
801 break; 802 break;
802 }; 803 };
@@ -852,36 +853,34 @@ void PlayListWidget::btnPlay(bool b) {
852 switch ( tabWidget->currentPageIndex()) { 853 switch ( tabWidget->currentPageIndex()) {
853 case 0: 854 case 0:
854 { 855 {
855 qDebug("here we are"); 856// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
856 if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 857// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
857 || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 858 QMessageBox::message("Note","You are trying to play\na malformed url.");
858 QMessageBox::message("Note","You are trying to play\na malformed url."); 859// } else {
859
860 } else {
861
862 mediaPlayerState->setPlaying(b); 860 mediaPlayerState->setPlaying(b);
863 } } 861// }
862 }
864 break; 863 break;
865 case 1: 864 case 1:
866 { 865 {
867 addToSelection( audioView->currentItem() ); 866 addToSelection( audioView->currentItem() );
868 mediaPlayerState->setPlaying(b); 867 mediaPlayerState->setPlaying(b);
869 d->selectedFiles->removeSelected( ); 868 d->selectedFiles->removeSelected( );
870 tabWidget->setCurrentPage(1); 869 tabWidget->setCurrentPage(1);
871 d->selectedFiles->unSelect(); 870 d->selectedFiles->unSelect();
872 insanityBool=FALSE; 871 insanityBool=FALSE;
873 }// audioView->clearSelection(); 872 }// audioView->clearSelection();
874 break; 873 break;
875 case 2: 874 case 2:
876 { 875 {
877 addToSelection( videoView->currentItem() ); 876 addToSelection( videoView->currentItem() );
878 mediaPlayerState->setPlaying(b); 877 mediaPlayerState->setPlaying(b);
879 qApp->processEvents(); 878 qApp->processEvents();
880 d->selectedFiles->removeSelected( ); 879 d->selectedFiles->removeSelected( );
881 tabWidget->setCurrentPage(2); 880 tabWidget->setCurrentPage(2);
882 d->selectedFiles->unSelect(); 881 d->selectedFiles->unSelect();
883 insanityBool=FALSE; 882 insanityBool=FALSE;
884 }// videoView->clearSelection(); 883 }// videoView->clearSelection();
885 break; 884 break;
886 }; 885 };
887 886
@@ -891,13 +890,13 @@ void PlayListWidget::deletePlaylist() {
891 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 890 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
892 (tr("You really want to delete\nthis playlist?")), 891 (tr("You really want to delete\nthis playlist?")),
893 (tr("Yes")), (tr("No")), 0 )){ 892 (tr("Yes")), (tr("No")), 0 )){
894 case 0: // Yes clicked, 893 case 0: // Yes clicked,
895 QFile().remove(playLists->selected()->file()); 894 QFile().remove(playLists->selected()->file());
896 QFile().remove(playLists->selected()->linkFile()); 895 QFile().remove(playLists->selected()->linkFile());
897 playLists->reread(); 896 playLists->reread();
898 break; 897 break;
899 case 1: // Cancel 898 case 1: // Cancel
900 break; 899 break;
901 }; 900 };
902} 901}
903 902
@@ -917,7 +916,7 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint&
917 916
918 m.exec( QCursor::pos() ); 917 m.exec( QCursor::pos() );
919 } 918 }
920 break; 919 break;
921 }; 920 };
922} 921}
923 922
@@ -929,29 +928,29 @@ void PlayListWidget::playSelected()
929 928
930void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 929void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
931{ 930{
932 switch (mouse) { 931 switch (mouse) {
933 case 1: 932 case 1:
934 933
935 break; 934 break;
936 case 2:{ 935 case 2:{
937 QPopupMenu m; 936 QPopupMenu m;
938 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 937 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
939 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 938 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
940// m.insertSeparator(); 939// m.insertSeparator();
941// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 940// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
942 m.exec( QCursor::pos() ); 941 m.exec( QCursor::pos() );
943 } 942 }
944 break; 943 break;
945 }; 944 };
946 945
947} 946}
948 947
949void PlayListWidget::listDelete() { 948void PlayListWidget::listDelete() {
950 Config cfg( "OpiePlayer" ); 949 Config cfg( "OpiePlayer" );
951 cfg.setGroup("PlayList"); 950 cfg.setGroup("PlayList");
952 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 951 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
953 QString file; 952 QString file;
954 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 953 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
955 switch ( tabWidget->currentPageIndex()) { 954 switch ( tabWidget->currentPageIndex()) {
956 case 0: 955 case 0:
957 break; 956 break;
@@ -970,7 +969,7 @@ void PlayListWidget::listDelete() {
970 prop.exec(); 969 prop.exec();
971 } 970 }
972 } 971 }
973 populateAudioView(); 972 populateAudioView();
974 } 973 }
975 break; 974 break;
976 case 2: 975 case 2:
@@ -989,7 +988,7 @@ void PlayListWidget::listDelete() {
989// } 988// }
990// } 989// }
991 } 990 }
992 break; 991 break;
993 }; 992 };
994} 993}
995 994
@@ -1081,34 +1080,34 @@ void PlayListWidget::openFile() {
1081// http://66.28.68.70:8000 1080// http://66.28.68.70:8000
1082// filename.replace(QRegExp("%20")," "); 1081// filename.replace(QRegExp("%20")," ");
1083 if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) { 1082 if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) {
1084 QMessageBox::message("Note","Spaces in urls are not allowed."); 1083 QMessageBox::message("Note","Spaces in urls are not allowed.");
1085 return; 1084 return;
1086 } else { 1085 } else {
1087 qDebug("Selected filename is "+filename); 1086 qDebug("Selected filename is "+filename);
1088 if(filename.right(3) == "m3u") 1087 if(filename.right(3) == "m3u")
1089 readm3u( filename); 1088 readm3u( filename);
1090 else if(filename.right(3) == "pls") 1089 else if(filename.right(3) == "pls")
1091 readPls( filename); 1090 readPls( filename);
1092 else { 1091 else {
1093 DocLnk lnk; 1092 DocLnk lnk;
1094 1093
1095 lnk.setName(filename); //sets file name 1094 lnk.setName(filename); //sets file name
1096 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1095 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1097 filename += "/"; 1096 filename += "/";
1098 lnk.setFile(filename); //sets File property 1097 lnk.setFile(filename); //sets File property
1099 1098
1100 lnk.setType("audio/x-mpegurl"); 1099 lnk.setType("audio/x-mpegurl");
1101 lnk.setExec("opieplayer"); 1100 lnk.setExec("opieplayer");
1102 lnk.setIcon("opieplayer/MPEGPlayer"); 1101 lnk.setIcon("opieplayer/MPEGPlayer");
1103 1102
1104 if(!lnk.writeLink()) 1103 if(!lnk.writeLink())
1105 qDebug("Writing doclink did not work"); 1104 qDebug("Writing doclink did not work");
1106 d->selectedFiles->addToSelection( lnk); 1105 d->selectedFiles->addToSelection( lnk);
1107// if(fileDlg2) 1106// if(fileDlg2)
1108// delete fileDlg2; 1107// delete fileDlg2;
1108 }
1109 } 1109 }
1110 } 1110 }
1111 }
1112 if(fileDlg) 1111 if(fileDlg)
1113 delete fileDlg; 1112 delete fileDlg;
1114} 1113}
@@ -1187,25 +1186,25 @@ void PlayListWidget::keyPressEvent( QKeyEvent *e)
1187} 1186}
1188 1187
1189void PlayListWidget::doBlank() { 1188void PlayListWidget::doBlank() {
1190 qDebug("do blanking"); 1189 qDebug("do blanking");
1191 fd=open("/dev/fb0",O_RDWR); 1190 fd=open("/dev/fb0",O_RDWR);
1192 if (fd != -1) { 1191 if (fd != -1) {
1193 ioctl(fd,FBIOBLANK,1); 1192 ioctl(fd,FBIOBLANK,1);
1194// close(fd); 1193// close(fd);
1195 } 1194 }
1196} 1195}
1197 1196
1198void PlayListWidget::doUnblank() { 1197void PlayListWidget::doUnblank() {
1199 // this crashes opieplayer with a segfault 1198 // this crashes opieplayer with a segfault
1200// int fd; 1199// int fd;
1201// fd=open("/dev/fb0",O_RDWR); 1200// fd=open("/dev/fb0",O_RDWR);
1202 qDebug("do unblanking"); 1201 qDebug("do unblanking");
1203 if (fd != -1) { 1202 if (fd != -1) {
1204 ioctl(fd,FBIOBLANK,0); 1203 ioctl(fd,FBIOBLANK,0);
1205 close(fd); 1204 close(fd);
1206 } 1205 }
1207 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1206 QCopEnvelope h("QPE/System", "setBacklight(int)");
1208 h <<-3;// v[1]; // -3 Force on 1207 h <<-3;// v[1]; // -3 Force on
1209} 1208}
1210 1209
1211void PlayListWidget::readm3u(const QString &filename) { 1210void PlayListWidget::readm3u(const QString &filename) {
@@ -1220,11 +1219,11 @@ void PlayListWidget::readm3u(const QString &filename) {
1220 while ( !t.atEnd()) { 1219 while ( !t.atEnd()) {
1221// Lview->insertLine(t.readLine(),-1); 1220// Lview->insertLine(t.readLine(),-1);
1222 s=t.readLine(); 1221 s=t.readLine();
1223 if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { 1222 if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) {
1224 QMessageBox::message("Note","Spaces in urls are not allowed."); 1223 QMessageBox::message("Note","Spaces in urls are not allowed.");
1225 } 1224 }
1226 else if(s.find("#",0,TRUE) == -1) { 1225 else if(s.find("#",0,TRUE) == -1) {
1227 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1226 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1228 if(s.left(2) == "E:" || s.left(2) == "P:") { 1227 if(s.left(2) == "E:" || s.left(2) == "P:") {
1229 s=s.right(s.length()-2); 1228 s=s.right(s.length()-2);
1230 DocLnk lnk( s ); 1229 DocLnk lnk( s );
@@ -1237,40 +1236,68 @@ void PlayListWidget::readm3u(const QString &filename) {
1237 lnk.writeLink(); 1236 lnk.writeLink();
1238// lnk.setIcon(opieplayer/MPEGPlayer); 1237// lnk.setIcon(opieplayer/MPEGPlayer);
1239 qDebug("add "+name); 1238 qDebug("add "+name);
1240 d->selectedFiles->addToSelection( lnk); 1239 d->selectedFiles->addToSelection( lnk);
1241 } else { // is url 1240 } else { // is url
1242 1241
1243 s.replace(QRegExp("%20")," "); 1242 s.replace(QRegExp("%20")," ");
1244 DocLnk lnk( s); 1243 DocLnk lnk( s);
1245 QString name; 1244 QString name;
1246 if(name.left(4)=="http") 1245 if(name.left(4)=="http")
1247 name = s.right( s.length() - 7); 1246 name = s.right( s.length() - 7);
1248 else 1247 else
1249 name=s; 1248 name=s;
1250// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1249// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1251 lnk.setName(name); 1250 lnk.setName(name);
1252 if(s.at(s.length()-4) == '.') 1251 if(s.at(s.length()-4) == '.')
1253 lnk.setFile( s); 1252 lnk.setFile( s);
1254 else 1253 else
1255 lnk.setFile( s+"/"); 1254 lnk.setFile( s+"/");
1256// lnk.setFile( filename); 1255// lnk.setFile( filename);
1257// lnk.setComment( s+"/"); 1256// lnk.setComment( s+"/");
1258 lnk.setType("audio/x-mpegurl"); 1257 lnk.setType("audio/x-mpegurl");
1259 lnk.writeLink(); 1258 lnk.writeLink();
1260// lnk.setIcon( "opieplayer/MPEGPlayer"); 1259// lnk.setIcon( "opieplayer/MPEGPlayer");
1261// qDebug("add "+s); 1260// qDebug("add "+s);
1262 d->selectedFiles->addToSelection( lnk); 1261 d->selectedFiles->addToSelection( lnk);
1263 } 1262 }
1264 i++; 1263 i++;
1265 } 1264 }
1266 } 1265 }
1267 } 1266 }
1268 } 1267 }
1269 f.close(); 1268 f.close();
1270} 1269}
1271 1270
1272void PlayListWidget::writem3u(const QString &filename) { 1271void PlayListWidget::writem3u() {
1273 1272
1273 InputDialog *fileDlg;
1274 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1275 fileDlg->exec();
1276 QString filename,list;
1277 if( fileDlg->result() == 1 ) {
1278 filename = fileDlg->LineEdit1->text();
1279 qDebug(filename);
1280 int noOfFiles = 0;
1281 d->selectedFiles->first();
1282 do {
1283// we dont check for existance because of url's
1284// qDebug(d->selectedFiles->current()->file());
1285 list += d->selectedFiles->current()->file()+"\n";
1286 noOfFiles++;
1287 }
1288 while ( d->selectedFiles->next() );
1289 qDebug(list);
1290 if(filename.left(1) != "/")
1291 filename=QPEApplication::documentDir()+"/"+filename;
1292 if(filename.right(3) != "m3u")
1293 filename=filename+".m3u";
1294
1295 QFile f(filename);
1296 f.open(IO_WriteOnly);
1297 f.writeBlock(list, list.length());
1298 f.close();
1299 }
1300 if(fileDlg) delete fileDlg;
1274} 1301}
1275 1302
1276void PlayListWidget::readPls(const QString &filename) { 1303void PlayListWidget::readPls(const QString &filename) {
@@ -1282,38 +1309,42 @@ void PlayListWidget::readPls(const QString &filename) {
1282 QTextStream t(&f); 1309 QTextStream t(&f);
1283 QString s;//, first, second; 1310 QString s;//, first, second;
1284 int i=0; 1311 int i=0;
1285 while ( !t.atEnd()) { 1312 while ( !t.atEnd()) {
1286 s=t.readLine(); 1313 s=t.readLine();
1287 if(s.left(4) == "File") { 1314 if(s.left(4) == "File") {
1288 s=s.right(s.length() - 6); 1315 s=s.right(s.length() - 6);
1289 s.replace(QRegExp("%20")," "); 1316 s.replace(QRegExp("%20")," ");
1290 qDebug("adding "+s+" to playlist"); 1317 qDebug("adding "+s+" to playlist");
1291// numberofentries=2 1318// numberofentries=2
1292// File1=http 1319// File1=http
1293 // Title 1320// Title
1294// Length 1321// Length
1295// Version 1322// Version
1296// File2=http 1323// File2=http
1297 1324
1298 s=s.replace( QRegExp("\\"),"/"); 1325 s=s.replace( QRegExp("\\"),"/");
1299// Lview->insertLine(t.readLine(),-1); 1326 DocLnk lnk( s );
1300// s=t.readLine(); 1327 QFileInfo f(s);
1301// s=s.right(s.length()-2); 1328 QString name = f.baseName();
1302 DocLnk lnk( s ); 1329 if(name.left(4)=="http")
1303 QFileInfo f(s); 1330 name = s.right( s.length() - 7);
1304 QString name = f.baseName(); 1331 else
1305 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1332 name=s;
1333 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1306// QFileInfo f(s); 1334// QFileInfo f(s);
1307// QString name = f.baseName(); 1335// QString name = f.baseName();
1308// // name = name.left(name.length()-4); 1336// name = name.left(name.length()-4);
1309// name = name.right(name.findRev("/",0,TRUE)); 1337// name = name.right(name.findRev("/",0,TRUE));
1310 lnk.setName( name); 1338 lnk.setName( name);
1311 lnk.setFile( s+"/"); 1339 if(s.at(s.length()-4) == '.')
1312 lnk.setType("audio/x-mpegurl"); 1340 lnk.setFile( s);
1313 1341 else
1314 qDebug("DocLnk add "+name); 1342 lnk.setFile( s+"/");
1315 d->selectedFiles->addToSelection( lnk); 1343 lnk.setType("audio/x-mpegurl");
1316 } 1344
1345 qDebug("DocLnk add "+name);
1346 d->selectedFiles->addToSelection( lnk);
1347 }
1317 } 1348 }
1318 i++; 1349 i++;
1319 } 1350 }
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 5837ed3..7718a8c 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -75,7 +75,6 @@ private:
75 void doBlank(); 75 void doBlank();
76 void doUnblank(); 76 void doUnblank();
77 void readm3u(const QString &); 77 void readm3u(const QString &);
78 void writem3u(const QString &);
79 void readPls(const QString &); 78 void readPls(const QString &);
80 79
81 80
@@ -86,6 +85,7 @@ private:
86 void populateAudioView(); 85 void populateAudioView();
87 void populateVideoView(); 86 void populateVideoView();
88private slots: 87private slots:
88 void writem3u();
89 void scanForAudio(); 89 void scanForAudio();
90 void scanForVideo(); 90 void scanForVideo();
91 void openFile(); 91 void openFile();