summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index cc4be23..c0d3108 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -468,65 +468,65 @@ void PlayListWidget::addSelected() {
468 if(QFileInfo( dit.current()->file()).exists()) { 468 if(QFileInfo( dit.current()->file()).exists()) {
469 d->selectedFiles->addToSelection( **dit ); 469 d->selectedFiles->addToSelection( **dit );
470 videoView->setSelected( it.current(),FALSE); 470 videoView->setSelected( it.current(),FALSE);
471 } 471 }
472 } 472 }
473 } 473 }
474 } 474 }
475 } 475 }
476 tabWidget->setCurrentPage(0); 476 tabWidget->setCurrentPage(0);
477 writeCurrentM3u(); 477 writeCurrentM3u();
478 } 478 }
479 break; 479 break;
480 }; 480 };
481} 481}
482 482
483 483
484void PlayListWidget::removeSelected() { 484void PlayListWidget::removeSelected() {
485 d->selectedFiles->removeSelected( ); 485 d->selectedFiles->removeSelected( );
486 writeCurrentM3u(); 486 writeCurrentM3u();
487} 487}
488 488
489 489
490void PlayListWidget::playIt( QListViewItem *it) { 490void PlayListWidget::playIt( QListViewItem *it) {
491 if(!it) return; 491 if(!it) return;
492 mediaPlayerState->setPlaying(FALSE); 492 mediaPlayerState->setPlaying(FALSE);
493 mediaPlayerState->setPlaying(TRUE); 493 mediaPlayerState->setPlaying(TRUE);
494 d->selectedFiles->unSelect(); 494 d->selectedFiles->unSelect();
495} 495}
496 496
497 497
498void PlayListWidget::addToSelection( QListViewItem *it) { 498void PlayListWidget::addToSelection( QListViewItem *it) {
499 d->setDocumentUsed = FALSE; 499 d->setDocumentUsed = FALSE;
500 qDebug("addToSelection2"); 500
501 if(it) { 501 if(it) {
502 switch ( whichList()) { 502 switch ( whichList()) {
503 case 1: { 503 case 1: {
504 QListIterator<DocLnk> dit( files.children() ); 504 QListIterator<DocLnk> dit( files.children() );
505 for ( ; dit.current(); ++dit ) { 505 for ( ; dit.current(); ++dit ) {
506 if( dit.current()->name() == it->text(0)) { 506 if( dit.current()->name() == it->text(0)) {
507 if(QFileInfo( dit.current()->file()).exists()) 507 if(QFileInfo( dit.current()->file()).exists())
508 d->selectedFiles->addToSelection( **dit ); 508 d->selectedFiles->addToSelection( **dit );
509 } 509 }
510 } 510 }
511 writeCurrentM3u(); 511 writeCurrentM3u();
512 } 512 }
513 break; 513 break;
514 case 2: { 514 case 2: {
515 QListIterator<DocLnk> dit( vFiles.children() ); 515 QListIterator<DocLnk> dit( vFiles.children() );
516 for ( ; dit.current(); ++dit ) { 516 for ( ; dit.current(); ++dit ) {
517 if( dit.current()->name() == it->text(0)) { 517 if( dit.current()->name() == it->text(0)) {
518 if( QFileInfo( dit.current()->file()).exists() ) 518 if( QFileInfo( dit.current()->file()).exists() )
519 d->selectedFiles->addToSelection( **dit ); 519 d->selectedFiles->addToSelection( **dit );
520 } 520 }
521 } 521 }
522 writeCurrentM3u(); 522 writeCurrentM3u();
523 523
524 } 524 }
525 break; 525 break;
526 case 0: 526 case 0:
527 break; 527 break;
528 }; 528 };
529 tabWidget->setCurrentPage(0); 529 tabWidget->setCurrentPage(0);
530 } 530 }
531} 531}
532 532
@@ -694,88 +694,79 @@ void PlayListWidget::populateVideoView() {
694 storage, Vdit.current()->file()); 694 storage, Vdit.current()->file());
695 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 695 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
696 } 696 }
697 } 697 }
698} 698}
699 699
700 700
701void PlayListWidget::openFile() { 701void PlayListWidget::openFile() {
702 QString filename, name; 702 QString filename, name;
703 InputDialog *fileDlg; 703 InputDialog *fileDlg;
704 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 704 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
705 fileDlg->exec(); 705 fileDlg->exec();
706 if( fileDlg->result() == 1 ) { 706 if( fileDlg->result() == 1 ) {
707 filename = fileDlg->text(); 707 filename = fileDlg->text();
708 qDebug( "Selected filename is " + filename ); 708 qDebug( "Selected filename is " + filename );
709 Om3u *m3uList; 709 Om3u *m3uList;
710 DocLnk lnk; 710 DocLnk lnk;
711 Config cfg( "OpiePlayer" ); 711 Config cfg( "OpiePlayer" );
712 cfg.setGroup("PlayList"); 712 cfg.setGroup("PlayList");
713 713
714 if(filename.left(4) == "http") { 714 if(filename.left(4) == "http") {
715 QString m3uFile, m3uFilePath; 715 QString m3uFile, m3uFilePath;
716 if(filename.find(":",8,TRUE) != -1) { //found a port 716 if(filename.find(":",8,TRUE) != -1) { //found a port
717 m3uFile = filename.left( filename.find( ":",8,TRUE)); 717 m3uFile = filename.left( filename.find( ":",8,TRUE));
718 m3uFile = m3uFile.right( 7); 718 m3uFile = m3uFile.right( 7);
719 } else if(filename.left(4) == "http"){ 719 } else if(filename.left(4) == "http"){
720 m3uFile=filename; 720 m3uFile=filename;
721 m3uFile = m3uFile.right( m3uFile.length() - 7); 721 m3uFile = m3uFile.right( m3uFile.length() - 7);
722 } else{ 722 } else{
723 m3uFile=filename; 723 m3uFile=filename;
724 } 724 }
725 725
726 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 726// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
727 m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite );
728 m3uList->add( filename);
729 m3uList->write();
730 m3uList->close();
731 if(m3uList) delete m3uList;
732 lnk.setName( filename ); //sets name 727 lnk.setName( filename ); //sets name
733 lnk.setFile( filename ); //sets file name 728 lnk.setFile( filename ); //sets file name
734 lnk.setIcon("opieplayer2/musicfile"); 729 lnk.setIcon("opieplayer2/musicfile");
735 d->selectedFiles->addToSelection( lnk ); 730 d->selectedFiles->addToSelection( lnk );
731 writeCurrentM3u();
736 } 732 }
737 else if( filename.right( 3) == "m3u" ) { 733 else if( filename.right( 3) == "m3u" ) {
738 readm3u( filename ); 734 readm3u( filename );
739 735
740 } else if( filename.right(3) == "pls" ) { 736 } else if( filename.right(3) == "pls" ) {
741 readPls( filename ); 737 readPls( filename );
742 } 738 } else {
743 else {
744 m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite );
745 m3uList->add( filename);
746 m3uList->write();
747 m3uList->close();
748 if(m3uList) delete m3uList;
749 d->selectedFiles->addToSelection( DocLnk(filename) ); 739 d->selectedFiles->addToSelection( DocLnk(filename) );
740 writeCurrentM3u();
750 } 741 }
751 } 742 }
752 743
753 if( fileDlg ) { 744 if( fileDlg ) {
754 delete fileDlg; 745 delete fileDlg;
755 } 746 }
756} 747}
757 748
758/* 749/*
759reads m3u and shows files/urls to playlist widget */ 750reads m3u and shows files/urls to playlist widget */
760void PlayListWidget::readm3u( const QString &filename ) { 751void PlayListWidget::readm3u( const QString &filename ) {
761 qDebug( "read m3u filename " + filename ); 752 qDebug( "read m3u filename " + filename );
762 753
763 Om3u *m3uList; 754 Om3u *m3uList;
764 QString s, name; 755 QString s, name;
765 m3uList = new Om3u( filename, IO_ReadOnly ); 756 m3uList = new Om3u( filename, IO_ReadOnly );
766 m3uList->readM3u(); 757 m3uList->readM3u();
767 DocLnk lnk; 758 DocLnk lnk;
768 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 759 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
769 s = *it; 760 s = *it;
770// s.replace( QRegExp( "%20" )," " ); 761// s.replace( QRegExp( "%20" )," " );
771// qDebug("reading "+ s); 762// qDebug("reading "+ s);
772 if(s.left(4)=="http") { 763 if(s.left(4)=="http") {
773 lnk.setName( s ); //sets file name 764 lnk.setName( s ); //sets file name
774 lnk.setFile( s ); //sets file name 765 lnk.setFile( s ); //sets file name
775 lnk.setIcon("opieplayer2/musicfile"); 766 lnk.setIcon("opieplayer2/musicfile");
776 } 767 }
777 else { 768 else {
778 if( QFileInfo( s ).exists() ) { 769 if( QFileInfo( s ).exists() ) {
779 lnk.setName( QFileInfo(s).baseName()); 770 lnk.setName( QFileInfo(s).baseName());
780// qDebug("set link "+s); 771// qDebug("set link "+s);
781 if(s.at(s.length()-4) == '.') //if regular file 772 if(s.at(s.length()-4) == '.') //if regular file
@@ -820,96 +811,96 @@ void PlayListWidget::readPls( const QString &filename ) {
820 QString name = f.baseName(); 811 QString name = f.baseName();
821 812
822 if( name.left( 4 ) == "http" ) { 813 if( name.left( 4 ) == "http" ) {
823 name = s.right( s.length() - 7); 814 name = s.right( s.length() - 7);
824 } else { 815 } else {
825 name = s; 816 name = s;
826 } 817 }
827 818
828 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 819 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
829 820
830 lnk.setName( name ); 821 lnk.setName( name );
831 if( s.at( s.length() - 4) == '.') {// if this is probably a file 822 if( s.at( s.length() - 4) == '.') {// if this is probably a file
832 lnk.setFile( s ); 823 lnk.setFile( s );
833 } else { //if its a url 824 } else { //if its a url
834 if( name.right( 1 ).find( '/' ) == -1) { 825 if( name.right( 1 ).find( '/' ) == -1) {
835 s += "/"; 826 s += "/";
836 } 827 }
837 lnk.setFile( s ); 828 lnk.setFile( s );
838 } 829 }
839 lnk.setType( "audio/x-mpegurl" ); 830 lnk.setType( "audio/x-mpegurl" );
840 831
841 lnk.writeLink(); 832 lnk.writeLink();
842 d->selectedFiles->addToSelection( lnk ); 833 d->selectedFiles->addToSelection( lnk );
843 } 834 }
844 835
845 m3uList->close(); 836 m3uList->close();
846 if(m3uList) delete m3uList; 837 if(m3uList) delete m3uList;
847} 838}
848 839
849/* 840/*
850 writes current playlist to current m3u file */ 841 writes current playlist to current m3u file */
851void PlayListWidget::writeCurrentM3u() { 842void PlayListWidget::writeCurrentM3u() {
852 qDebug("writting to current m3u"); 843 qDebug("writing to current m3u");
853 Config cfg( "OpiePlayer" ); 844 Config cfg( "OpiePlayer" );
854 cfg.setGroup("PlayList"); 845 cfg.setGroup("PlayList");
855 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 846 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
856 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 847 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
857 Om3u *m3uList; 848 Om3u *m3uList;
858 m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate ); 849 m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate );
859 d->selectedFiles->first(); 850 d->selectedFiles->first();
860 851
861 do { 852 do {
862 m3uList->add( d->selectedFiles->current()->file()); 853 m3uList->add( d->selectedFiles->current()->file());
863 } 854 }
864 while ( d->selectedFiles->next() ); 855 while ( d->selectedFiles->next() );
865 // qDebug( list ); 856// qDebug( list );
866 m3uList->write(); 857 m3uList->write();
867 m3uList->close(); 858 m3uList->close();
868 859
869 if(m3uList) delete m3uList; 860 if(m3uList) delete m3uList;
870} 861}
871 862
872 /* 863 /*
873 writes current playlist to m3u file */ 864 writes current playlist to m3u file */
874void PlayListWidget::writem3u() { 865void PlayListWidget::writem3u() {
875 InputDialog *fileDlg; 866 InputDialog *fileDlg;
876 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 867 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
877 fileDlg->exec(); 868 fileDlg->exec();
878 QString name, filename, list; 869 QString name, filename, list;
879 Om3u *m3uList; 870 Om3u *m3uList;
880 871
881 if( fileDlg->result() == 1 ) { 872 if( fileDlg->result() == 1 ) {
882 name = fileDlg->text(); 873 name = fileDlg->text();
883 qDebug( filename ); 874// qDebug( filename );
884 875
885 if( name.left( 1) != "/" ) { 876 if( name.left( 1) != "/" ) {
886 filename = QPEApplication::documentDir() + "/" + name; 877 filename = QPEApplication::documentDir() + "/" + name;
887 } 878 }
888 879
889 if( name.right( 3 ) != "m3u" ) { 880 if( name.right( 3 ) != "m3u" ) {
890 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 881 filename = QPEApplication::documentDir() + "/" +name+".m3u";
891 } 882 }
892 883
893 m3uList = new Om3u(filename, IO_ReadWrite); 884 m3uList = new Om3u(filename, IO_ReadWrite);
894 885
895 d->selectedFiles->first(); 886 d->selectedFiles->first();
896 887
897 do { 888 do {
898 m3uList->add( d->selectedFiles->current()->file()); 889 m3uList->add( d->selectedFiles->current()->file());
899 } 890 }
900 while ( d->selectedFiles->next() ); 891 while ( d->selectedFiles->next() );
901// qDebug( list ); 892// qDebug( list );
902 m3uList->write(); 893 m3uList->write();
903 m3uList->close(); 894 m3uList->close();
904 895
905 } 896 }
906 if(m3uList) delete m3uList; 897 if(m3uList) delete m3uList;
907 if(fileDlg) delete fileDlg; 898 if(fileDlg) delete fileDlg;
908 899
909 DocLnk lnk; 900 DocLnk lnk;
910 lnk.setFile( filename); 901 lnk.setFile( filename);
911 lnk.setIcon("opieplayer2/playlist2"); 902 lnk.setIcon("opieplayer2/playlist2");
912 lnk.setName( name); //sets file name 903 lnk.setName( name); //sets file name
913 904
914// qDebug(filename); 905// qDebug(filename);
915 Config config( "OpiePlayer" ); 906 Config config( "OpiePlayer" );