summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-07-31 23:56:39 (UTC)
committer harlekin <harlekin>2002-07-31 23:56:39 (UTC)
commitb2978cf32ae5e6954fb118c89c1f70ee05d53ef4 (patch) (unidiff)
treec9a90786a9676014cc1abba61bc0828cf61beb67
parent3a4d367a8e5e9f599e0487326c105de9aa773bfe (diff)
downloadopie-b2978cf32ae5e6954fb118c89c1f70ee05d53ef4.zip
opie-b2978cf32ae5e6954fb118c89c1f70ee05d53ef4.tar.gz
opie-b2978cf32ae5e6954fb118c89c1f70ee05d53ef4.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp5
1 files changed, 0 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 9373f6b..cd53748 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -702,516 +702,511 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
702 tabWidget->setCurrentPage(0); 702 tabWidget->setCurrentPage(0);
703 } 703 }
704} 704}
705 705
706void PlayListWidget::tabChanged(QWidget *widg) { 706void PlayListWidget::tabChanged(QWidget *widg) {
707 707
708 switch ( tabWidget->currentPageIndex()) { 708 switch ( tabWidget->currentPageIndex()) {
709 case 0: 709 case 0:
710 { 710 {
711 if( !tbDeletePlaylist->isHidden()) 711 if( !tbDeletePlaylist->isHidden())
712 tbDeletePlaylist->hide(); 712 tbDeletePlaylist->hide();
713 d->tbRemoveFromList->setEnabled(TRUE); 713 d->tbRemoveFromList->setEnabled(TRUE);
714 d->tbAddToList->setEnabled(FALSE); 714 d->tbAddToList->setEnabled(FALSE);
715 } 715 }
716 break; 716 break;
717 case 1: 717 case 1:
718 { 718 {
719 audioView->clear(); 719 audioView->clear();
720 populateAudioView(); 720 populateAudioView();
721 721
722 if( !tbDeletePlaylist->isHidden()) 722 if( !tbDeletePlaylist->isHidden())
723 tbDeletePlaylist->hide(); 723 tbDeletePlaylist->hide();
724 d->tbRemoveFromList->setEnabled(FALSE); 724 d->tbRemoveFromList->setEnabled(FALSE);
725 d->tbAddToList->setEnabled(TRUE); 725 d->tbAddToList->setEnabled(TRUE);
726 } 726 }
727 break; 727 break;
728 case 2: 728 case 2:
729 { 729 {
730 videoView->clear(); 730 videoView->clear();
731 populateVideoView(); 731 populateVideoView();
732 if( !tbDeletePlaylist->isHidden()) 732 if( !tbDeletePlaylist->isHidden())
733 tbDeletePlaylist->hide(); 733 tbDeletePlaylist->hide();
734 d->tbRemoveFromList->setEnabled(FALSE); 734 d->tbRemoveFromList->setEnabled(FALSE);
735 d->tbAddToList->setEnabled(TRUE); 735 d->tbAddToList->setEnabled(TRUE);
736 } 736 }
737 break; 737 break;
738 case 3: 738 case 3:
739 { 739 {
740 if( tbDeletePlaylist->isHidden()) 740 if( tbDeletePlaylist->isHidden())
741 tbDeletePlaylist->show(); 741 tbDeletePlaylist->show();
742 playLists->reread(); 742 playLists->reread();
743 } 743 }
744 break; 744 break;
745 }; 745 };
746} 746}
747 747
748void PlayListWidget::btnPlay(bool b) { 748void PlayListWidget::btnPlay(bool b) {
749 749
750// mediaPlayerState->setPlaying(b); 750// mediaPlayerState->setPlaying(b);
751 switch ( tabWidget->currentPageIndex()) { 751 switch ( tabWidget->currentPageIndex()) {
752 case 0: 752 case 0:
753 { 753 {
754 mediaPlayerState->setPlaying(b); 754 mediaPlayerState->setPlaying(b);
755 } 755 }
756 break; 756 break;
757 case 1: 757 case 1:
758 { 758 {
759 addToSelection( audioView->currentItem() ); 759 addToSelection( audioView->currentItem() );
760 mediaPlayerState->setPlaying(b); 760 mediaPlayerState->setPlaying(b);
761 d->selectedFiles->removeSelected( ); 761 d->selectedFiles->removeSelected( );
762 tabWidget->setCurrentPage(1); 762 tabWidget->setCurrentPage(1);
763 d->selectedFiles->unSelect(); 763 d->selectedFiles->unSelect();
764 insanityBool=FALSE; 764 insanityBool=FALSE;
765 }// audioView->clearSelection(); 765 }// audioView->clearSelection();
766 break; 766 break;
767 case 2: 767 case 2:
768 { 768 {
769 addToSelection( videoView->currentItem() ); 769 addToSelection( videoView->currentItem() );
770 mediaPlayerState->setPlaying(b); 770 mediaPlayerState->setPlaying(b);
771 qApp->processEvents(); 771 qApp->processEvents();
772 d->selectedFiles->removeSelected( ); 772 d->selectedFiles->removeSelected( );
773 tabWidget->setCurrentPage(2); 773 tabWidget->setCurrentPage(2);
774 d->selectedFiles->unSelect(); 774 d->selectedFiles->unSelect();
775 insanityBool=FALSE; 775 insanityBool=FALSE;
776 }// videoView->clearSelection(); 776 }// videoView->clearSelection();
777 break; 777 break;
778 }; 778 };
779 779
780} 780}
781 781
782void PlayListWidget::deletePlaylist() { 782void PlayListWidget::deletePlaylist() {
783 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 783 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
784 (tr("You really want to delete\nthis playlist?")), 784 (tr("You really want to delete\nthis playlist?")),
785 (tr("Yes")), (tr("No")), 0 )){ 785 (tr("Yes")), (tr("No")), 0 )){
786 case 0: // Yes clicked, 786 case 0: // Yes clicked,
787 QFile().remove(playLists->selected()->file()); 787 QFile().remove(playLists->selected()->file());
788 QFile().remove(playLists->selected()->linkFile()); 788 QFile().remove(playLists->selected()->linkFile());
789 playLists->reread(); 789 playLists->reread();
790 break; 790 break;
791 case 1: // Cancel 791 case 1: // Cancel
792 break; 792 break;
793 }; 793 };
794} 794}
795 795
796void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { 796void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) {
797 switch (mouse) { 797 switch (mouse) {
798 case 1: 798 case 1:
799 break; 799 break;
800 case 2:{ 800 case 2:{
801 QPopupMenu m; 801 QPopupMenu m;
802 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 802 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
803 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 803 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
804 m.insertSeparator(); 804 m.insertSeparator();
805 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 805 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
806 m.exec( QCursor::pos() ); 806 m.exec( QCursor::pos() );
807 } 807 }
808 break; 808 break;
809 }; 809 };
810} 810}
811 811
812void PlayListWidget::playSelected() { 812void PlayListWidget::playSelected() {
813 btnPlay( TRUE); 813 btnPlay( TRUE);
814} 814}
815 815
816void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { 816void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) {
817 switch (mouse) { 817 switch (mouse) {
818 case 1: 818 case 1:
819 819
820 break; 820 break;
821 case 2: 821 case 2:
822 { 822 {
823 QPopupMenu m; 823 QPopupMenu m;
824 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 824 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
825 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 825 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
826 m.exec( QCursor::pos() ); 826 m.exec( QCursor::pos() );
827 } 827 }
828 break; 828 break;
829 }; 829 };
830} 830}
831 831
832void PlayListWidget::listDelete() { 832void PlayListWidget::listDelete() {
833 Config cfg( "OpiePlayer" ); 833 Config cfg( "OpiePlayer" );
834 cfg.setGroup("PlayList"); 834 cfg.setGroup("PlayList");
835 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 835 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
836 QString file; 836 QString file;
837 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 837 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
838 switch ( tabWidget->currentPageIndex()) { 838 switch ( tabWidget->currentPageIndex()) {
839 case 0: 839 case 0:
840 break; 840 break;
841 case 1: 841 case 1:
842 { 842 {
843 file = audioView->selectedItem()->text(0); 843 file = audioView->selectedItem()->text(0);
844 QListIterator<DocLnk> dit( files.children() ); 844 QListIterator<DocLnk> dit( files.children() );
845 for ( ; dit.current(); ++dit ) { 845 for ( ; dit.current(); ++dit ) {
846 if( dit.current()->name() == file) { 846 if( dit.current()->name() == file) {
847 // qDebug(file); 847 // qDebug(file);
848 LnkProperties prop( dit.current() ); 848 LnkProperties prop( dit.current() );
849 prop.showMaximized(); 849 prop.showMaximized();
850 prop.exec(); 850 prop.exec();
851 } 851 }
852 } 852 }
853 populateAudioView(); 853 populateAudioView();
854 } 854 }
855 break; 855 break;
856 case 2: 856 case 2:
857 { 857 {
858 858
859 } 859 }
860 break; 860 break;
861 }; 861 };
862} 862}
863 863
864void PlayListWidget::scanForAudio() { 864void PlayListWidget::scanForAudio() {
865 qDebug("scan for audio"); 865 qDebug("scan for audio");
866 files.detachChildren(); 866 files.detachChildren();
867 QListIterator<DocLnk> sdit( files.children() ); 867 QListIterator<DocLnk> sdit( files.children() );
868 for ( ; sdit.current(); ++sdit ) { 868 for ( ; sdit.current(); ++sdit ) {
869 delete sdit.current(); 869 delete sdit.current();
870 } 870 }
871 Global::findDocuments(&files, "audio/*"); 871 Global::findDocuments(&files, "audio/*");
872 audioScan = TRUE; 872 audioScan = TRUE;
873} 873}
874void PlayListWidget::scanForVideo() { 874void PlayListWidget::scanForVideo() {
875 qDebug("scan for video"); 875 qDebug("scan for video");
876 vFiles.detachChildren(); 876 vFiles.detachChildren();
877 QListIterator<DocLnk> sdit( vFiles.children() ); 877 QListIterator<DocLnk> sdit( vFiles.children() );
878 for ( ; sdit.current(); ++sdit ) { 878 for ( ; sdit.current(); ++sdit ) {
879 delete sdit.current(); 879 delete sdit.current();
880 } 880 }
881 Global::findDocuments(&vFiles, "video/*"); 881 Global::findDocuments(&vFiles, "video/*");
882 videoScan = TRUE; 882 videoScan = TRUE;
883} 883}
884 884
885void PlayListWidget::populateAudioView() { 885void PlayListWidget::populateAudioView() {
886 886
887 audioView->clear(); 887 audioView->clear();
888 StorageInfo storageInfo; 888 StorageInfo storageInfo;
889 const QList<FileSystem> &fs = storageInfo.fileSystems(); 889 const QList<FileSystem> &fs = storageInfo.fileSystems();
890 if(!audioScan) scanForAudio(); 890 if(!audioScan) scanForAudio();
891 891
892 QListIterator<DocLnk> dit( files.children() ); 892 QListIterator<DocLnk> dit( files.children() );
893 QListIterator<FileSystem> it ( fs ); 893 QListIterator<FileSystem> it ( fs );
894 894
895 QString storage; 895 QString storage;
896 for ( ; dit.current(); ++dit ) { 896 for ( ; dit.current(); ++dit ) {
897 for( ; it.current(); ++it ){ 897 for( ; it.current(); ++it ){
898 const QString name = (*it)->name(); 898 const QString name = (*it)->name();
899 const QString path = (*it)->path(); 899 const QString path = (*it)->path();
900 if(dit.current()->file().find(path) != -1 ) storage=name; 900 if(dit.current()->file().find(path) != -1 ) storage=name;
901 } 901 }
902 902
903 QListViewItem * newItem; 903 QListViewItem * newItem;
904 if ( QFile( dit.current()->file()).exists() ) { 904 if ( QFile( dit.current()->file()).exists() ) {
905 // qDebug(dit.current()->name()); 905 // qDebug(dit.current()->name());
906 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 906 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
907 QString::number( QFile( dit.current()->file()).size() ), storage); 907 QString::number( QFile( dit.current()->file()).size() ), storage);
908 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 908 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
909 } 909 }
910 } 910 }
911 911
912} 912}
913 913
914void PlayListWidget::populateVideoView() { 914void PlayListWidget::populateVideoView() {
915 videoView->clear(); 915 videoView->clear();
916 StorageInfo storageInfo; 916 StorageInfo storageInfo;
917 const QList<FileSystem> &fs = storageInfo.fileSystems(); 917 const QList<FileSystem> &fs = storageInfo.fileSystems();
918 918
919 if(!videoScan ) scanForVideo(); 919 if(!videoScan ) scanForVideo();
920 920
921 QListIterator<DocLnk> Vdit( vFiles.children() ); 921 QListIterator<DocLnk> Vdit( vFiles.children() );
922 QListIterator<FileSystem> it ( fs ); 922 QListIterator<FileSystem> it ( fs );
923 videoView->clear(); 923 videoView->clear();
924 QString storage; 924 QString storage;
925 for ( ; Vdit.current(); ++Vdit ) { 925 for ( ; Vdit.current(); ++Vdit ) {
926 for( ; it.current(); ++it ){ 926 for( ; it.current(); ++it ){
927 const QString name = (*it)->name(); 927 const QString name = (*it)->name();
928 const QString path = (*it)->path(); 928 const QString path = (*it)->path();
929 if( Vdit.current()->file().find(path) != -1 ) storage=name; 929 if( Vdit.current()->file().find(path) != -1 ) storage=name;
930 } 930 }
931 931
932 QListViewItem * newItem; 932 QListViewItem * newItem;
933 if ( QFile( Vdit.current()->file()).exists() ) { 933 if ( QFile( Vdit.current()->file()).exists() ) {
934 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 934 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
935 QString::number( QFile( Vdit.current()->file()).size() ), storage); 935 QString::number( QFile( Vdit.current()->file()).size() ), storage);
936 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 936 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
937 } 937 }
938 } 938 }
939} 939}
940 940
941void PlayListWidget::openFile() { 941void PlayListWidget::openFile() {
942 QString filename, name; 942 QString filename, name;
943 InputDialog *fileDlg; 943 InputDialog *fileDlg;
944 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 944 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
945 fileDlg->exec(); 945 fileDlg->exec();
946 if( fileDlg->result() == 1 ) { 946 if( fileDlg->result() == 1 ) {
947 filename = fileDlg->LineEdit1->text(); 947 filename = fileDlg->LineEdit1->text();
948 948
949 qDebug("Selected filename is "+filename); 949 qDebug("Selected filename is "+filename);
950 if(filename.right(3) == "m3u") { 950 if(filename.right(3) == "m3u") {
951 readm3u( filename ); 951 readm3u( filename );
952 } else if(filename.right(3) == "pls") { 952 } else if(filename.right(3) == "pls") {
953 readPls( filename ); 953 readPls( filename );
954 } else { 954 } else {
955 DocLnk lnk; 955 DocLnk lnk;
956 956
957 lnk.setName(filename); //sets file name 957 lnk.setName(filename); //sets file name
958 // probably not needed anymore either
959 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") {
960 filename += "/";
961 }
962 lnk.setFile(filename); //sets File property 958 lnk.setFile(filename); //sets File property
963
964 lnk.setType("audio/x-mpegurl"); 959 lnk.setType("audio/x-mpegurl");
965 lnk.setExec("opieplayer"); 960 lnk.setExec("opieplayer");
966 lnk.setIcon("opieplayer/MPEGPlayer"); 961 lnk.setIcon("opieplayer/MPEGPlayer");
967 962
968 if(!lnk.writeLink()) { 963 if(!lnk.writeLink()) {
969 qDebug("Writing doclink did not work"); 964 qDebug("Writing doclink did not work");
970 } 965 }
971 d->selectedFiles->addToSelection( lnk); 966 d->selectedFiles->addToSelection( lnk);
972 } 967 }
973 } 968 }
974 if(fileDlg) { 969 if(fileDlg) {
975 delete fileDlg; 970 delete fileDlg;
976 } 971 }
977} 972}
978 973
979void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 974void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
980{ 975{
981 switch ( e->key() ) { 976 switch ( e->key() ) {
982////////////////////////////// Zaurus keys 977////////////////////////////// Zaurus keys
983 case Key_F9: //activity 978 case Key_F9: //activity
984// if(audioUI->isHidden()) 979// if(audioUI->isHidden())
985// audioUI->showMaximized(); 980// audioUI->showMaximized();
986 break; 981 break;
987 case Key_F10: //contacts 982 case Key_F10: //contacts
988// if( videoUI->isHidden()) 983// if( videoUI->isHidden())
989// videoUI->showMaximized(); 984// videoUI->showMaximized();
990 break; 985 break;
991 case Key_F11: //menu 986 case Key_F11: //menu
992 break; 987 break;
993 case Key_F12: //home 988 case Key_F12: //home
994// doBlank(); 989// doBlank();
995 break; 990 break;
996 case Key_F13: //mail 991 case Key_F13: //mail
997// doUnblank(); 992// doUnblank();
998 break; 993 break;
999 case Key_Q: //add to playlist 994 case Key_Q: //add to playlist
1000 qDebug("Add"); 995 qDebug("Add");
1001 addSelected(); 996 addSelected();
1002 break; 997 break;
1003 case Key_R: //remove from playlist 998 case Key_R: //remove from playlist
1004 removeSelected(); 999 removeSelected();
1005 break; 1000 break;
1006// case Key_P: //play 1001// case Key_P: //play
1007// qDebug("Play"); 1002// qDebug("Play");
1008// playSelected(); 1003// playSelected();
1009// break; 1004// break;
1010 case Key_Space: 1005 case Key_Space:
1011 qDebug("Play"); 1006 qDebug("Play");
1012// playSelected(); puh 1007// playSelected(); puh
1013 break; 1008 break;
1014 case Key_1: 1009 case Key_1:
1015 tabWidget->setCurrentPage(0); 1010 tabWidget->setCurrentPage(0);
1016 break; 1011 break;
1017 case Key_2: 1012 case Key_2:
1018 tabWidget->setCurrentPage(1); 1013 tabWidget->setCurrentPage(1);
1019 break; 1014 break;
1020 case Key_3: 1015 case Key_3:
1021 tabWidget->setCurrentPage(2); 1016 tabWidget->setCurrentPage(2);
1022 break; 1017 break;
1023 case Key_4: 1018 case Key_4:
1024 tabWidget->setCurrentPage(3); 1019 tabWidget->setCurrentPage(3);
1025 break; 1020 break;
1026 case Key_Down: 1021 case Key_Down:
1027 if ( !d->selectedFiles->next() ) 1022 if ( !d->selectedFiles->next() )
1028 d->selectedFiles->first(); 1023 d->selectedFiles->first();
1029 1024
1030 break; 1025 break;
1031 case Key_Up: 1026 case Key_Up:
1032 if ( !d->selectedFiles->prev() ) 1027 if ( !d->selectedFiles->prev() )
1033 // d->selectedFiles->last(); 1028 // d->selectedFiles->last();
1034 1029
1035 break; 1030 break;
1036 1031
1037 } 1032 }
1038} 1033}
1039 1034
1040void PlayListWidget::keyPressEvent( QKeyEvent *e) 1035void PlayListWidget::keyPressEvent( QKeyEvent *e)
1041{ 1036{
1042// qDebug("Key press"); 1037// qDebug("Key press");
1043// switch ( e->key() ) { 1038// switch ( e->key() ) {
1044// ////////////////////////////// Zaurus keys 1039// ////////////////////////////// Zaurus keys
1045// case Key_A: //add to playlist 1040// case Key_A: //add to playlist
1046// qDebug("Add"); 1041// qDebug("Add");
1047// addSelected(); 1042// addSelected();
1048// break; 1043// break;
1049// case Key_R: //remove from playlist 1044// case Key_R: //remove from playlist
1050// removeSelected(); 1045// removeSelected();
1051// break; 1046// break;
1052// case Key_P: //play 1047// case Key_P: //play
1053// qDebug("Play"); 1048// qDebug("Play");
1054// playSelected(); 1049// playSelected();
1055// break; 1050// break;
1056// case Key_Space: 1051// case Key_Space:
1057// qDebug("Play"); 1052// qDebug("Play");
1058// playSelected(); 1053// playSelected();
1059// break; 1054// break;
1060// } 1055// }
1061} 1056}
1062 1057
1063void PlayListWidget::doBlank() { 1058void PlayListWidget::doBlank() {
1064 qDebug("do blanking"); 1059 qDebug("do blanking");
1065 fd=open("/dev/fb0",O_RDWR); 1060 fd=open("/dev/fb0",O_RDWR);
1066 if (fd != -1) { 1061 if (fd != -1) {
1067 ioctl(fd,FBIOBLANK,1); 1062 ioctl(fd,FBIOBLANK,1);
1068// close(fd); 1063// close(fd);
1069 } 1064 }
1070} 1065}
1071 1066
1072void PlayListWidget::doUnblank() { 1067void PlayListWidget::doUnblank() {
1073 // this crashes opieplayer with a segfault 1068 // this crashes opieplayer with a segfault
1074 // int fd; 1069 // int fd;
1075 // fd=open("/dev/fb0",O_RDWR); 1070 // fd=open("/dev/fb0",O_RDWR);
1076 qDebug("do unblanking"); 1071 qDebug("do unblanking");
1077 if (fd != -1) { 1072 if (fd != -1) {
1078 ioctl(fd,FBIOBLANK,0); 1073 ioctl(fd,FBIOBLANK,0);
1079 close(fd); 1074 close(fd);
1080 } 1075 }
1081 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1076 QCopEnvelope h("QPE/System", "setBacklight(int)");
1082 h <<-3;// v[1]; // -3 Force on 1077 h <<-3;// v[1]; // -3 Force on
1083} 1078}
1084 1079
1085void PlayListWidget::readm3u(const QString &filename) { 1080void PlayListWidget::readm3u(const QString &filename) {
1086 1081
1087 qDebug("m3u filename is "+filename); 1082 qDebug("m3u filename is "+filename);
1088 QFile f(filename); 1083 QFile f(filename);
1089 1084
1090 if(f.open(IO_ReadOnly)) { 1085 if(f.open(IO_ReadOnly)) {
1091 QTextStream t(&f); 1086 QTextStream t(&f);
1092 QString s;//, first, second; 1087 QString s;//, first, second;
1093 int i=0; 1088 int i=0;
1094 while ( !t.atEnd()) { 1089 while ( !t.atEnd()) {
1095 s=t.readLine(); 1090 s=t.readLine();
1096 1091
1097 if(s.find("#",0,TRUE) == -1) { 1092 if(s.find("#",0,TRUE) == -1) {
1098 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1093 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1099 if(s.left(2) == "E:" || s.left(2) == "P:") { 1094 if(s.left(2) == "E:" || s.left(2) == "P:") {
1100 s=s.right(s.length()-2); 1095 s=s.right(s.length()-2);
1101 DocLnk lnk( s ); 1096 DocLnk lnk( s );
1102 QFileInfo f(s); 1097 QFileInfo f(s);
1103 QString name = f.baseName(); 1098 QString name = f.baseName();
1104 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); 1099 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
1105 lnk.setName( name ); 1100 lnk.setName( name );
1106 s=s.replace( QRegExp("\\"),"/"); 1101 s=s.replace( QRegExp("\\"),"/");
1107 lnk.setFile( s ); 1102 lnk.setFile( s );
1108 lnk.writeLink(); 1103 lnk.writeLink();
1109 qDebug("add "+name); 1104 qDebug("add "+name);
1110 d->selectedFiles->addToSelection( lnk); 1105 d->selectedFiles->addToSelection( lnk);
1111 } else { // is url 1106 } else { // is url
1112 s.replace(QRegExp("%20")," "); 1107 s.replace(QRegExp("%20")," ");
1113 DocLnk lnk( s ); 1108 DocLnk lnk( s );
1114 QString name; 1109 QString name;
1115 if(name.left(4)=="http") { 1110 if(name.left(4)=="http") {
1116 name = s.right( s.length() - 7); 1111 name = s.right( s.length() - 7);
1117 } else { 1112 } else {
1118 name = s; 1113 name = s;
1119 } 1114 }
1120 lnk.setName(name); 1115 lnk.setName(name);
1121 if(s.at(s.length()-4) == '.') { 1116 if(s.at(s.length()-4) == '.') {
1122 lnk.setFile( s); 1117 lnk.setFile( s);
1123 } else { 1118 } else {
1124 lnk.setFile( s+"/"); 1119 lnk.setFile( s+"/");
1125 } 1120 }
1126 lnk.setType("audio/x-mpegurl"); 1121 lnk.setType("audio/x-mpegurl");
1127 lnk.writeLink(); 1122 lnk.writeLink();
1128 d->selectedFiles->addToSelection( lnk); 1123 d->selectedFiles->addToSelection( lnk);
1129 } 1124 }
1130 i++; 1125 i++;
1131 } 1126 }
1132 } 1127 }
1133 } 1128 }
1134 } 1129 }
1135 f.close(); 1130 f.close();
1136} 1131}
1137 1132
1138void PlayListWidget::writem3u() { 1133void PlayListWidget::writem3u() {
1139 1134
1140 InputDialog *fileDlg; 1135 InputDialog *fileDlg;
1141 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 1136 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1142 fileDlg->exec(); 1137 fileDlg->exec();
1143 QString filename,list; 1138 QString filename,list;
1144 if( fileDlg->result() == 1 ) { 1139 if( fileDlg->result() == 1 ) {
1145 filename = fileDlg->LineEdit1->text(); 1140 filename = fileDlg->LineEdit1->text();
1146 qDebug(filename); 1141 qDebug(filename);
1147 int noOfFiles = 0; 1142 int noOfFiles = 0;
1148 d->selectedFiles->first(); 1143 d->selectedFiles->first();
1149 do { 1144 do {
1150 // we dont check for existance because of url's 1145 // we dont check for existance because of url's
1151 // qDebug(d->selectedFiles->current()->file()); 1146 // qDebug(d->selectedFiles->current()->file());
1152 list += d->selectedFiles->current()->file()+"\n"; 1147 list += d->selectedFiles->current()->file()+"\n";
1153 noOfFiles++; 1148 noOfFiles++;
1154 } 1149 }
1155 while ( d->selectedFiles->next() ); 1150 while ( d->selectedFiles->next() );
1156 qDebug(list); 1151 qDebug(list);
1157 if(filename.left(1) != "/") 1152 if(filename.left(1) != "/")
1158 filename=QPEApplication::documentDir()+"/"+filename; 1153 filename=QPEApplication::documentDir()+"/"+filename;
1159 if(filename.right(3) != "m3u") 1154 if(filename.right(3) != "m3u")
1160 filename=filename+".m3u"; 1155 filename=filename+".m3u";
1161 1156
1162 QFile f(filename); 1157 QFile f(filename);
1163 f.open(IO_WriteOnly); 1158 f.open(IO_WriteOnly);
1164 f.writeBlock(list, list.length()); 1159 f.writeBlock(list, list.length());
1165 f.close(); 1160 f.close();
1166 } 1161 }
1167 if(fileDlg) delete fileDlg; 1162 if(fileDlg) delete fileDlg;
1168} 1163}
1169 1164
1170void PlayListWidget::readPls(const QString &filename) { 1165void PlayListWidget::readPls(const QString &filename) {
1171 1166
1172 qDebug("pls filename is "+filename); 1167 qDebug("pls filename is "+filename);
1173 QFile f(filename); 1168 QFile f(filename);
1174 1169
1175 if(f.open(IO_ReadOnly)) { 1170 if(f.open(IO_ReadOnly)) {
1176 QTextStream t(&f); 1171 QTextStream t(&f);
1177 QString s;//, first, second; 1172 QString s;//, first, second;
1178 int i=0; 1173 int i=0;
1179 while ( !t.atEnd()) { 1174 while ( !t.atEnd()) {
1180 s=t.readLine(); 1175 s=t.readLine();
1181 if(s.left(4) == "File") { 1176 if(s.left(4) == "File") {
1182 s=s.right(s.length() - 6); 1177 s=s.right(s.length() - 6);
1183 s.replace(QRegExp("%20")," "); 1178 s.replace(QRegExp("%20")," ");
1184 qDebug("adding "+s+" to playlist"); 1179 qDebug("adding "+s+" to playlist");
1185 // numberofentries=2 1180 // numberofentries=2
1186 // File1=http 1181 // File1=http
1187 // Title 1182 // Title
1188 // Length 1183 // Length
1189 // Version 1184 // Version
1190 // File2=http 1185 // File2=http
1191 s=s.replace( QRegExp("\\"),"/"); 1186 s=s.replace( QRegExp("\\"),"/");
1192 DocLnk lnk( s ); 1187 DocLnk lnk( s );
1193 QFileInfo f(s); 1188 QFileInfo f(s);
1194 QString name = f.baseName(); 1189 QString name = f.baseName();
1195 if(name.left(4)=="http") 1190 if(name.left(4)=="http")
1196 name = s.right( s.length() - 7); 1191 name = s.right( s.length() - 7);
1197 else 1192 else
1198 name=s; 1193 name=s;
1199 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1194 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1200 lnk.setName( name); 1195 lnk.setName( name);
1201 if(s.at(s.length()-4) == '.') // if this is probably a file 1196 if(s.at(s.length()-4) == '.') // if this is probably a file
1202 lnk.setFile( s); 1197 lnk.setFile( s);
1203 else { //if its a url 1198 else { //if its a url
1204 if( name.right(1).find('/') == -1) 1199 if( name.right(1).find('/') == -1)
1205 s+="/"; 1200 s+="/";
1206 lnk.setFile( s); 1201 lnk.setFile( s);
1207 } 1202 }
1208 lnk.setType("audio/x-mpegurl"); 1203 lnk.setType("audio/x-mpegurl");
1209 1204
1210 qDebug("DocLnk add "+name); 1205 qDebug("DocLnk add "+name);
1211 d->selectedFiles->addToSelection( lnk); 1206 d->selectedFiles->addToSelection( lnk);
1212 } 1207 }
1213 } 1208 }
1214 i++; 1209 i++;
1215 } 1210 }
1216} 1211}
1217 1212