summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 16467c0..ccf654f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -454,207 +454,219 @@ bool PlayListWidget::prev() {
454 if ( cur == current() ) 454 if ( cur == current() )
455 if ( !d->selectedFiles->next() ) { 455 if ( !d->selectedFiles->next() ) {
456 d->selectedFiles->first(); 456 d->selectedFiles->first();
457 } 457 }
458 return TRUE; 458 return TRUE;
459 } else { 459 } else {
460 if ( !d->selectedFiles->prev() ) { 460 if ( !d->selectedFiles->prev() ) {
461 if ( mediaPlayerState->looping() ) { 461 if ( mediaPlayerState->looping() ) {
462 return d->selectedFiles->last(); 462 return d->selectedFiles->last();
463 } else { 463 } else {
464 return FALSE; 464 return FALSE;
465 } 465 }
466 } 466 }
467 return TRUE; 467 return TRUE;
468 } 468 }
469 } else { 469 } else {
470 return mediaPlayerState->looping(); 470 return mediaPlayerState->looping();
471 } 471 }
472} 472}
473 473
474 474
475bool PlayListWidget::next() { 475bool PlayListWidget::next() {
476//qDebug("<<<<<<<<<<<<next()"); 476//qDebug("<<<<<<<<<<<<next()");
477 if ( mediaPlayerState->playlist() ) { 477 if ( mediaPlayerState->playlist() ) {
478 if ( mediaPlayerState->shuffled() ) { 478 if ( mediaPlayerState->shuffled() ) {
479 return prev(); 479 return prev();
480 } else { 480 } else {
481 if ( !d->selectedFiles->next() ) { 481 if ( !d->selectedFiles->next() ) {
482 if ( mediaPlayerState->looping() ) { 482 if ( mediaPlayerState->looping() ) {
483 return d->selectedFiles->first(); 483 return d->selectedFiles->first();
484 } else { 484 } else {
485 return FALSE; 485 return FALSE;
486 } 486 }
487 } 487 }
488 return TRUE; 488 return TRUE;
489 } 489 }
490 } else { 490 } else {
491 return mediaPlayerState->looping(); 491 return mediaPlayerState->looping();
492 } 492 }
493} 493}
494 494
495 495
496bool PlayListWidget::first() { 496bool PlayListWidget::first() {
497 if ( mediaPlayerState->playlist() ) 497 if ( mediaPlayerState->playlist() )
498 return d->selectedFiles->first(); 498 return d->selectedFiles->first();
499 else 499 else
500 return mediaPlayerState->looping(); 500 return mediaPlayerState->looping();
501} 501}
502 502
503 503
504bool PlayListWidget::last() { 504bool PlayListWidget::last() {
505 if ( mediaPlayerState->playlist() ) 505 if ( mediaPlayerState->playlist() )
506 return d->selectedFiles->last(); 506 return d->selectedFiles->last();
507 else 507 else
508 return mediaPlayerState->looping(); 508 return mediaPlayerState->looping();
509} 509}
510 510
511 511
512 void PlayListWidget::saveList() { 512 void PlayListWidget::saveList() {
513 writem3u(); 513 writem3u();
514 } 514 }
515 515
516 516
517void PlayListWidget::loadList( const DocLnk & lnk) { 517void PlayListWidget::loadList( const DocLnk & lnk) {
518 QString name = lnk.name(); 518 QString name = lnk.name();
519 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 519 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
520 520
521 if( name.length()>0) { 521 if( name.length()>0) {
522 setCaption("OpiePlayer: "+name); 522 setCaption("OpiePlayer: "+name);
523// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 523// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
524 clearList(); 524 clearList();
525 readm3u(lnk.file()); 525 readm3u(lnk.file());
526 tabWidget->setCurrentPage(0); 526 tabWidget->setCurrentPage(0);
527 } 527 }
528} 528}
529 529
530 530
531void PlayListWidget::setPlaylist( bool shown ) { 531void PlayListWidget::setPlaylist( bool shown ) {
532 if ( shown ) { 532 if ( shown ) {
533 d->playListFrame->show(); 533 d->playListFrame->show();
534 } else { 534 } else {
535 d->playListFrame->hide(); 535 d->playListFrame->hide();
536 } 536 }
537} 537}
538 538
539 539
540void PlayListWidget::addSelected() { 540void PlayListWidget::addSelected() {
541 qDebug("addSelected"); 541 qDebug("addSelected");
542 DocLnk lnk; 542 DocLnk lnk;
543 QString filename; 543 QString filename;
544 switch (whichList()) { 544 switch (whichList()) {
545 545
546 case 0: //playlist 546 case 0: //playlist
547 return; 547 return;
548 break; 548 break;
549 case 1: { //audio 549 case 1: { //audio
550 filename=audioView->currentItem()->text(3); 550 QListViewItemIterator it( audioView );
551 // d->selectedFiles->next(); 551 for ( ; it.current(); ++it ) {
552 if ( it.current()->isSelected() ) {
553 filename=it.current()->text(3);
554 lnk.setName( QFileInfo(filename).baseName() ); //sets name
555 lnk.setFile( filename ); //sets file name
556 d->selectedFiles->addToSelection( lnk);
557 }
558 }
552 } 559 }
553 break; 560 break;
554 561
555 case 2: { // video 562 case 2: { // video
556 filename=videoView->currentItem()->text(3); 563 QListViewItemIterator it( videoView );
557 // tabWidget->setCurrentPage(0); 564 for ( ; it.current(); ++it ) {
565 if ( it.current()->isSelected() ) {
566 // myFile = (*it);
558 567
568 filename=it.current()->text(3);
569 lnk.setName( QFileInfo(filename).baseName() ); //sets name
570 lnk.setFile( filename ); //sets file name
571 d->selectedFiles->addToSelection( lnk);
572 }
573 }
559 } 574 }
560 break; 575 break;
561 }; 576 };
562 lnk.setName( QFileInfo(filename).baseName() ); //sets name
563 lnk.setFile( filename ); //sets file name
564 d->selectedFiles->addToSelection( lnk);
565 tabWidget->setCurrentPage(0); 577 tabWidget->setCurrentPage(0);
566 writeCurrentM3u(); 578 writeCurrentM3u();
567} 579}
568 580
569 581
570void PlayListWidget::removeSelected() { 582void PlayListWidget::removeSelected() {
571 d->selectedFiles->removeSelected( ); 583 d->selectedFiles->removeSelected( );
572 writeCurrentM3u(); 584 writeCurrentM3u();
573} 585}
574 586
575 587
576void PlayListWidget::playIt( QListViewItem *it) { 588void PlayListWidget::playIt( QListViewItem *it) {
577 if(!it) return; 589 if(!it) return;
578 mediaPlayerState->setPlaying(FALSE); 590 mediaPlayerState->setPlaying(FALSE);
579 mediaPlayerState->setPlaying(TRUE); 591 mediaPlayerState->setPlaying(TRUE);
580 d->selectedFiles->unSelect(); 592 d->selectedFiles->unSelect();
581} 593}
582 594
583 595
584void PlayListWidget::addToSelection( QListViewItem *it) { 596void PlayListWidget::addToSelection( QListViewItem *it) {
585 d->setDocumentUsed = FALSE; 597 d->setDocumentUsed = FALSE;
586 598
587 if(it) { 599 if(it) {
588 switch ( whichList()) { 600 switch ( whichList()) {
589 case 0: //playlist 601 case 0: //playlist
590 return; 602 return;
591 break; 603 break;
592 }; 604 };
593 // case 1: { 605 // case 1: {
594 DocLnk lnk; 606 DocLnk lnk;
595 QString filename; 607 QString filename;
596 608
597 filename=it->text(3); 609 filename=it->text(3);
598 lnk.setName( QFileInfo(filename).baseName() ); //sets name 610 lnk.setName( QFileInfo(filename).baseName() ); //sets name
599 lnk.setFile( filename ); //sets file name 611 lnk.setFile( filename ); //sets file name
600 d->selectedFiles->addToSelection( lnk); 612 d->selectedFiles->addToSelection( lnk);
601 613
602 writeCurrentM3u(); 614 writeCurrentM3u();
603 tabWidget->setCurrentPage(0); 615 tabWidget->setCurrentPage(0);
604 616
605 } 617 }
606} 618}
607 619
608 620
609void PlayListWidget::tabChanged(QWidget *) { 621void PlayListWidget::tabChanged(QWidget *) {
610 622
611 switch ( whichList()) { 623 switch ( whichList()) {
612 case 0: 624 case 0:
613 { 625 {
614 if( !tbDeletePlaylist->isHidden() ) { 626 if( !tbDeletePlaylist->isHidden() ) {
615 tbDeletePlaylist->hide(); 627 tbDeletePlaylist->hide();
616 } 628 }
617 d->tbRemoveFromList->setEnabled(TRUE); 629 d->tbRemoveFromList->setEnabled(TRUE);
618 d->tbAddToList->setEnabled(FALSE); 630 d->tbAddToList->setEnabled(FALSE);
619 } 631 }
620 break; 632 break;
621 case 1: 633 case 1:
622 { 634 {
623 // audioView->clear(); 635 // audioView->clear();
624 if(!audioPopulated) populateAudioView(); 636 if(!audioPopulated) populateAudioView();
625 637
626 if( !tbDeletePlaylist->isHidden() ) { 638 if( !tbDeletePlaylist->isHidden() ) {
627 tbDeletePlaylist->hide(); 639 tbDeletePlaylist->hide();
628 } 640 }
629 d->tbRemoveFromList->setEnabled(FALSE); 641 d->tbRemoveFromList->setEnabled(FALSE);
630 d->tbAddToList->setEnabled(TRUE); 642 d->tbAddToList->setEnabled(TRUE);
631 } 643 }
632 break; 644 break;
633 case 2: 645 case 2:
634 { 646 {
635 // videoView->clear(); 647 // videoView->clear();
636 if(!videoPopulated) populateVideoView(); 648 if(!videoPopulated) populateVideoView();
637 if( !tbDeletePlaylist->isHidden() ) { 649 if( !tbDeletePlaylist->isHidden() ) {
638 tbDeletePlaylist->hide(); 650 tbDeletePlaylist->hide();
639 } 651 }
640 d->tbRemoveFromList->setEnabled(FALSE); 652 d->tbRemoveFromList->setEnabled(FALSE);
641 d->tbAddToList->setEnabled(TRUE); 653 d->tbAddToList->setEnabled(TRUE);
642 } 654 }
643 break; 655 break;
644 case 3: 656 case 3:
645 { 657 {
646 if( tbDeletePlaylist->isHidden() ) { 658 if( tbDeletePlaylist->isHidden() ) {
647 tbDeletePlaylist->show(); 659 tbDeletePlaylist->show();
648 } 660 }
649 playLists->reread(); 661 playLists->reread();
650 } 662 }
651 break; 663 break;
652 }; 664 };
653} 665}
654 666
655 667
656void PlayListWidget::btnPlay(bool b) { 668void PlayListWidget::btnPlay(bool b) {
657// mediaPlayerState->setPlaying(false); 669// mediaPlayerState->setPlaying(false);
658 mediaPlayerState->setPlaying(b); 670 mediaPlayerState->setPlaying(b);
659 insanityBool=FALSE; 671 insanityBool=FALSE;
660} 672}
@@ -903,193 +915,193 @@ void PlayListWidget::readPls( const QString &filename ) {
903 s = *it; 915 s = *it;
904 // s.replace( QRegExp( "%20" )," " ); 916 // s.replace( QRegExp( "%20" )," " );
905 DocLnk lnk( s ); 917 DocLnk lnk( s );
906 QFileInfo f( s ); 918 QFileInfo f( s );
907 QString name = f.baseName(); 919 QString name = f.baseName();
908 920
909 if( name.left( 4 ) == "http" ) { 921 if( name.left( 4 ) == "http" ) {
910 name = s.right( s.length() - 7); 922 name = s.right( s.length() - 7);
911 } else { 923 } else {
912 name = s; 924 name = s;
913 } 925 }
914 926
915 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 927 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
916 928
917 lnk.setName( name ); 929 lnk.setName( name );
918 if( s.at( s.length() - 4) == '.') {// if this is probably a file 930 if( s.at( s.length() - 4) == '.') {// if this is probably a file
919 lnk.setFile( s ); 931 lnk.setFile( s );
920 } else { //if its a url 932 } else { //if its a url
921// if( name.right( 1 ).find( '/' ) == -1) { 933// if( name.right( 1 ).find( '/' ) == -1) {
922// s += "/"; 934// s += "/";
923// } 935// }
924 lnk.setFile( s ); 936 lnk.setFile( s );
925 } 937 }
926 lnk.setType( "audio/x-mpegurl" ); 938 lnk.setType( "audio/x-mpegurl" );
927 939
928 lnk.writeLink(); 940 lnk.writeLink();
929 d->selectedFiles->addToSelection( lnk ); 941 d->selectedFiles->addToSelection( lnk );
930 } 942 }
931 943
932 m3uList->close(); 944 m3uList->close();
933 if(m3uList) delete m3uList; 945 if(m3uList) delete m3uList;
934} 946}
935 947
936/* 948/*
937 writes current playlist to current m3u file */ 949 writes current playlist to current m3u file */
938void PlayListWidget::writeCurrentM3u() { 950void PlayListWidget::writeCurrentM3u() {
939 qDebug("writing to current m3u"); 951 qDebug("writing to current m3u");
940 Config cfg( "OpiePlayer" ); 952 Config cfg( "OpiePlayer" );
941 cfg.setGroup("PlayList"); 953 cfg.setGroup("PlayList");
942 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 954 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
943 955
944 Om3u *m3uList; 956 Om3u *m3uList;
945 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 957 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
946 if( d->selectedFiles->first()) { 958 if( d->selectedFiles->first()) {
947 959
948 do { 960 do {
949 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 961 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
950 m3uList->add( d->selectedFiles->current()->file() ); 962 m3uList->add( d->selectedFiles->current()->file() );
951 } 963 }
952 while ( d->selectedFiles->next() ); 964 while ( d->selectedFiles->next() );
953 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 965 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
954 m3uList->write(); 966 m3uList->write();
955 m3uList->close(); 967 m3uList->close();
956 968
957 if(m3uList) delete m3uList; 969 if(m3uList) delete m3uList;
958 } 970 }
959 971
960} 972}
961 973
962 /* 974 /*
963 writes current playlist to m3u file */ 975 writes current playlist to m3u file */
964void PlayListWidget::writem3u() { 976void PlayListWidget::writem3u() {
965 InputDialog *fileDlg; 977 InputDialog *fileDlg;
966 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 978 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
967 fileDlg->exec(); 979 fileDlg->exec();
968 QString name, filename, list; 980 QString name, filename, list;
969 Om3u *m3uList; 981 Om3u *m3uList;
970 982
971 if( fileDlg->result() == 1 ) { 983 if( fileDlg->result() == 1 ) {
972 name = fileDlg->text(); 984 name = fileDlg->text();
973// qDebug( filename ); 985// qDebug( filename );
974 986
975 if( name.left( 1) != "/" ) { 987 if( name.left( 1) != "/" ) {
976 filename = QPEApplication::documentDir() + "/" + name; 988 filename = QPEApplication::documentDir() + "/" + name;
977 } 989 }
978 990
979 if( name.right( 3 ) != "m3u" ) { 991 if( name.right( 3 ) != "m3u" ) {
980 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 992 filename = QPEApplication::documentDir() + "/" +name+".m3u";
981 } 993 }
982 994
983 if( d->selectedFiles->first()) { 995 if( d->selectedFiles->first()) {
984 m3uList = new Om3u(filename, IO_ReadWrite); 996 m3uList = new Om3u(filename, IO_ReadWrite);
985 997
986 do { 998 do {
987 m3uList->add( d->selectedFiles->current()->file()); 999 m3uList->add( d->selectedFiles->current()->file());
988 } 1000 }
989 while ( d->selectedFiles->next() ); 1001 while ( d->selectedFiles->next() );
990 // qDebug( list ); 1002 // qDebug( list );
991 m3uList->write(); 1003 m3uList->write();
992 m3uList->close(); 1004 m3uList->close();
993 if(m3uList) delete m3uList; 1005 if(m3uList) delete m3uList;
994 1006
995 if(fileDlg) delete fileDlg; 1007 if(fileDlg) delete fileDlg;
996 1008
997 DocLnk lnk; 1009 DocLnk lnk;
998 lnk.setFile( filename); 1010 lnk.setFile( filename);
999// lnk.setIcon("opieplayer2/playlist2"); 1011 lnk.setIcon("opieplayer2/playlist2");
1000 lnk.setName( name); //sets file name 1012 lnk.setName( name); //sets file name
1001 1013
1002 // qDebug(filename); 1014 // qDebug(filename);
1003 Config config( "OpiePlayer" ); 1015 Config config( "OpiePlayer" );
1004 config.setGroup( "PlayList" ); 1016 config.setGroup( "PlayList" );
1005 1017
1006 config.writeEntry("CurrentPlaylist",filename); 1018 config.writeEntry("CurrentPlaylist",filename);
1007 currentPlayList=filename; 1019 currentPlayList=filename;
1008 1020
1009 if(!lnk.writeLink()) { 1021 if(!lnk.writeLink()) {
1010 qDebug("Writing doclink did not work"); 1022 qDebug("Writing doclink did not work");
1011 } 1023 }
1012 1024
1013 setCaption(tr("OpiePlayer: ") + name); 1025 setCaption(tr("OpiePlayer: ") + name);
1014 } 1026 }
1015 } 1027 }
1016} 1028}
1017 1029
1018void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1030void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
1019 switch ( e->key() ) { 1031 switch ( e->key() ) {
1020 ////////////////////////////// Zaurus keys 1032 ////////////////////////////// Zaurus keys
1021 case Key_F9: //activity 1033 case Key_F9: //activity
1022 // if(audioUI->isHidden()) 1034 // if(audioUI->isHidden())
1023 // audioUI->showMaximized(); 1035 // audioUI->showMaximized();
1024 break; 1036 break;
1025 case Key_F10: //contacts 1037 case Key_F10: //contacts
1026 // if( videoUI->isHidden()) 1038 // if( videoUI->isHidden())
1027 // videoUI->showMaximized(); 1039 // videoUI->showMaximized();
1028 break; 1040 break;
1029 case Key_F11: //menu 1041 case Key_F11: //menu
1030 break; 1042 break;
1031 case Key_F12: //home 1043 case Key_F12: //home
1032 // doBlank(); 1044 // doBlank();
1033 break; 1045 break;
1034 case Key_F13: //mail 1046 case Key_F13: //mail
1035 // doUnblank(); 1047 // doUnblank();
1036 break; 1048 break;
1037 case Key_Q: //add to playlist 1049 case Key_Q: //add to playlist
1038 addSelected(); 1050 addSelected();
1039 break; 1051 break;
1040 case Key_R: //remove from playlist 1052 case Key_R: //remove from playlist
1041 removeSelected(); 1053 removeSelected();
1042 break; 1054 break;
1043 // case Key_P: //play 1055 // case Key_P: //play
1044 // qDebug("Play"); 1056 // qDebug("Play");
1045 // playSelected(); 1057 // playSelected();
1046 // break; 1058 // break;
1047 case Key_Space: 1059 case Key_Space:
1048 // playSelected(); puh 1060 // playSelected(); puh
1049 break; 1061 break;
1050 case Key_1: 1062 case Key_1:
1051 tabWidget->setCurrentPage( 0 ); 1063 tabWidget->setCurrentPage( 0 );
1052 break; 1064 break;
1053 case Key_2: 1065 case Key_2:
1054 tabWidget->setCurrentPage( 1 ); 1066 tabWidget->setCurrentPage( 1 );
1055 break; 1067 break;
1056 case Key_3: 1068 case Key_3:
1057 tabWidget->setCurrentPage( 2 ); 1069 tabWidget->setCurrentPage( 2 );
1058 break; 1070 break;
1059 case Key_4: 1071 case Key_4:
1060 tabWidget->setCurrentPage( 3 ); 1072 tabWidget->setCurrentPage( 3 );
1061 break; 1073 break;
1062 case Key_Down: 1074 case Key_Down:
1063 if ( !d->selectedFiles->next() ) 1075 if ( !d->selectedFiles->next() )
1064 d->selectedFiles->first(); 1076 d->selectedFiles->first();
1065 break; 1077 break;
1066 case Key_Up: 1078 case Key_Up:
1067 if ( !d->selectedFiles->prev() ) 1079 if ( !d->selectedFiles->prev() )
1068 // d->selectedFiles->last(); 1080 // d->selectedFiles->last();
1069 break; 1081 break;
1070 } 1082 }
1071} 1083}
1072 1084
1073void PlayListWidget::pmViewActivated(int index) { 1085void PlayListWidget::pmViewActivated(int index) {
1074// qDebug("%d", index); 1086// qDebug("%d", index);
1075 switch(index) { 1087 switch(index) {
1076 case -16: 1088 case -16:
1077 { 1089 {
1078 mediaPlayerState->toggleFullscreen(); 1090 mediaPlayerState->toggleFullscreen();
1079 bool b=mediaPlayerState->fullscreen(); 1091 bool b=mediaPlayerState->fullscreen();
1080 pmView->setItemChecked( index, b); 1092 pmView->setItemChecked( index, b);
1081 Config cfg( "OpiePlayer" ); 1093 Config cfg( "OpiePlayer" );
1082 cfg.writeEntry( "FullScreen", b ); 1094 cfg.writeEntry( "FullScreen", b );
1083 } 1095 }
1084 break; 1096 break;
1085 }; 1097 };
1086} 1098}
1087 1099
1088void PlayListWidget::populateSkinsMenu() { 1100void PlayListWidget::populateSkinsMenu() {
1089 int item = 0; 1101 int item = 0;
1090 defaultSkinIndex = 0; 1102 defaultSkinIndex = 0;
1091 QString skinName; 1103 QString skinName;
1092 Config cfg( "OpiePlayer" ); 1104 Config cfg( "OpiePlayer" );
1093 cfg.setGroup("Options" ); 1105 cfg.setGroup("Options" );
1094 QString skin = cfg.readEntry( "Skin", "default" ); 1106 QString skin = cfg.readEntry( "Skin", "default" );
1095 1107