author | llornkcor <llornkcor> | 2002-10-08 19:37:34 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-08 19:37:34 (UTC) |
commit | b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d (patch) (unidiff) | |
tree | 60246a741e7895f5efe6755c2aee455376ca0939 | |
parent | de9496b2e6e2784dc4cc83dd5800f89f0954affc (diff) | |
download | opie-b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d.zip opie-b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d.tar.gz opie-b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d.tar.bz2 |
more fixes 2
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 25 |
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 | |||
@@ -484,33 +484,33 @@ void PlayListWidget::addSelected() { | |||
484 | void PlayListWidget::removeSelected() { | 484 | void PlayListWidget::removeSelected() { |
485 | d->selectedFiles->removeSelected( ); | 485 | d->selectedFiles->removeSelected( ); |
486 | writeCurrentM3u(); | 486 | writeCurrentM3u(); |
487 | } | 487 | } |
488 | 488 | ||
489 | 489 | ||
490 | void PlayListWidget::playIt( QListViewItem *it) { | 490 | void 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 | ||
498 | void PlayListWidget::addToSelection( QListViewItem *it) { | 498 | void 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 ) { |
@@ -710,56 +710,47 @@ void PlayListWidget::openFile() { | |||
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 | /* |
759 | reads m3u and shows files/urls to playlist widget */ | 750 | reads m3u and shows files/urls to playlist widget */ |
760 | void PlayListWidget::readm3u( const QString &filename ) { | 751 | void 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 ); |
@@ -836,64 +827,64 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
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 */ |
851 | void PlayListWidget::writeCurrentM3u() { | 842 | void 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 */ |
874 | void PlayListWidget::writem3u() { | 865 | void 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 | } |