-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index ac52b07..2df7f27 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -702,203 +702,202 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
702 | // qDebug("reading "+ s); | 702 | // qDebug("reading "+ s); |
703 | if(s.left(4)=="http") { | 703 | if(s.left(4)=="http") { |
704 | lnk.setName( s ); //sets file name | 704 | lnk.setName( s ); //sets file name |
705 | lnk.setIcon("opieplayer2/musicfile"); | 705 | lnk.setIcon("opieplayer2/musicfile"); |
706 | lnk.setFile( s ); //sets file name | 706 | lnk.setFile( s ); //sets file name |
707 | 707 | ||
708 | } else { | 708 | } else { |
709 | // if( QFileInfo( s ).exists() ) { | 709 | // if( QFileInfo( s ).exists() ) { |
710 | lnk.setName( QFileInfo(s).baseName()); | 710 | lnk.setName( QFileInfo(s).baseName()); |
711 | // if(s.right(4) == '.') {//if regular file | 711 | // if(s.right(4) == '.') {//if regular file |
712 | if(s.left(1) != "/") { | 712 | if(s.left(1) != "/") { |
713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
715 | // lnk.setIcon(MimeType(s).pixmap() ); | 715 | // lnk.setIcon(MimeType(s).pixmap() ); |
716 | // lnk.setIcon("SoundPlayer"); | 716 | // lnk.setIcon("SoundPlayer"); |
717 | } else { | 717 | } else { |
718 | // qDebug("set link2 "+s); | 718 | // qDebug("set link2 "+s); |
719 | lnk.setFile( s); | 719 | lnk.setFile( s); |
720 | // lnk.setIcon(MimeType(s).pixmap() ); | 720 | // lnk.setIcon(MimeType(s).pixmap() ); |
721 | // lnk.setIcon("SoundPlayer"); | 721 | // lnk.setIcon("SoundPlayer"); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | d->selectedFiles->addToSelection( lnk ); | 724 | d->selectedFiles->addToSelection( lnk ); |
725 | } | 725 | } |
726 | Config config( "OpiePlayer" ); | 726 | Config config( "OpiePlayer" ); |
727 | config.setGroup( "PlayList" ); | 727 | config.setGroup( "PlayList" ); |
728 | 728 | ||
729 | config.writeEntry("CurrentPlaylist",filename); | 729 | config.writeEntry("CurrentPlaylist",filename); |
730 | config.write(); | 730 | config.write(); |
731 | currentPlayList=filename; | 731 | currentPlayList=filename; |
732 | 732 | ||
733 | // m3uList->write(); | 733 | // m3uList->write(); |
734 | m3uList->close(); | 734 | m3uList->close(); |
735 | delete m3uList; | 735 | delete m3uList; |
736 | 736 | ||
737 | d->selectedFiles->setSelectedItem( s); | 737 | d->selectedFiles->setSelectedItem( s); |
738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
739 | 739 | ||
740 | } | 740 | } |
741 | 741 | ||
742 | /* | 742 | /* |
743 | reads pls and adds files/urls to playlist */ | 743 | reads pls and adds files/urls to playlist */ |
744 | void PlayListWidget::readPls( const QString &filename ) { | 744 | void PlayListWidget::readPls( const QString &filename ) { |
745 | 745 | ||
746 | qDebug( "pls filename is " + filename ); | 746 | qDebug( "pls filename is " + filename ); |
747 | Om3u *m3uList; | 747 | Om3u *m3uList; |
748 | QString s, name; | 748 | QString s, name; |
749 | m3uList = new Om3u( filename, IO_ReadOnly ); | 749 | m3uList = new Om3u( filename, IO_ReadOnly ); |
750 | m3uList->readPls(); | 750 | m3uList->readPls(); |
751 | 751 | ||
752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
753 | s = *it; | 753 | s = *it; |
754 | // s.replace( QRegExp( "%20" )," " ); | 754 | // s.replace( QRegExp( "%20" )," " ); |
755 | DocLnk lnk( s ); | 755 | DocLnk lnk( s ); |
756 | QFileInfo f( s ); | 756 | QFileInfo f( s ); |
757 | QString name = f.baseName(); | 757 | QString name = f.baseName(); |
758 | 758 | ||
759 | if( name.left( 4 ) == "http" ) { | 759 | if( name.left( 4 ) == "http" ) { |
760 | name = s.right( s.length() - 7); | 760 | name = s.right( s.length() - 7); |
761 | } else { | 761 | } else { |
762 | name = s; | 762 | name = s; |
763 | } | 763 | } |
764 | 764 | ||
765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
766 | 766 | ||
767 | lnk.setName( name ); | 767 | lnk.setName( name ); |
768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
769 | lnk.setFile( s ); | 769 | lnk.setFile( s ); |
770 | } else { //if its a url | 770 | } else { //if its a url |
771 | // if( name.right( 1 ).find( '/' ) == -1) { | 771 | // if( name.right( 1 ).find( '/' ) == -1) { |
772 | // s += "/"; | 772 | // s += "/"; |
773 | // } | 773 | // } |
774 | lnk.setFile( s ); | 774 | lnk.setFile( s ); |
775 | } | 775 | } |
776 | lnk.setType( "audio/x-mpegurl" ); | 776 | lnk.setType( "audio/x-mpegurl" ); |
777 | 777 | ||
778 | lnk.writeLink(); | 778 | lnk.writeLink(); |
779 | d->selectedFiles->addToSelection( lnk ); | 779 | d->selectedFiles->addToSelection( lnk ); |
780 | } | 780 | } |
781 | 781 | ||
782 | m3uList->close(); | 782 | m3uList->close(); |
783 | delete m3uList; | 783 | delete m3uList; |
784 | } | 784 | } |
785 | 785 | ||
786 | /* | 786 | /* |
787 | writes current playlist to current m3u file */ | 787 | writes current playlist to current m3u file */ |
788 | void PlayListWidget::writeCurrentM3u() { | 788 | void PlayListWidget::writeCurrentM3u() { |
789 | qDebug("writing to current m3u"); | 789 | qDebug("writing to current m3u"); |
790 | Config cfg( "OpiePlayer" ); | 790 | Config cfg( "OpiePlayer" ); |
791 | cfg.setGroup("PlayList"); | 791 | cfg.setGroup("PlayList"); |
792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
793 | 793 | ||
794 | Om3u *m3uList; | 794 | Om3u *m3uList; |
795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
796 | if( d->selectedFiles->first()) { | 796 | if( d->selectedFiles->first()) { |
797 | 797 | ||
798 | do { | 798 | do { |
799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
800 | m3uList->add( d->selectedFiles->current()->file() ); | 800 | m3uList->add( d->selectedFiles->current()->file() ); |
801 | } | ||
802 | while ( d->selectedFiles->next() ); | ||
803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
804 | m3uList->write(); | ||
805 | m3uList->close(); | ||
801 | } | 806 | } |
802 | while ( d->selectedFiles->next() ); | ||
803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
804 | m3uList->write(); | ||
805 | m3uList->close(); | ||
806 | |||
807 | delete m3uList; | 807 | delete m3uList; |
808 | } | ||
809 | 808 | ||
810 | } | 809 | } |
811 | 810 | ||
812 | /* | 811 | /* |
813 | writes current playlist to m3u file */ | 812 | writes current playlist to m3u file */ |
814 | void PlayListWidget::writem3u() { | 813 | void PlayListWidget::writem3u() { |
815 | InputDialog *fileDlg; | 814 | InputDialog *fileDlg; |
816 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 815 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
817 | fileDlg->exec(); | 816 | fileDlg->exec(); |
818 | QString name, filename, list; | 817 | QString name, filename, list; |
819 | Om3u *m3uList; | 818 | Om3u *m3uList; |
820 | 819 | ||
821 | if( fileDlg->result() == 1 ) { | 820 | if( fileDlg->result() == 1 ) { |
822 | name = fileDlg->text(); | 821 | name = fileDlg->text(); |
823 | // qDebug( filename ); | 822 | // qDebug( filename ); |
824 | 823 | ||
825 | if( name.left( 1) != "/" ) { | 824 | if( name.left( 1) != "/" ) { |
826 | filename = QPEApplication::documentDir() + "/" + name; | 825 | filename = QPEApplication::documentDir() + "/" + name; |
827 | } | 826 | } |
828 | 827 | ||
829 | if( name.right( 3 ) != "m3u" ) { | 828 | if( name.right( 3 ) != "m3u" ) { |
830 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 829 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
831 | } | 830 | } |
832 | 831 | ||
833 | if( d->selectedFiles->first()) { | 832 | if( d->selectedFiles->first()) { |
834 | m3uList = new Om3u(filename, IO_ReadWrite); | 833 | m3uList = new Om3u(filename, IO_ReadWrite); |
835 | 834 | ||
836 | do { | 835 | do { |
837 | m3uList->add( d->selectedFiles->current()->file()); | 836 | m3uList->add( d->selectedFiles->current()->file()); |
838 | } | 837 | } |
839 | while ( d->selectedFiles->next() ); | 838 | while ( d->selectedFiles->next() ); |
840 | // qDebug( list ); | 839 | // qDebug( list ); |
841 | m3uList->write(); | 840 | m3uList->write(); |
842 | m3uList->close(); | 841 | m3uList->close(); |
843 | delete m3uList; | 842 | delete m3uList; |
844 | 843 | ||
845 | delete fileDlg; | 844 | delete fileDlg; |
846 | 845 | ||
847 | DocLnk lnk; | 846 | DocLnk lnk; |
848 | lnk.setFile( filename); | 847 | lnk.setFile( filename); |
849 | lnk.setIcon("opieplayer2/playlist2"); | 848 | lnk.setIcon("opieplayer2/playlist2"); |
850 | lnk.setName( name); //sets file name | 849 | lnk.setName( name); //sets file name |
851 | 850 | ||
852 | // qDebug(filename); | 851 | // qDebug(filename); |
853 | Config config( "OpiePlayer" ); | 852 | Config config( "OpiePlayer" ); |
854 | config.setGroup( "PlayList" ); | 853 | config.setGroup( "PlayList" ); |
855 | 854 | ||
856 | config.writeEntry("CurrentPlaylist",filename); | 855 | config.writeEntry("CurrentPlaylist",filename); |
857 | currentPlayList=filename; | 856 | currentPlayList=filename; |
858 | 857 | ||
859 | if(!lnk.writeLink()) { | 858 | if(!lnk.writeLink()) { |
860 | qDebug("Writing doclink did not work"); | 859 | qDebug("Writing doclink did not work"); |
861 | } | 860 | } |
862 | 861 | ||
863 | setCaption(tr("OpiePlayer: ") + name); | 862 | setCaption(tr("OpiePlayer: ") + name); |
864 | } | 863 | } |
865 | } | 864 | } |
866 | } | 865 | } |
867 | 866 | ||
868 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 867 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
869 | switch ( e->key() ) { | 868 | switch ( e->key() ) { |
870 | ////////////////////////////// Zaurus keys | 869 | ////////////////////////////// Zaurus keys |
871 | case Key_F9: //activity | 870 | case Key_F9: //activity |
872 | // if(audioUI->isHidden()) | 871 | // if(audioUI->isHidden()) |
873 | // audioUI->showMaximized(); | 872 | // audioUI->showMaximized(); |
874 | break; | 873 | break; |
875 | case Key_F10: //contacts | 874 | case Key_F10: //contacts |
876 | // if( videoUI->isHidden()) | 875 | // if( videoUI->isHidden()) |
877 | // videoUI->showMaximized(); | 876 | // videoUI->showMaximized(); |
878 | break; | 877 | break; |
879 | case Key_F11: //menu | 878 | case Key_F11: //menu |
880 | break; | 879 | break; |
881 | case Key_F12: //home | 880 | case Key_F12: //home |
882 | // doBlank(); | 881 | // doBlank(); |
883 | break; | 882 | break; |
884 | case Key_F13: //mail | 883 | case Key_F13: //mail |
885 | // doUnblank(); | 884 | // doUnblank(); |
886 | break; | 885 | break; |
887 | case Key_Q: //add to playlist | 886 | case Key_Q: //add to playlist |
888 | addSelected(); | 887 | addSelected(); |
889 | break; | 888 | break; |
890 | case Key_R: //remove from playlist | 889 | case Key_R: //remove from playlist |
891 | removeSelected(); | 890 | removeSelected(); |
892 | break; | 891 | break; |
893 | // case Key_P: //play | 892 | // case Key_P: //play |
894 | // qDebug("Play"); | 893 | // qDebug("Play"); |
895 | // playSelected(); | 894 | // playSelected(); |
896 | // break; | 895 | // break; |
897 | case Key_Space: | 896 | case Key_Space: |
898 | // playSelected(); puh | 897 | // playSelected(); puh |
899 | break; | 898 | break; |
900 | case Key_1: | 899 | case Key_1: |
901 | tabWidget->setCurrentPage( 0 ); | 900 | tabWidget->setCurrentPage( 0 ); |
902 | break; | 901 | break; |
903 | case Key_2: | 902 | case Key_2: |
904 | tabWidget->setCurrentPage( 1 ); | 903 | tabWidget->setCurrentPage( 1 ); |