summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 299181b..8b295b0 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -807,567 +807,577 @@ void PlayListWidget::tabChanged(QWidget *) {
807 case 3: 807 case 3:
808 { 808 {
809 if( tbDeletePlaylist->isHidden()) 809 if( tbDeletePlaylist->isHidden())
810 tbDeletePlaylist->show(); 810 tbDeletePlaylist->show();
811 playLists->reread(); 811 playLists->reread();
812 } 812 }
813 break; 813 break;
814 }; 814 };
815} 815}
816 816
817void PlayListWidget::btnPlay(bool b) { 817void PlayListWidget::btnPlay(bool b) {
818 qDebug("<<<<<<<<<<<<<<<BtnPlay"); 818 qDebug("<<<<<<<<<<<<<<<BtnPlay");
819// mediaPlayerState->setPlaying(b); 819// mediaPlayerState->setPlaying(b);
820 switch ( tabWidget->currentPageIndex()) { 820 switch ( tabWidget->currentPageIndex()) {
821 case 0: 821 case 0:
822 { 822 {
823 qDebug("1"); 823 qDebug("1");
824// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 824// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
825// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 825// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
826// QMessageBox::message("Note","You are trying to play\na malformed url."); 826// QMessageBox::message("Note","You are trying to play\na malformed url.");
827// } else { 827// } else {
828 mediaPlayerState->setPlaying(b); 828 mediaPlayerState->setPlaying(b);
829 insanityBool=FALSE; 829 insanityBool=FALSE;
830 qDebug("insanity"); 830 qDebug("insanity");
831// } 831// }
832 } 832 }
833 break; 833 break;
834 case 1: 834 case 1:
835 { 835 {
836 qDebug("2"); 836 qDebug("2");
837// d->selectedFiles->unSelect(); 837// d->selectedFiles->unSelect();
838 addToSelection( audioView->currentItem() ); 838 addToSelection( audioView->currentItem() );
839 mediaPlayerState->setPlaying(true); 839 mediaPlayerState->setPlaying(true);
840 d->selectedFiles->removeSelected( ); 840 d->selectedFiles->removeSelected( );
841 d->selectedFiles->unSelect(); 841 d->selectedFiles->unSelect();
842 tabWidget->setCurrentPage(1); 842 tabWidget->setCurrentPage(1);
843 insanityBool=FALSE; 843 insanityBool=FALSE;
844 }// audioView->clearSelection(); 844 }// audioView->clearSelection();
845 break; 845 break;
846 case 2: 846 case 2:
847 { 847 {
848 qDebug("3"); 848 qDebug("3");
849 849
850 addToSelection( videoView->currentItem() ); 850 addToSelection( videoView->currentItem() );
851 mediaPlayerState->setPlaying(true); 851 mediaPlayerState->setPlaying(true);
852// qApp->processEvents(); 852// qApp->processEvents();
853 d->selectedFiles->removeSelected( ); 853 d->selectedFiles->removeSelected( );
854 d->selectedFiles->unSelect(); 854 d->selectedFiles->unSelect();
855 tabWidget->setCurrentPage(2); 855 tabWidget->setCurrentPage(2);
856 insanityBool=FALSE; 856 insanityBool=FALSE;
857 }// videoView->clearSelection(); 857 }// videoView->clearSelection();
858 break; 858 break;
859 }; 859 };
860 860
861} 861}
862 862
863void PlayListWidget::deletePlaylist() { 863void PlayListWidget::deletePlaylist() {
864 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 864 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
865 (tr("You really want to delete\nthis playlist?")), 865 (tr("You really want to delete\nthis playlist?")),
866 (tr("Yes")), (tr("No")), 0 )){ 866 (tr("Yes")), (tr("No")), 0 )){
867 case 0: // Yes clicked, 867 case 0: // Yes clicked,
868 QFile().remove(playLists->selectedDocument().file()); 868 QFile().remove(playLists->selectedDocument().file());
869 QFile().remove(playLists->selectedDocument().linkFile()); 869 QFile().remove(playLists->selectedDocument().linkFile());
870 playLists->reread(); 870 playLists->reread();
871 break; 871 break;
872 case 1: // Cancel 872 case 1: // Cancel
873 break; 873 break;
874 }; 874 };
875} 875}
876 876
877void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 877void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
878{ 878{
879 switch (mouse) { 879 switch (mouse) {
880 case 1: 880 case 1:
881 break; 881 break;
882 case 2:{ 882 case 2:{
883 883
884 QPopupMenu m; 884 QPopupMenu m;
885 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 885 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
886 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 886 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
887 m.insertSeparator(); 887 m.insertSeparator();
888 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 888 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
889 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 889 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
890 890
891 m.exec( QCursor::pos() ); 891 m.exec( QCursor::pos() );
892 } 892 }
893 break; 893 break;
894 }; 894 };
895} 895}
896 896
897void PlayListWidget::playSelected() 897void PlayListWidget::playSelected()
898{ 898{
899 qDebug("playSelected"); 899 qDebug("playSelected");
900 btnPlay( true); 900 btnPlay( true);
901// d->selectedFiles->unSelect(); 901// d->selectedFiles->unSelect();
902} 902}
903 903
904void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 904void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
905{ 905{
906 switch (mouse) { 906 switch (mouse) {
907 case 1: 907 case 1:
908 908
909 break; 909 break;
910 case 2:{ 910 case 2:{
911 QPopupMenu m; 911 QPopupMenu m;
912 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 912 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
913 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 913 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
914// m.insertSeparator(); 914// m.insertSeparator();
915// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 915// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
916 m.exec( QCursor::pos() ); 916 m.exec( QCursor::pos() );
917 } 917 }
918 break; 918 break;
919 }; 919 };
920 920
921} 921}
922 922
923void PlayListWidget::listDelete() { 923void PlayListWidget::listDelete() {
924 Config cfg( "OpiePlayer" ); 924 Config cfg( "OpiePlayer" );
925 cfg.setGroup("PlayList"); 925 cfg.setGroup("PlayList");
926 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 926 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
927 QString file; 927 QString file;
928// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 928// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
929 switch ( tabWidget->currentPageIndex()) { 929 switch ( tabWidget->currentPageIndex()) {
930 case 0: 930 case 0:
931 break; 931 break;
932 case 1: 932 case 1:
933 { 933 {
934 file = audioView->currentItem()->text(0); 934 file = audioView->currentItem()->text(0);
935 QListIterator<DocLnk> Pdit( files.children() ); 935 QListIterator<DocLnk> Pdit( files.children() );
936 for ( ; Pdit.current(); ++Pdit ) { 936 for ( ; Pdit.current(); ++Pdit ) {
937 if( Pdit.current()->name() == file) { 937 if( Pdit.current()->name() == file) {
938 LnkProperties prop( Pdit.current() ); 938 LnkProperties prop( Pdit.current() );
939 prop.showMaximized(); 939 prop.showMaximized();
940 prop.exec(); 940 prop.exec();
941 } 941 }
942 } 942 }
943 populateAudioView(); 943 populateAudioView();
944 } 944 }
945 break; 945 break;
946 case 2: 946 case 2:
947 { 947 {
948// file = videoView->selectedItem()->text(0); 948// file = videoView->selectedItem()->text(0);
949// for ( int i = 0; i < noOfFiles; i++ ) { 949// for ( int i = 0; i < noOfFiles; i++ ) {
950// QString entryName; 950// QString entryName;
951// entryName.sprintf( "File%i", i + 1 ); 951// entryName.sprintf( "File%i", i + 1 );
952// QString linkFile = cfg.readEntry( entryName ); 952// QString linkFile = cfg.readEntry( entryName );
953// AppLnk lnk( AppLnk(linkFile)); 953// AppLnk lnk( AppLnk(linkFile));
954// if( lnk.name() == file ) { 954// if( lnk.name() == file ) {
955// LnkProperties prop( &lnk); 955// LnkProperties prop( &lnk);
956// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 956// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
957// prop.showMaximized(); 957// prop.showMaximized();
958// prop.exec(); 958// prop.exec();
959// } 959// }
960// } 960// }
961 } 961 }
962 break; 962 break;
963 }; 963 };
964} 964}
965 965
966void PlayListWidget::scanForAudio() { 966void PlayListWidget::scanForAudio() {
967// qDebug("scan for audio"); 967// qDebug("scan for audio");
968 files.detachChildren(); 968 files.detachChildren();
969 QListIterator<DocLnk> sdit( files.children() ); 969 QListIterator<DocLnk> sdit( files.children() );
970 for ( ; sdit.current(); ++sdit ) { 970 for ( ; sdit.current(); ++sdit ) {
971 delete sdit.current(); 971 delete sdit.current();
972 } 972 }
973 Global::findDocuments( &files, audioMimes); 973 Global::findDocuments( &files, audioMimes);
974 audioScan = true; 974 audioScan = true;
975} 975}
976void PlayListWidget::scanForVideo() { 976void PlayListWidget::scanForVideo() {
977// qDebug("scan for video"); 977// qDebug("scan for video");
978 vFiles.detachChildren(); 978 vFiles.detachChildren();
979 QListIterator<DocLnk> sdit( vFiles.children() ); 979 QListIterator<DocLnk> sdit( vFiles.children() );
980 for ( ; sdit.current(); ++sdit ) { 980 for ( ; sdit.current(); ++sdit ) {
981 delete sdit.current(); 981 delete sdit.current();
982 } 982 }
983 Global::findDocuments(&vFiles, "video/*"); 983 Global::findDocuments(&vFiles, "video/*");
984 videoScan = true; 984 videoScan = true;
985} 985}
986 986
987void PlayListWidget::populateAudioView() { 987void PlayListWidget::populateAudioView() {
988 988
989 audioView->clear(); 989 audioView->clear();
990 StorageInfo storageInfo; 990 StorageInfo storageInfo;
991 const QList<FileSystem> &fs = storageInfo.fileSystems(); 991 const QList<FileSystem> &fs = storageInfo.fileSystems();
992 if(!audioScan) scanForAudio(); 992 if(!audioScan) scanForAudio();
993 993
994 QListIterator<DocLnk> dit( files.children() ); 994 QListIterator<DocLnk> dit( files.children() );
995 QListIterator<FileSystem> it ( fs ); 995 QListIterator<FileSystem> it ( fs );
996 996
997 QString storage; 997 QString storage;
998 for ( ; dit.current(); ++dit ) { 998 for ( ; dit.current(); ++dit ) {
999 for( ; it.current(); ++it ){ 999 for( ; it.current(); ++it ){
1000 const QString name = (*it)->name(); 1000 const QString name = (*it)->name();
1001 const QString path = (*it)->path(); 1001 const QString path = (*it)->path();
1002 if(dit.current()->file().find(path) != -1 ) storage=name; 1002 if(dit.current()->file().find(path) != -1 ) storage=name;
1003 } 1003 }
1004 1004
1005 QListViewItem * newItem; 1005 QListViewItem * newItem;
1006 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1006 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1007 long size; 1007 long size;
1008 if( dit.current()->file().left(4) == "http" ) 1008 if( dit.current()->file().left(4) == "http" )
1009 size=0; 1009 size=0;
1010 else 1010 else
1011 size = QFile( dit.current()->file() ).size(); 1011 size = QFile( dit.current()->file() ).size();
1012// qDebug(dit.current()->name()); 1012// qDebug(dit.current()->name());
1013 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1013 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1014 QString::number(size ), storage, dit.current()->file()); 1014 QString::number(size ), storage, dit.current()->file());
1015 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1015 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1016 } 1016 }
1017 } 1017 }
1018 1018
1019} 1019}
1020 1020
1021void PlayListWidget::populateVideoView() { 1021void PlayListWidget::populateVideoView() {
1022 videoView->clear(); 1022 videoView->clear();
1023 StorageInfo storageInfo; 1023 StorageInfo storageInfo;
1024 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1024 const QList<FileSystem> &fs = storageInfo.fileSystems();
1025 1025
1026 if(!videoScan ) scanForVideo(); 1026 if(!videoScan ) scanForVideo();
1027 1027
1028 QListIterator<DocLnk> Vdit( vFiles.children() ); 1028 QListIterator<DocLnk> Vdit( vFiles.children() );
1029 QListIterator<FileSystem> it ( fs ); 1029 QListIterator<FileSystem> it ( fs );
1030 videoView->clear(); 1030 videoView->clear();
1031 QString storage; 1031 QString storage;
1032 for ( ; Vdit.current(); ++Vdit ) { 1032 for ( ; Vdit.current(); ++Vdit ) {
1033 for( ; it.current(); ++it ){ 1033 for( ; it.current(); ++it ){
1034 const QString name = (*it)->name(); 1034 const QString name = (*it)->name();
1035 const QString path = (*it)->path(); 1035 const QString path = (*it)->path();
1036 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1036 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1037 } 1037 }
1038 1038
1039 QListViewItem * newItem; 1039 QListViewItem * newItem;
1040 if ( QFile( Vdit.current()->file()).exists() ) { 1040 if ( QFile( Vdit.current()->file()).exists() ) {
1041 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1041 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1042 QString::number( QFile( Vdit.current()->file() ).size() ), 1042 QString::number( QFile( Vdit.current()->file() ).size() ),
1043 storage, Vdit.current()->file()); 1043 storage, Vdit.current()->file());
1044 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1044 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1045 } 1045 }
1046 } 1046 }
1047} 1047}
1048 1048
1049void PlayListWidget::openFile() { 1049void PlayListWidget::openFile() {
1050 qDebug("<<<<<<<<<OPEN File"); 1050 qDebug("<<<<<<<<<OPEN File");
1051 QString filename, name; 1051 QString filename, name;
1052 InputDialog *fileDlg; 1052 InputDialog *fileDlg;
1053 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1053 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1054 fileDlg->exec(); 1054 fileDlg->exec();
1055 if( fileDlg->result() == 1 ) { 1055 if( fileDlg->result() == 1 ) {
1056 filename = fileDlg->text(); 1056 filename = fileDlg->text();
1057 qDebug( "Selected filename is " + filename ); 1057 qDebug( "Selected filename is " + filename );
1058// Om3u *m3uList; 1058// Om3u *m3uList;
1059 DocLnk lnk; 1059 DocLnk lnk;
1060 Config cfg( "OpiePlayer" ); 1060 Config cfg( "OpiePlayer" );
1061 cfg.setGroup("PlayList"); 1061 cfg.setGroup("PlayList");
1062 1062
1063 QString m3uFile;
1064 m3uFile = filename;
1063 if(filename.left(4) == "http") { 1065 if(filename.left(4) == "http") {
1064 QString m3uFile, m3uFilePath;
1065 if(filename.find(":",8,TRUE) != -1) { //found a port 1066 if(filename.find(":",8,TRUE) != -1) { //found a port
1066 m3uFile = filename.left( filename.find( ":",8,TRUE));
1067 m3uFile = m3uFile.right( 7);
1068 } else if(filename.left(4) == "http"){
1069 m3uFile=filename;
1070 m3uFile = m3uFile.right( m3uFile.length() - 7);
1071 } else{
1072 m3uFile=filename;
1073 }
1074 1067
1075// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 1068// m3uFile = filename.left( filename.find( ":",8,TRUE));
1076 lnk.setName( filename ); //sets name 1069 m3uFile = filename;
1070 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1071 m3uFile += "/";
1072 }
1073 filename = m3uFile;
1074// qDebug("1 "+m3uFile);
1075// } else if(filename.left(4) == "http"){
1076// m3uFile=filename;
1077// m3uFile = m3uFile.right( m3uFile.length() - 7);
1078// qDebug("2 "+m3uFile);
1079// } else{
1080// m3uFile=filename;
1081// qDebug("3 "+m3uFile);
1082 }
1083 lnk.setName( m3uFile ); //sets name
1077 lnk.setFile( filename ); //sets file name 1084 lnk.setFile( filename ); //sets file name
1078 lnk.setIcon("opieplayer2/musicfile"); 1085 lnk.setIcon("opieplayer2/musicfile");
1079 d->selectedFiles->addToSelection( lnk ); 1086 d->selectedFiles->addToSelection( lnk );
1080 writeCurrentM3u(); 1087 writeCurrentM3u();
1081 } 1088 }
1082 else if( filename.right( 3) == "m3u" ) { 1089 else if( filename.right( 3) == "m3u" ) {
1083 readm3u( filename ); 1090 readm3u( filename );
1084 1091
1085 } else if( filename.right(3) == "pls" ) { 1092 } else if( filename.right(3) == "pls" ) {
1086 readPls( filename ); 1093 readPls( filename );
1087 } else { 1094 } else {
1088 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1095 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1089 lnk.setFile( filename ); //sets file name 1096 lnk.setFile( filename ); //sets file name
1090 d->selectedFiles->addToSelection( lnk); 1097 d->selectedFiles->addToSelection( lnk);
1091 writeCurrentM3u(); 1098 writeCurrentM3u();
1092 } 1099 }
1093 } 1100 }
1094 1101
1095 if( fileDlg ) { 1102 if( fileDlg ) {
1096 delete fileDlg; 1103 delete fileDlg;
1097 } 1104 }
1098} 1105}
1099 1106
1100 1107
1101/* 1108/*
1102reads m3u and shows files/urls to playlist widget */ 1109reads m3u and shows files/urls to playlist widget */
1103void PlayListWidget::readm3u( const QString &filename ) { 1110void PlayListWidget::readm3u( const QString &filename ) {
1104 qDebug( "read m3u filename " + filename ); 1111 qDebug( "read m3u filename " + filename );
1105 1112
1106 Om3u *m3uList; 1113 Om3u *m3uList;
1107 QString s, name; 1114 QString s, name;
1108 m3uList = new Om3u( filename, IO_ReadOnly ); 1115 m3uList = new Om3u( filename, IO_ReadOnly );
1109 m3uList->readM3u(); 1116 m3uList->readM3u();
1110 DocLnk lnk; 1117 DocLnk lnk;
1111 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1118 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1112 s = *it; 1119 s = *it;
1113// qDebug("reading "+ s); 1120// qDebug("reading "+ s);
1114 if(s.left(4)=="http") { 1121 if(s.left(4)=="http") {
1115 lnk.setName( s ); //sets file name 1122 lnk.setName( s ); //sets file name
1116 lnk.setIcon("opieplayer2/musicfile"); 1123 lnk.setIcon("opieplayer2/musicfile");
1117 if(s.right(4) != '.' || s.right(5) != '.') 1124
1125// if(s.right(4) != '.' || s.right(5) != '.')
1126 if(s.right(4) != '.' || s.right(5) != '.' )
1127 if( s.right(1) != "/")
1118 lnk.setFile( s+"/"); //if url with no extension 1128 lnk.setFile( s+"/"); //if url with no extension
1119 else 1129 else
1120 lnk.setFile( s ); //sets file name 1130 lnk.setFile( s ); //sets file name
1121 1131
1122 } else { 1132 } else {
1123 // if( QFileInfo( s ).exists() ) { 1133 // if( QFileInfo( s ).exists() ) {
1124 lnk.setName( fullBaseName ( QFileInfo(s))); 1134 lnk.setName( fullBaseName ( QFileInfo(s)));
1125 // if(s.right(4) == '.') {//if regular file 1135 // if(s.right(4) == '.') {//if regular file
1126 if(s.left(1) != "/") { 1136 if(s.left(1) != "/") {
1127 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1137 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1128 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1138 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1129 lnk.setIcon("SoundPlayer"); 1139 lnk.setIcon("SoundPlayer");
1130 } else { 1140 } else {
1131 // qDebug("set link2 "+s); 1141 // qDebug("set link2 "+s);
1132 lnk.setFile( s); 1142 lnk.setFile( s);
1133 lnk.setIcon("SoundPlayer"); 1143 lnk.setIcon("SoundPlayer");
1134 } 1144 }
1135 } 1145 }
1136 d->selectedFiles->addToSelection( lnk ); 1146 d->selectedFiles->addToSelection( lnk );
1137 } 1147 }
1138 Config config( "OpiePlayer" ); 1148 Config config( "OpiePlayer" );
1139 config.setGroup( "PlayList" ); 1149 config.setGroup( "PlayList" );
1140 1150
1141 config.writeEntry("CurrentPlaylist",filename); 1151 config.writeEntry("CurrentPlaylist",filename);
1142 config.write(); 1152 config.write();
1143 currentPlayList=filename; 1153 currentPlayList=filename;
1144 1154
1145// m3uList->write(); 1155// m3uList->write();
1146 m3uList->close(); 1156 m3uList->close();
1147 if(m3uList) delete m3uList; 1157 if(m3uList) delete m3uList;
1148 1158
1149 d->selectedFiles->setSelectedItem( s); 1159 d->selectedFiles->setSelectedItem( s);
1150 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1160 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1151 1161
1152} 1162}
1153 1163
1154/* 1164/*
1155reads pls and adds files/urls to playlist */ 1165reads pls and adds files/urls to playlist */
1156void PlayListWidget::readPls( const QString &filename ) { 1166void PlayListWidget::readPls( const QString &filename ) {
1157 1167
1158 qDebug( "pls filename is " + filename ); 1168 qDebug( "pls filename is " + filename );
1159 Om3u *m3uList; 1169 Om3u *m3uList;
1160 QString s, name; 1170 QString s, name;
1161 m3uList = new Om3u( filename, IO_ReadOnly ); 1171 m3uList = new Om3u( filename, IO_ReadOnly );
1162 m3uList->readPls(); 1172 m3uList->readPls();
1163 1173
1164 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1174 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1165 s = *it; 1175 s = *it;
1166 // s.replace( QRegExp( "%20" )," " ); 1176 // s.replace( QRegExp( "%20" )," " );
1167 DocLnk lnk( s ); 1177 DocLnk lnk( s );
1168 QFileInfo f( s ); 1178 QFileInfo f( s );
1169 QString name = fullBaseName ( f); 1179 QString name = fullBaseName ( f);
1170 1180
1171 if( name.left( 4 ) == "http" ) { 1181 if( name.left( 4 ) == "http" ) {
1172 name = s.right( s.length() - 7); 1182 name = s.right( s.length() - 7);
1173 } else { 1183 } else {
1174 name = s; 1184 name = s;
1175 } 1185 }
1176 1186
1177 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1187 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1178 1188
1179 lnk.setName( name ); 1189 lnk.setName( name );
1180 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1190 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1181 lnk.setFile( s ); 1191 lnk.setFile( s );
1182 } else { //if its a url 1192 } else { //if its a url
1183 if( name.right( 1 ).find( '/' ) == -1) { 1193 if( name.right( 1 ).find( '/' ) == -1) {
1184 s += "/"; 1194 s += "/";
1185 } 1195 }
1186 lnk.setFile( s ); 1196 lnk.setFile( s );
1187 } 1197 }
1188 lnk.setType( "audio/x-mpegurl" ); 1198 lnk.setType( "audio/x-mpegurl" );
1189 1199
1190 lnk.writeLink(); 1200 lnk.writeLink();
1191 d->selectedFiles->addToSelection( lnk ); 1201 d->selectedFiles->addToSelection( lnk );
1192 } 1202 }
1193 1203
1194 m3uList->close(); 1204 m3uList->close();
1195 if(m3uList) delete m3uList; 1205 if(m3uList) delete m3uList;
1196} 1206}
1197 1207
1198/* 1208/*
1199 writes current playlist to current m3u file */ 1209 writes current playlist to current m3u file */
1200void PlayListWidget::writeCurrentM3u() { 1210void PlayListWidget::writeCurrentM3u() {
1201 qDebug("writing to current m3u"); 1211 qDebug("writing to current m3u");
1202 Config cfg( "OpiePlayer" ); 1212 Config cfg( "OpiePlayer" );
1203 cfg.setGroup("PlayList"); 1213 cfg.setGroup("PlayList");
1204 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 1214 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1205 Om3u *m3uList; 1215 Om3u *m3uList;
1206 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 1216 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1207 1217
1208 if( d->selectedFiles->first()) { 1218 if( d->selectedFiles->first()) {
1209 do { 1219 do {
1210 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1220 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1211 m3uList->add( d->selectedFiles->current()->file() ); 1221 m3uList->add( d->selectedFiles->current()->file() );
1212 } 1222 }
1213 while ( d->selectedFiles->next() ); 1223 while ( d->selectedFiles->next() );
1214 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1224 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1215 m3uList->write(); 1225 m3uList->write();
1216 m3uList->close(); 1226 m3uList->close();
1217 1227
1218 if(m3uList) delete m3uList; 1228 if(m3uList) delete m3uList;
1219 } 1229 }
1220} 1230}
1221 1231
1222 /* 1232 /*
1223 writes current playlist to m3u file */ 1233 writes current playlist to m3u file */
1224void PlayListWidget::writem3u() { 1234void PlayListWidget::writem3u() {
1225 InputDialog *fileDlg; 1235 InputDialog *fileDlg;
1226 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1236 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1227 fileDlg->exec(); 1237 fileDlg->exec();
1228 QString name, filename, list; 1238 QString name, filename, list;
1229 Om3u *m3uList; 1239 Om3u *m3uList;
1230 1240
1231 if( fileDlg->result() == 1 ) { 1241 if( fileDlg->result() == 1 ) {
1232 name = fileDlg->text(); 1242 name = fileDlg->text();
1233// qDebug( filename ); 1243// qDebug( filename );
1234 if( name.find("/",0,true) != -1) {// assume they specify a file path 1244 if( name.find("/",0,true) != -1) {// assume they specify a file path
1235 filename = name; 1245 filename = name;
1236 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1246 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1237 } 1247 }
1238 else //otherwise dump it somewhere noticable 1248 else //otherwise dump it somewhere noticable
1239 filename = QPEApplication::documentDir() + "/" + name; 1249 filename = QPEApplication::documentDir() + "/" + name;
1240 1250
1241 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1251 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1242 filename += ".m3u"; 1252 filename += ".m3u";
1243 1253
1244 if( d->selectedFiles->first()) { 1254 if( d->selectedFiles->first()) {
1245 m3uList = new Om3u(filename, IO_ReadWrite); 1255 m3uList = new Om3u(filename, IO_ReadWrite);
1246 1256
1247 do { 1257 do {
1248 m3uList->add( d->selectedFiles->current()->file()); 1258 m3uList->add( d->selectedFiles->current()->file());
1249 } 1259 }
1250 while ( d->selectedFiles->next() ); 1260 while ( d->selectedFiles->next() );
1251 // qDebug( list ); 1261 // qDebug( list );
1252 m3uList->write(); 1262 m3uList->write();
1253 m3uList->close(); 1263 m3uList->close();
1254 if(m3uList) delete m3uList; 1264 if(m3uList) delete m3uList;
1255 1265
1256 if(fileDlg) delete fileDlg; 1266 if(fileDlg) delete fileDlg;
1257 1267
1258 DocLnk lnk; 1268 DocLnk lnk;
1259 lnk.setFile( filename); 1269 lnk.setFile( filename);
1260 lnk.setIcon("opieplayer2/playlist2"); 1270 lnk.setIcon("opieplayer2/playlist2");
1261 lnk.setName( name); //sets file name 1271 lnk.setName( name); //sets file name
1262 1272
1263 // qDebug(filename); 1273 // qDebug(filename);
1264 Config config( "OpiePlayer" ); 1274 Config config( "OpiePlayer" );
1265 config.setGroup( "PlayList" ); 1275 config.setGroup( "PlayList" );
1266 1276
1267 config.writeEntry("CurrentPlaylist",filename); 1277 config.writeEntry("CurrentPlaylist",filename);
1268 currentPlayList=filename; 1278 currentPlayList=filename;
1269 1279
1270 if(!lnk.writeLink()) { 1280 if(!lnk.writeLink()) {
1271 qDebug("Writing doclink did not work"); 1281 qDebug("Writing doclink did not work");
1272 } 1282 }
1273 1283
1274 setCaption(tr("OpiePlayer: ") + name); 1284 setCaption(tr("OpiePlayer: ") + name);
1275 } 1285 }
1276 } 1286 }
1277} 1287}
1278 1288
1279 1289
1280void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1290void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1281{ 1291{
1282 switch ( e->key() ) { 1292 switch ( e->key() ) {
1283////////////////////////////// Zaurus keys 1293////////////////////////////// Zaurus keys
1284 case Key_F9: //activity 1294 case Key_F9: //activity
1285// if(audioUI->isHidden()) 1295// if(audioUI->isHidden())
1286// audioUI->showMaximized(); 1296// audioUI->showMaximized();
1287 break; 1297 break;
1288 case Key_F10: //contacts 1298 case Key_F10: //contacts
1289// if( videoUI->isHidden()) 1299// if( videoUI->isHidden())
1290// videoUI->showMaximized(); 1300// videoUI->showMaximized();
1291 break; 1301 break;
1292 case Key_F11: //menu 1302 case Key_F11: //menu
1293 break; 1303 break;
1294 case Key_F12: //home 1304 case Key_F12: //home
1295// doBlank(); 1305// doBlank();
1296 break; 1306 break;
1297 case Key_F13: //mail 1307 case Key_F13: //mail
1298// doUnblank(); 1308// doUnblank();
1299 break; 1309 break;
1300 case Key_Q: //add to playlist 1310 case Key_Q: //add to playlist
1301 qDebug("Add"); 1311 qDebug("Add");
1302 addSelected(); 1312 addSelected();
1303 break; 1313 break;
1304 case Key_R: //remove from playlist 1314 case Key_R: //remove from playlist
1305 removeSelected(); 1315 removeSelected();
1306 break; 1316 break;
1307// case Key_P: //play 1317// case Key_P: //play
1308// qDebug("Play"); 1318// qDebug("Play");
1309// playSelected(); 1319// playSelected();
1310// break; 1320// break;
1311 case Key_Space: 1321 case Key_Space:
1312 qDebug("Play"); 1322 qDebug("Play");
1313// playSelected(); puh 1323// playSelected(); puh
1314 break; 1324 break;
1315 case Key_1: 1325 case Key_1:
1316 tabWidget->setCurrentPage(0); 1326 tabWidget->setCurrentPage(0);
1317 break; 1327 break;
1318 case Key_2: 1328 case Key_2:
1319 tabWidget->setCurrentPage(1); 1329 tabWidget->setCurrentPage(1);
1320 break; 1330 break;
1321 case Key_3: 1331 case Key_3:
1322 tabWidget->setCurrentPage(2); 1332 tabWidget->setCurrentPage(2);
1323 break; 1333 break;
1324 case Key_4: 1334 case Key_4:
1325 tabWidget->setCurrentPage(3); 1335 tabWidget->setCurrentPage(3);
1326 break; 1336 break;
1327 case Key_Down: 1337 case Key_Down:
1328 if ( !d->selectedFiles->next() ) 1338 if ( !d->selectedFiles->next() )
1329 d->selectedFiles->first(); 1339 d->selectedFiles->first();
1330 1340
1331 break; 1341 break;
1332 case Key_Up: 1342 case Key_Up:
1333 if ( !d->selectedFiles->prev() ) 1343 if ( !d->selectedFiles->prev() )
1334 // d->selectedFiles->last(); 1344 // d->selectedFiles->last();
1335 1345
1336 break; 1346 break;
1337 1347
1338 } 1348 }
1339} 1349}
1340 1350
1341void PlayListWidget::keyPressEvent( QKeyEvent *) 1351void PlayListWidget::keyPressEvent( QKeyEvent *)
1342{ 1352{
1343// qDebug("Key press"); 1353// qDebug("Key press");
1344// switch ( e->key() ) { 1354// switch ( e->key() ) {
1345// ////////////////////////////// Zaurus keys 1355// ////////////////////////////// Zaurus keys
1346// case Key_A: //add to playlist 1356// case Key_A: //add to playlist
1347// qDebug("Add"); 1357// qDebug("Add");
1348// addSelected(); 1358// addSelected();
1349// break; 1359// break;
1350// case Key_R: //remove from playlist 1360// case Key_R: //remove from playlist
1351// removeSelected(); 1361// removeSelected();
1352// break; 1362// break;
1353// case Key_P: //play 1363// case Key_P: //play
1354// qDebug("Play"); 1364// qDebug("Play");
1355// playSelected(); 1365// playSelected();
1356// break; 1366// break;
1357// case Key_Space: 1367// case Key_Space:
1358// qDebug("Play"); 1368// qDebug("Play");
1359// playSelected(); 1369// playSelected();
1360// break; 1370// break;
1361// } 1371// }
1362} 1372}
1363 1373
1364void PlayListWidget::doBlank() { 1374void PlayListWidget::doBlank() {
1365 qDebug("do blanking"); 1375 qDebug("do blanking");
1366 fd=open("/dev/fb0",O_RDWR); 1376 fd=open("/dev/fb0",O_RDWR);
1367 if (fd != -1) { 1377 if (fd != -1) {
1368 ioctl(fd,FBIOBLANK,1); 1378 ioctl(fd,FBIOBLANK,1);
1369// close(fd); 1379// close(fd);
1370 } 1380 }
1371} 1381}
1372 1382
1373void PlayListWidget::doUnblank() { 1383void PlayListWidget::doUnblank() {