-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 79 |
1 files changed, 49 insertions, 30 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 41fcb30..2323ac2 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -371,103 +371,109 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
371 | DocLnk lnk( linkFile ); | 371 | DocLnk lnk( linkFile ); |
372 | if ( lnk.isValid() ) { | 372 | if ( lnk.isValid() ) { |
373 | d->selectedFiles->addToSelection( lnk ); | 373 | d->selectedFiles->addToSelection( lnk ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | d->selectedFiles->setSelectedItem( currentString); | 376 | d->selectedFiles->setSelectedItem( currentString); |
377 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 377 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::writeConfig( Config& cfg ) const { | 381 | void PlayListWidget::writeConfig( Config& cfg ) const { |
382 | 382 | ||
383 | d->selectedFiles->writeCurrent( cfg); | 383 | d->selectedFiles->writeCurrent( cfg); |
384 | cfg.setGroup("PlayList"); | 384 | cfg.setGroup("PlayList"); |
385 | int noOfFiles = 0; | 385 | int noOfFiles = 0; |
386 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
387 | do { | 387 | do { |
388 | const DocLnk *lnk = d->selectedFiles->current(); | 388 | const DocLnk *lnk = d->selectedFiles->current(); |
389 | if ( lnk ) { | 389 | if ( lnk ) { |
390 | QString entryName; | 390 | QString entryName; |
391 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 391 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
392 | // qDebug(entryName); | 392 | // qDebug(entryName); |
393 | cfg.writeEntry( entryName, lnk->linkFile() ); | 393 | cfg.writeEntry( entryName, lnk->linkFile() ); |
394 | // if this link does exist, add it so we have the file | 394 | // if this link does exist, add it so we have the file |
395 | // next time... | 395 | // next time... |
396 | if ( !QFile::exists( lnk->linkFile() ) ) { | 396 | if ( !QFile::exists( lnk->linkFile() ) ) { |
397 | // the way writing lnks doesn't really check for out | 397 | // the way writing lnks doesn't really check for out |
398 | // of disk space, but check it anyway. | 398 | // of disk space, but check it anyway. |
399 | if ( !lnk->writeLink() ) { | 399 | if ( !lnk->writeLink() ) { |
400 | QMessageBox::critical( 0, tr("Out of space"), | 400 | QMessageBox::critical( 0, tr("Out of space"), |
401 | tr( "There was a problem saving " | 401 | tr( "There was a problem saving " |
402 | "the playlist.\n" | 402 | "the playlist.\n" |
403 | "Your playlist " | 403 | "Your playlist " |
404 | "may be missing some entries\n" | 404 | "may be missing some entries\n" |
405 | "the next time you start it." ) | 405 | "the next time you start it." ) |
406 | ); | 406 | ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | noOfFiles++; | 409 | noOfFiles++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | while ( d->selectedFiles->next() ); | 412 | while ( d->selectedFiles->next() ); |
413 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 413 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 417 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
418 | // qDebug("add"); | 418 | // qDebug("add"); |
419 | d->setDocumentUsed = FALSE; | 419 | if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { |
420 | if ( mediaPlayerState->playlist() ) { | 420 | QMessageBox::message("Note","You are trying to play\na malformed url."); |
421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 421 | |
422 | d->selectedFiles->addToSelection( lnk ); | 422 | } else { |
423 | |||
424 | d->setDocumentUsed = FALSE; | ||
425 | if ( mediaPlayerState->playlist() ) { | ||
426 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | ||
427 | d->selectedFiles->addToSelection( lnk ); | ||
428 | } | ||
429 | else | ||
430 | mediaPlayerState->setPlaying( TRUE ); | ||
423 | } | 431 | } |
424 | else | ||
425 | mediaPlayerState->setPlaying( TRUE ); | ||
426 | } | 432 | } |
427 | 433 | ||
428 | 434 | ||
429 | void PlayListWidget::clearList() { | 435 | void PlayListWidget::clearList() { |
430 | while ( first() ) | 436 | while ( first() ) |
431 | d->selectedFiles->removeSelected(); | 437 | d->selectedFiles->removeSelected(); |
432 | } | 438 | } |
433 | 439 | ||
434 | 440 | ||
435 | void PlayListWidget::addAllToList() { | 441 | void PlayListWidget::addAllToList() { |
436 | DocLnkSet filesAll; | 442 | DocLnkSet filesAll; |
437 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 443 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
438 | QListIterator<DocLnk> Adit( filesAll.children() ); | 444 | QListIterator<DocLnk> Adit( filesAll.children() ); |
439 | for ( ; Adit.current(); ++Adit ) | 445 | for ( ; Adit.current(); ++Adit ) |
440 | if(QFileInfo(Adit.current()->file()).exists()) | 446 | if(QFileInfo(Adit.current()->file()).exists()) |
441 | d->selectedFiles->addToSelection( **Adit ); | 447 | d->selectedFiles->addToSelection( **Adit ); |
442 | } | 448 | } |
443 | 449 | ||
444 | 450 | ||
445 | void PlayListWidget::addAllMusicToList() { | 451 | void PlayListWidget::addAllMusicToList() { |
446 | QListIterator<DocLnk> dit( files.children() ); | 452 | QListIterator<DocLnk> dit( files.children() ); |
447 | for ( ; dit.current(); ++dit ) | 453 | for ( ; dit.current(); ++dit ) |
448 | if(QFileInfo(dit.current()->file()).exists()) | 454 | if(QFileInfo(dit.current()->file()).exists()) |
449 | d->selectedFiles->addToSelection( **dit ); | 455 | d->selectedFiles->addToSelection( **dit ); |
450 | } | 456 | } |
451 | 457 | ||
452 | 458 | ||
453 | void PlayListWidget::addAllVideoToList() { | 459 | void PlayListWidget::addAllVideoToList() { |
454 | QListIterator<DocLnk> dit( vFiles.children() ); | 460 | QListIterator<DocLnk> dit( vFiles.children() ); |
455 | for ( ; dit.current(); ++dit ) | 461 | for ( ; dit.current(); ++dit ) |
456 | if(QFileInfo( dit.current()->file()).exists()) | 462 | if(QFileInfo( dit.current()->file()).exists()) |
457 | d->selectedFiles->addToSelection( **dit ); | 463 | d->selectedFiles->addToSelection( **dit ); |
458 | } | 464 | } |
459 | 465 | ||
460 | 466 | ||
461 | void PlayListWidget::setDocument(const QString& fileref) { | 467 | void PlayListWidget::setDocument(const QString& fileref) { |
462 | qDebug(fileref); | 468 | qDebug(fileref); |
463 | fromSetDocument = TRUE; | 469 | fromSetDocument = TRUE; |
464 | if ( fileref.isNull() ) { | 470 | if ( fileref.isNull() ) { |
465 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 471 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
466 | return; | 472 | return; |
467 | } | 473 | } |
468 | // qDebug("setDocument "+fileref); | 474 | // qDebug("setDocument "+fileref); |
469 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 475 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
470 | readm3u( fileref); | 476 | readm3u( fileref); |
471 | } | 477 | } |
472 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 478 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
473 | readPls( fileref); | 479 | readPls( fileref); |
@@ -801,124 +807,128 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
801 | void PlayListWidget::tabChanged(QWidget *widg) { | 807 | void PlayListWidget::tabChanged(QWidget *widg) { |
802 | 808 | ||
803 | switch ( tabWidget->currentPageIndex()) { | 809 | switch ( tabWidget->currentPageIndex()) { |
804 | case 0: | 810 | case 0: |
805 | { | 811 | { |
806 | if( !tbDeletePlaylist->isHidden()) | 812 | if( !tbDeletePlaylist->isHidden()) |
807 | tbDeletePlaylist->hide(); | 813 | tbDeletePlaylist->hide(); |
808 | d->tbRemoveFromList->setEnabled(TRUE); | 814 | d->tbRemoveFromList->setEnabled(TRUE); |
809 | d->tbAddToList->setEnabled(FALSE); | 815 | d->tbAddToList->setEnabled(FALSE); |
810 | } | 816 | } |
811 | break; | 817 | break; |
812 | case 1: | 818 | case 1: |
813 | { | 819 | { |
814 | audioView->clear(); | 820 | audioView->clear(); |
815 | populateAudioView(); | 821 | populateAudioView(); |
816 | 822 | ||
817 | if( !tbDeletePlaylist->isHidden()) | 823 | if( !tbDeletePlaylist->isHidden()) |
818 | tbDeletePlaylist->hide(); | 824 | tbDeletePlaylist->hide(); |
819 | d->tbRemoveFromList->setEnabled(FALSE); | 825 | d->tbRemoveFromList->setEnabled(FALSE); |
820 | d->tbAddToList->setEnabled(TRUE); | 826 | d->tbAddToList->setEnabled(TRUE); |
821 | } | 827 | } |
822 | break; | 828 | break; |
823 | case 2: | 829 | case 2: |
824 | { | 830 | { |
825 | videoView->clear(); | 831 | videoView->clear(); |
826 | populateVideoView(); | 832 | populateVideoView(); |
827 | if( !tbDeletePlaylist->isHidden()) | 833 | if( !tbDeletePlaylist->isHidden()) |
828 | tbDeletePlaylist->hide(); | 834 | tbDeletePlaylist->hide(); |
829 | d->tbRemoveFromList->setEnabled(FALSE); | 835 | d->tbRemoveFromList->setEnabled(FALSE); |
830 | d->tbAddToList->setEnabled(TRUE); | 836 | d->tbAddToList->setEnabled(TRUE); |
831 | } | 837 | } |
832 | break; | 838 | break; |
833 | case 3: | 839 | case 3: |
834 | { | 840 | { |
835 | if( tbDeletePlaylist->isHidden()) | 841 | if( tbDeletePlaylist->isHidden()) |
836 | tbDeletePlaylist->show(); | 842 | tbDeletePlaylist->show(); |
837 | playLists->reread(); | 843 | playLists->reread(); |
838 | } | 844 | } |
839 | break; | 845 | break; |
840 | }; | 846 | }; |
841 | } | 847 | } |
842 | 848 | ||
843 | void PlayListWidget::btnPlay(bool b) { | 849 | void PlayListWidget::btnPlay(bool b) { |
844 | 850 | ||
845 | // mediaPlayerState->setPlaying(b); | 851 | // mediaPlayerState->setPlaying(b); |
846 | switch ( tabWidget->currentPageIndex()) { | 852 | switch ( tabWidget->currentPageIndex()) { |
847 | case 0: | 853 | case 0: |
848 | { | 854 | { |
849 | 855 | qDebug("here we are"); | |
850 | mediaPlayerState->setPlaying(b); | 856 | if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
851 | } | 857 | QMessageBox::message("Note","You are trying to play\na malformed url."); |
858 | |||
859 | } else { | ||
860 | |||
861 | mediaPlayerState->setPlaying(b); | ||
862 | } } | ||
852 | break; | 863 | break; |
853 | case 1: | 864 | case 1: |
854 | { | 865 | { |
855 | addToSelection( audioView->currentItem() ); | 866 | addToSelection( audioView->currentItem() ); |
856 | mediaPlayerState->setPlaying(b); | 867 | mediaPlayerState->setPlaying(b); |
857 | d->selectedFiles->removeSelected( ); | 868 | d->selectedFiles->removeSelected( ); |
858 | tabWidget->setCurrentPage(1); | 869 | tabWidget->setCurrentPage(1); |
859 | d->selectedFiles->unSelect(); | 870 | d->selectedFiles->unSelect(); |
860 | insanityBool=FALSE; | 871 | insanityBool=FALSE; |
861 | // audioView->clearSelection(); | 872 | }// audioView->clearSelection(); |
862 | } | ||
863 | break; | 873 | break; |
864 | case 2: | 874 | case 2: |
865 | { | 875 | { |
866 | addToSelection( videoView->currentItem() ); | 876 | addToSelection( videoView->currentItem() ); |
867 | mediaPlayerState->setPlaying(b); | 877 | mediaPlayerState->setPlaying(b); |
868 | qApp->processEvents(); | 878 | qApp->processEvents(); |
869 | d->selectedFiles->removeSelected( ); | 879 | d->selectedFiles->removeSelected( ); |
870 | tabWidget->setCurrentPage(2); | 880 | tabWidget->setCurrentPage(2); |
871 | d->selectedFiles->unSelect(); | 881 | d->selectedFiles->unSelect(); |
872 | insanityBool=FALSE; | 882 | insanityBool=FALSE; |
873 | // videoView->clearSelection(); | 883 | }// videoView->clearSelection(); |
874 | } | ||
875 | break; | 884 | break; |
876 | }; | 885 | }; |
886 | |||
877 | } | 887 | } |
878 | 888 | ||
879 | void PlayListWidget::deletePlaylist() { | 889 | void PlayListWidget::deletePlaylist() { |
880 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 890 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
881 | (tr("You really want to delete\nthis playlist?")), | 891 | (tr("You really want to delete\nthis playlist?")), |
882 | (tr("Yes")), (tr("No")), 0 )){ | 892 | (tr("Yes")), (tr("No")), 0 )){ |
883 | case 0: // Yes clicked, | 893 | case 0: // Yes clicked, |
884 | QFile().remove(playLists->selected()->file()); | 894 | QFile().remove(playLists->selected()->file()); |
885 | QFile().remove(playLists->selected()->linkFile()); | 895 | QFile().remove(playLists->selected()->linkFile()); |
886 | playLists->reread(); | 896 | playLists->reread(); |
887 | break; | 897 | break; |
888 | case 1: // Cancel | 898 | case 1: // Cancel |
889 | break; | 899 | break; |
890 | }; | 900 | }; |
891 | } | 901 | } |
892 | 902 | ||
893 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 903 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
894 | { | 904 | { |
895 | switch (mouse) { | 905 | switch (mouse) { |
896 | case 1: | 906 | case 1: |
897 | break; | 907 | break; |
898 | case 2:{ | 908 | case 2:{ |
899 | 909 | ||
900 | QPopupMenu m; | 910 | QPopupMenu m; |
901 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 911 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
902 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 912 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
903 | m.insertSeparator(); | 913 | m.insertSeparator(); |
904 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 914 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
905 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 915 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
906 | 916 | ||
907 | m.exec( QCursor::pos() ); | 917 | m.exec( QCursor::pos() ); |
908 | } | 918 | } |
909 | break; | 919 | break; |
910 | }; | 920 | }; |
911 | } | 921 | } |
912 | 922 | ||
913 | void PlayListWidget::playSelected() | 923 | void PlayListWidget::playSelected() |
914 | { | 924 | { |
915 | btnPlay( TRUE); | 925 | btnPlay( TRUE); |
916 | // d->selectedFiles->unSelect(); | 926 | // d->selectedFiles->unSelect(); |
917 | } | 927 | } |
918 | 928 | ||
919 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 929 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
920 | { | 930 | { |
921 | switch (mouse) { | 931 | switch (mouse) { |
922 | case 1: | 932 | case 1: |
923 | 933 | ||
924 | break; | 934 | break; |
@@ -1023,122 +1033,126 @@ void PlayListWidget::populateAudioView() { | |||
1023 | 1033 | ||
1024 | QListViewItem * newItem; | 1034 | QListViewItem * newItem; |
1025 | if ( QFile( dit.current()->file()).exists() ) { | 1035 | if ( QFile( dit.current()->file()).exists() ) { |
1026 | // qDebug(dit.current()->name()); | 1036 | // qDebug(dit.current()->name()); |
1027 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1037 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1028 | QString::number( QFile( dit.current()->file()).size() ), storage); | 1038 | QString::number( QFile( dit.current()->file()).size() ), storage); |
1029 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1039 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1030 | } | 1040 | } |
1031 | } | 1041 | } |
1032 | 1042 | ||
1033 | } | 1043 | } |
1034 | 1044 | ||
1035 | void PlayListWidget::populateVideoView() { | 1045 | void PlayListWidget::populateVideoView() { |
1036 | videoView->clear(); | 1046 | videoView->clear(); |
1037 | StorageInfo storageInfo; | 1047 | StorageInfo storageInfo; |
1038 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1048 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1039 | 1049 | ||
1040 | if(!videoScan ) scanForVideo(); | 1050 | if(!videoScan ) scanForVideo(); |
1041 | 1051 | ||
1042 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1052 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1043 | QListIterator<FileSystem> it ( fs ); | 1053 | QListIterator<FileSystem> it ( fs ); |
1044 | videoView->clear(); | 1054 | videoView->clear(); |
1045 | QString storage; | 1055 | QString storage; |
1046 | for ( ; Vdit.current(); ++Vdit ) { | 1056 | for ( ; Vdit.current(); ++Vdit ) { |
1047 | for( ; it.current(); ++it ){ | 1057 | for( ; it.current(); ++it ){ |
1048 | const QString name = (*it)->name(); | 1058 | const QString name = (*it)->name(); |
1049 | const QString path = (*it)->path(); | 1059 | const QString path = (*it)->path(); |
1050 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1060 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1051 | } | 1061 | } |
1052 | 1062 | ||
1053 | QListViewItem * newItem; | 1063 | QListViewItem * newItem; |
1054 | if ( QFile( Vdit.current()->file()).exists() ) { | 1064 | if ( QFile( Vdit.current()->file()).exists() ) { |
1055 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1065 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1056 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1066 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1057 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1067 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1058 | } | 1068 | } |
1059 | } | 1069 | } |
1060 | } | 1070 | } |
1061 | 1071 | ||
1062 | void PlayListWidget::openFile() { | 1072 | void PlayListWidget::openFile() { |
1063 | QString filename, name; | 1073 | QString filename, name; |
1064 | InputDialog *fileDlg; | 1074 | InputDialog *fileDlg; |
1065 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1075 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1066 | fileDlg->exec(); | 1076 | fileDlg->exec(); |
1067 | if( fileDlg->result() == 1 ) { | 1077 | if( fileDlg->result() == 1 ) { |
1068 | filename = fileDlg->LineEdit1->text(); | 1078 | filename = fileDlg->LineEdit1->text(); |
1069 | // http://205.188.234.129:8030 | 1079 | // http://205.188.234.129:8030 |
1070 | // http://66.28.68.70:8000 | 1080 | // http://66.28.68.70:8000 |
1071 | filename.replace(QRegExp("%20")," "); | 1081 | // filename.replace(QRegExp("%20")," "); |
1072 | 1082 | if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) { | |
1073 | qDebug("Selected filename is "+filename); | 1083 | QMessageBox::message("Note","Spaces in urls are not allowed."); |
1084 | return; | ||
1085 | } else { | ||
1086 | qDebug("Selected filename is "+filename); | ||
1074 | if(filename.right(3) == "m3u") | 1087 | if(filename.right(3) == "m3u") |
1075 | readm3u( filename); | 1088 | readm3u( filename); |
1076 | else if(filename.right(3) == "pls") | 1089 | else if(filename.right(3) == "pls") |
1077 | readPls( filename); | 1090 | readPls( filename); |
1078 | else { | 1091 | else { |
1079 | DocLnk lnk; | 1092 | DocLnk lnk; |
1080 | 1093 | ||
1081 | lnk.setName(filename); //sets file name | 1094 | lnk.setName(filename); //sets file name |
1082 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1095 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1083 | filename += "/"; | 1096 | filename += "/"; |
1084 | lnk.setFile(filename); //sets File property | 1097 | lnk.setFile(filename); //sets File property |
1085 | 1098 | ||
1086 | lnk.setType("audio/x-mpegurl"); | 1099 | lnk.setType("audio/x-mpegurl"); |
1087 | lnk.setExec("opieplayer"); | 1100 | lnk.setExec("opieplayer"); |
1088 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1101 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1089 | 1102 | ||
1090 | if(!lnk.writeLink()) | 1103 | if(!lnk.writeLink()) |
1091 | qDebug("Writing doclink did not work"); | 1104 | qDebug("Writing doclink did not work"); |
1092 | d->selectedFiles->addToSelection( lnk); | 1105 | d->selectedFiles->addToSelection( lnk); |
1093 | // if(fileDlg2) | 1106 | // if(fileDlg2) |
1094 | // delete fileDlg2; | 1107 | // delete fileDlg2; |
1095 | } | 1108 | } |
1096 | } | 1109 | } |
1110 | } | ||
1097 | if(fileDlg) | 1111 | if(fileDlg) |
1098 | delete fileDlg; | 1112 | delete fileDlg; |
1099 | } | 1113 | } |
1100 | 1114 | ||
1101 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1115 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1102 | { | 1116 | { |
1103 | switch ( e->key() ) { | 1117 | switch ( e->key() ) { |
1104 | ////////////////////////////// Zaurus keys | 1118 | ////////////////////////////// Zaurus keys |
1105 | case Key_F9: //activity | 1119 | case Key_F9: //activity |
1106 | // if(audioUI->isHidden()) | 1120 | // if(audioUI->isHidden()) |
1107 | // audioUI->showMaximized(); | 1121 | // audioUI->showMaximized(); |
1108 | break; | 1122 | break; |
1109 | case Key_F10: //contacts | 1123 | case Key_F10: //contacts |
1110 | // if( videoUI->isHidden()) | 1124 | // if( videoUI->isHidden()) |
1111 | // videoUI->showMaximized(); | 1125 | // videoUI->showMaximized(); |
1112 | break; | 1126 | break; |
1113 | case Key_F11: //menu | 1127 | case Key_F11: //menu |
1114 | break; | 1128 | break; |
1115 | case Key_F12: //home | 1129 | case Key_F12: //home |
1116 | // doBlank(); | 1130 | // doBlank(); |
1117 | break; | 1131 | break; |
1118 | case Key_F13: //mail | 1132 | case Key_F13: //mail |
1119 | // doUnblank(); | 1133 | // doUnblank(); |
1120 | break; | 1134 | break; |
1121 | case Key_Q: //add to playlist | 1135 | case Key_Q: //add to playlist |
1122 | qDebug("Add"); | 1136 | qDebug("Add"); |
1123 | addSelected(); | 1137 | addSelected(); |
1124 | break; | 1138 | break; |
1125 | case Key_R: //remove from playlist | 1139 | case Key_R: //remove from playlist |
1126 | removeSelected(); | 1140 | removeSelected(); |
1127 | break; | 1141 | break; |
1128 | // case Key_P: //play | 1142 | // case Key_P: //play |
1129 | // qDebug("Play"); | 1143 | // qDebug("Play"); |
1130 | // playSelected(); | 1144 | // playSelected(); |
1131 | // break; | 1145 | // break; |
1132 | case Key_Space: | 1146 | case Key_Space: |
1133 | qDebug("Play"); | 1147 | qDebug("Play"); |
1134 | // playSelected(); puh | 1148 | // playSelected(); puh |
1135 | break; | 1149 | break; |
1136 | case Key_1: | 1150 | case Key_1: |
1137 | tabWidget->setCurrentPage(0); | 1151 | tabWidget->setCurrentPage(0); |
1138 | break; | 1152 | break; |
1139 | case Key_2: | 1153 | case Key_2: |
1140 | tabWidget->setCurrentPage(1); | 1154 | tabWidget->setCurrentPage(1); |
1141 | break; | 1155 | break; |
1142 | case Key_3: | 1156 | case Key_3: |
1143 | tabWidget->setCurrentPage(2); | 1157 | tabWidget->setCurrentPage(2); |
1144 | break; | 1158 | break; |
@@ -1160,129 +1174,134 @@ void PlayListWidget::keyPressEvent( QKeyEvent *e) | |||
1160 | // case Key_R: //remove from playlist | 1174 | // case Key_R: //remove from playlist |
1161 | // removeSelected(); | 1175 | // removeSelected(); |
1162 | // break; | 1176 | // break; |
1163 | // case Key_P: //play | 1177 | // case Key_P: //play |
1164 | // qDebug("Play"); | 1178 | // qDebug("Play"); |
1165 | // playSelected(); | 1179 | // playSelected(); |
1166 | // break; | 1180 | // break; |
1167 | // case Key_Space: | 1181 | // case Key_Space: |
1168 | // qDebug("Play"); | 1182 | // qDebug("Play"); |
1169 | // playSelected(); | 1183 | // playSelected(); |
1170 | // break; | 1184 | // break; |
1171 | // } | 1185 | // } |
1172 | } | 1186 | } |
1173 | 1187 | ||
1174 | void PlayListWidget::doBlank() { | 1188 | void PlayListWidget::doBlank() { |
1175 | qDebug("do blanking"); | 1189 | qDebug("do blanking"); |
1176 | fd=open("/dev/fb0",O_RDWR); | 1190 | fd=open("/dev/fb0",O_RDWR); |
1177 | if (fd != -1) { | 1191 | if (fd != -1) { |
1178 | ioctl(fd,FBIOBLANK,1); | 1192 | ioctl(fd,FBIOBLANK,1); |
1179 | // close(fd); | 1193 | // close(fd); |
1180 | } | 1194 | } |
1181 | } | 1195 | } |
1182 | 1196 | ||
1183 | void PlayListWidget::doUnblank() { | 1197 | void PlayListWidget::doUnblank() { |
1184 | // this crashes opieplayer with a segfault | 1198 | // this crashes opieplayer with a segfault |
1185 | // int fd; | 1199 | // int fd; |
1186 | // fd=open("/dev/fb0",O_RDWR); | 1200 | // fd=open("/dev/fb0",O_RDWR); |
1187 | qDebug("do unblanking"); | 1201 | qDebug("do unblanking"); |
1188 | if (fd != -1) { | 1202 | if (fd != -1) { |
1189 | ioctl(fd,FBIOBLANK,0); | 1203 | ioctl(fd,FBIOBLANK,0); |
1190 | close(fd); | 1204 | close(fd); |
1191 | } | 1205 | } |
1192 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1206 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1193 | h <<-3;// v[1]; // -3 Force on | 1207 | h <<-3;// v[1]; // -3 Force on |
1194 | } | 1208 | } |
1195 | 1209 | ||
1196 | void PlayListWidget::readm3u(const QString &filename) { | 1210 | void PlayListWidget::readm3u(const QString &filename) { |
1197 | 1211 | ||
1198 | qDebug("m3u filename is "+filename); | 1212 | qDebug("m3u filename is "+filename); |
1199 | QFile f(filename); | 1213 | QFile f(filename); |
1200 | 1214 | ||
1201 | if(f.open(IO_ReadOnly)) { | 1215 | if(f.open(IO_ReadOnly)) { |
1202 | QTextStream t(&f); | 1216 | QTextStream t(&f); |
1203 | QString s;//, first, second; | 1217 | QString s;//, first, second; |
1204 | int i=0; | 1218 | int i=0; |
1205 | while ( !t.atEnd()) { | 1219 | while ( !t.atEnd()) { |
1206 | // Lview->insertLine(t.readLine(),-1); | 1220 | // Lview->insertLine(t.readLine(),-1); |
1207 | s=t.readLine(); | 1221 | s=t.readLine(); |
1208 | if(s.find("#",0,TRUE) == -1) { | 1222 | if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { |
1223 | QMessageBox::message("Note","Spaces in urls are not allowed."); | ||
1224 | } | ||
1225 | else if(s.find("#",0,TRUE) == -1) { | ||
1209 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1226 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1210 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1227 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1211 | s=s.right(s.length()-2); | 1228 | s=s.right(s.length()-2); |
1212 | DocLnk lnk( s ); | 1229 | DocLnk lnk( s ); |
1213 | QFileInfo f(s); | 1230 | QFileInfo f(s); |
1214 | QString name = f.baseName(); | 1231 | QString name = f.baseName(); |
1215 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1232 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1216 | lnk.setName( name); | 1233 | lnk.setName( name); |
1217 | s=s.replace( QRegExp("\\"),"/"); | 1234 | s=s.replace( QRegExp("\\"),"/"); |
1218 | lnk.setFile( s); | 1235 | lnk.setFile( s); |
1219 | // lnk.setIcon(opieplayer/MPEGPlayer); | 1236 | // lnk.setIcon(opieplayer/MPEGPlayer); |
1220 | qDebug("add "+name); | 1237 | qDebug("add "+name); |
1221 | d->selectedFiles->addToSelection( lnk); | 1238 | d->selectedFiles->addToSelection( lnk); |
1222 | } else { // is url | 1239 | } else { // is url |
1240 | |||
1223 | s.replace(QRegExp("%20")," "); | 1241 | s.replace(QRegExp("%20")," "); |
1224 | DocLnk lnk( s); | 1242 | DocLnk lnk( s); |
1225 | QString name = s.right( s.length() - 7); | 1243 | QString name = s.right( s.length() - 7); |
1226 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1244 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1227 | lnk.setName(name); | 1245 | lnk.setName(name); |
1228 | lnk.setFile( s+"/"); | 1246 | lnk.setFile( s+"/"); |
1229 | // lnk.setFile( filename); | 1247 | // lnk.setFile( filename); |
1230 | // lnk.setComment( s+"/"); | 1248 | // lnk.setComment( s+"/"); |
1231 | lnk.setType("audio/x-mpegurl"); | 1249 | lnk.setType("audio/x-mpegurl"); |
1232 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | 1250 | // lnk.setIcon( "opieplayer/MPEGPlayer"); |
1233 | // qDebug("add "+s); | 1251 | // qDebug("add "+s); |
1234 | d->selectedFiles->addToSelection( lnk); | 1252 | d->selectedFiles->addToSelection( lnk); |
1235 | } | 1253 | } |
1236 | i++; | 1254 | i++; |
1237 | } | 1255 | } |
1238 | } | 1256 | } |
1239 | } | 1257 | } |
1240 | } | 1258 | } |
1259 | f.close(); | ||
1241 | } | 1260 | } |
1242 | 1261 | ||
1243 | void PlayListWidget::writem3u(const QString &filename) { | 1262 | void PlayListWidget::writem3u(const QString &filename) { |
1244 | 1263 | ||
1245 | } | 1264 | } |
1246 | 1265 | ||
1247 | void PlayListWidget::readPls(const QString &filename) { | 1266 | void PlayListWidget::readPls(const QString &filename) { |
1248 | 1267 | ||
1249 | qDebug("pls filename is "+filename); | 1268 | qDebug("pls filename is "+filename); |
1250 | QFile f(filename); | 1269 | QFile f(filename); |
1251 | 1270 | ||
1252 | if(f.open(IO_ReadOnly)) { | 1271 | if(f.open(IO_ReadOnly)) { |
1253 | QTextStream t(&f); | 1272 | QTextStream t(&f); |
1254 | QString s;//, first, second; | 1273 | QString s;//, first, second; |
1255 | int i=0; | 1274 | int i=0; |
1256 | while ( !t.atEnd()) { | 1275 | while ( !t.atEnd()) { |
1257 | s=t.readLine(); | 1276 | s=t.readLine(); |
1258 | if(s.left(4) == "File") { | 1277 | if(s.left(4) == "File") { |
1259 | s=s.right(s.length() - 6); | 1278 | s=s.right(s.length() - 6); |
1260 | s.replace(QRegExp("%20")," "); | 1279 | s.replace(QRegExp("%20")," "); |
1261 | qDebug("adding "+s+" to playlist"); | 1280 | qDebug("adding "+s+" to playlist"); |
1262 | // numberofentries=2 | 1281 | // numberofentries=2 |
1263 | // File1=http | 1282 | // File1=http |
1264 | // Title | 1283 | // Title |
1265 | // Length | 1284 | // Length |
1266 | // Version | 1285 | // Version |
1267 | // File2=http | 1286 | // File2=http |
1268 | 1287 | ||
1269 | s=s.replace( QRegExp("\\"),"/"); | 1288 | s=s.replace( QRegExp("\\"),"/"); |
1270 | // Lview->insertLine(t.readLine(),-1); | 1289 | // Lview->insertLine(t.readLine(),-1); |
1271 | // s=t.readLine(); | 1290 | // s=t.readLine(); |
1272 | // s=s.right(s.length()-2); | 1291 | // s=s.right(s.length()-2); |
1273 | DocLnk lnk( s ); | 1292 | DocLnk lnk( s ); |
1274 | QFileInfo f(s); | 1293 | QFileInfo f(s); |
1275 | QString name = f.baseName(); | 1294 | QString name = f.baseName(); |
1276 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1295 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1277 | // QFileInfo f(s); | 1296 | // QFileInfo f(s); |
1278 | // QString name = f.baseName(); | 1297 | // QString name = f.baseName(); |
1279 | // // name = name.left(name.length()-4); | 1298 | // // name = name.left(name.length()-4); |
1280 | // name = name.right(name.findRev("/",0,TRUE)); | 1299 | // name = name.right(name.findRev("/",0,TRUE)); |
1281 | lnk.setName( name); | 1300 | lnk.setName( name); |
1282 | lnk.setFile( s+"/"); | 1301 | lnk.setFile( s+"/"); |
1283 | lnk.setType("audio/x-mpegurl"); | 1302 | lnk.setType("audio/x-mpegurl"); |
1284 | 1303 | ||
1285 | qDebug("DocLnk add "+name); | 1304 | qDebug("DocLnk add "+name); |
1286 | d->selectedFiles->addToSelection( lnk); | 1305 | d->selectedFiles->addToSelection( lnk); |
1287 | } | 1306 | } |
1288 | } | 1307 | } |