summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp58
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
2 files changed, 24 insertions, 36 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 92da73b..c9ae225 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -409,521 +409,507 @@ void PlayListWidget::setDocument( const QString& fileref ) {
409 readPls( DocLnk( fileref).file() ); 409 readPls( DocLnk( fileref).file() );
410 } else { 410 } else {
411 clearList(); 411 clearList();
412 addToSelection( DocLnk( fileref ) ); 412 addToSelection( DocLnk( fileref ) );
413 writeCurrentM3u(); 413 writeCurrentM3u();
414 414
415 d->setDocumentUsed = TRUE; 415 d->setDocumentUsed = TRUE;
416 mediaPlayerState->setPlaying( FALSE ); 416 mediaPlayerState->setPlaying( FALSE );
417 mediaPlayerState->setPlaying( TRUE ); 417 mediaPlayerState->setPlaying( TRUE );
418 } 418 }
419} 419}
420 420
421 421
422void PlayListWidget::useSelectedDocument() { 422void PlayListWidget::useSelectedDocument() {
423 d->setDocumentUsed = FALSE; 423 d->setDocumentUsed = FALSE;
424} 424}
425 425
426 426
427const DocLnk *PlayListWidget::current() { // this is fugly 427const DocLnk *PlayListWidget::current() { // this is fugly
428 assert( currentTab() == CurrentPlayList ); 428 assert( currentTab() == CurrentPlayList );
429 429
430// qDebug("playlist"); 430// qDebug("playlist");
431 if ( mediaPlayerState->isUsingPlaylist() ) { 431 if ( mediaPlayerState->isUsingPlaylist() ) {
432 return d->selectedFiles->current(); 432 return d->selectedFiles->current();
433 } else if ( d->setDocumentUsed && d->current ) { 433 } else if ( d->setDocumentUsed && d->current ) {
434 return d->current; 434 return d->current;
435 } else { 435 } else {
436 return &(d->files->selectedDocument()); 436 return &(d->files->selectedDocument());
437 } 437 }
438} 438}
439 439
440 440
441bool PlayListWidget::prev() { 441bool PlayListWidget::prev() {
442 if ( mediaPlayerState->isUsingPlaylist() ) { 442 if ( mediaPlayerState->isUsingPlaylist() ) {
443 if ( mediaPlayerState->isShuffled() ) { 443 if ( mediaPlayerState->isShuffled() ) {
444 const DocLnk *cur = current(); 444 const DocLnk *cur = current();
445 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 445 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
446 for ( int i = 0; i < j; i++ ) { 446 for ( int i = 0; i < j; i++ ) {
447 if ( !d->selectedFiles->next() ) 447 if ( !d->selectedFiles->next() )
448 d->selectedFiles->first(); 448 d->selectedFiles->first();
449 } 449 }
450 if ( cur == current() ) 450 if ( cur == current() )
451 if ( !d->selectedFiles->next() ) { 451 if ( !d->selectedFiles->next() ) {
452 d->selectedFiles->first(); 452 d->selectedFiles->first();
453 } 453 }
454 return TRUE; 454 return TRUE;
455 } else { 455 } else {
456 if ( !d->selectedFiles->prev() ) { 456 if ( !d->selectedFiles->prev() ) {
457 if ( mediaPlayerState->isLooping() ) { 457 if ( mediaPlayerState->isLooping() ) {
458 return d->selectedFiles->last(); 458 return d->selectedFiles->last();
459 } else { 459 } else {
460 return FALSE; 460 return FALSE;
461 } 461 }
462 } 462 }
463 return TRUE; 463 return TRUE;
464 } 464 }
465 } else { 465 } else {
466 return mediaPlayerState->isLooping(); 466 return mediaPlayerState->isLooping();
467 } 467 }
468} 468}
469 469
470 470
471bool PlayListWidget::next() { 471bool PlayListWidget::next() {
472//qDebug("<<<<<<<<<<<<next()"); 472//qDebug("<<<<<<<<<<<<next()");
473 if ( mediaPlayerState->isUsingPlaylist() ) { 473 if ( mediaPlayerState->isUsingPlaylist() ) {
474 if ( mediaPlayerState->isShuffled() ) { 474 if ( mediaPlayerState->isShuffled() ) {
475 return prev(); 475 return prev();
476 } else { 476 } else {
477 if ( !d->selectedFiles->next() ) { 477 if ( !d->selectedFiles->next() ) {
478 if ( mediaPlayerState->isLooping() ) { 478 if ( mediaPlayerState->isLooping() ) {
479 return d->selectedFiles->first(); 479 return d->selectedFiles->first();
480 } else { 480 } else {
481 return FALSE; 481 return FALSE;
482 } 482 }
483 } 483 }
484 return TRUE; 484 return TRUE;
485 } 485 }
486 } else { 486 } else {
487 return mediaPlayerState->isLooping(); 487 return mediaPlayerState->isLooping();
488 } 488 }
489} 489}
490 490
491 491
492bool PlayListWidget::first() { 492bool PlayListWidget::first() {
493 if ( mediaPlayerState->isUsingPlaylist() ) 493 if ( mediaPlayerState->isUsingPlaylist() )
494 return d->selectedFiles->first(); 494 return d->selectedFiles->first();
495 else 495 else
496 return mediaPlayerState->isLooping(); 496 return mediaPlayerState->isLooping();
497} 497}
498 498
499 499
500bool PlayListWidget::last() { 500bool PlayListWidget::last() {
501 if ( mediaPlayerState->isUsingPlaylist() ) 501 if ( mediaPlayerState->isUsingPlaylist() )
502 return d->selectedFiles->last(); 502 return d->selectedFiles->last();
503 else 503 else
504 return mediaPlayerState->isLooping(); 504 return mediaPlayerState->isLooping();
505} 505}
506 506
507 507
508 void PlayListWidget::saveList() { 508 void PlayListWidget::saveList() {
509 writem3u(); 509 writem3u();
510 } 510 }
511 511
512 512
513void PlayListWidget::loadList( const DocLnk & lnk) { 513void PlayListWidget::loadList( const DocLnk & lnk) {
514 QString name = lnk.name(); 514 QString name = lnk.name();
515 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 515 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
516 516
517 if( name.length()>0) { 517 if( name.length()>0) {
518 setCaption("OpiePlayer: "+name); 518 setCaption("OpiePlayer: "+name);
519// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 519// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
520 clearList(); 520 clearList();
521 readm3u(lnk.file()); 521 readm3u(lnk.file());
522 tabWidget->setCurrentPage(0); 522 tabWidget->setCurrentPage(0);
523 } 523 }
524} 524}
525 525
526 526
527void PlayListWidget::setPlaylist( bool shown ) { 527void PlayListWidget::setPlaylist( bool shown ) {
528 if ( shown ) { 528 if ( shown ) {
529 d->playListFrame->show(); 529 d->playListFrame->show();
530 } else { 530 } else {
531 d->playListFrame->hide(); 531 d->playListFrame->hide();
532 } 532 }
533} 533}
534 534
535 535
536void PlayListWidget::addSelected() { 536void PlayListWidget::addSelected() {
537 qDebug("addSelected"); 537 assert( inFileListMode() );
538 DocLnk lnk;
539 QString filename;
540 switch (whichList()) {
541 538
542 case 0: //playlist 539 QListView *fileListView = currentFileListView();
543 return; 540 QListViewItemIterator it( fileListView );
544 break; 541 for ( ; it.current(); ++it )
545 case 1: { //audio
546 QListViewItemIterator it( audioView );
547 for ( ; it.current(); ++it ) {
548 if ( it.current()->isSelected() ) { 542 if ( it.current()->isSelected() ) {
549 filename=it.current()->text(3); 543 QString filename = it.current()->text(3);
550 lnk.setName( QFileInfo(filename).baseName() ); //sets name 544
551 lnk.setFile( filename ); //sets file name 545 DocLnk lnk;
552 d->selectedFiles->addToSelection( lnk); 546 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
553 547 lnk.setFile( filename ); //sets file name
554 } 548
555 } 549 d->selectedFiles->addToSelection( lnk );
556 audioView->clearSelection();
557 }
558 break;
559
560 case 2: { // video
561 QListViewItemIterator it( videoView );
562 for ( ; it.current(); ++it ) {
563 if ( it.current()->isSelected() ) {
564 filename=it.current()->text(3);
565 lnk.setName( QFileInfo(filename).baseName() ); //sets name
566 lnk.setFile( filename ); //sets file name
567 d->selectedFiles->addToSelection( lnk);
568 } 550 }
569 } 551
570 videoView->clearSelection(); 552 fileListView->clearSelection();
571 } 553
572 break; 554 tabWidget->setCurrentPage( 0 );
573 }; 555 writeCurrentM3u();
574 tabWidget->setCurrentPage(0);
575 writeCurrentM3u();
576} 556}
577 557
578 558
579void PlayListWidget::removeSelected() { 559void PlayListWidget::removeSelected() {
580 d->selectedFiles->removeSelected( ); 560 d->selectedFiles->removeSelected( );
581 writeCurrentM3u(); 561 writeCurrentM3u();
582} 562}
583 563
584 564
585void PlayListWidget::playIt( QListViewItem *it) { 565void PlayListWidget::playIt( QListViewItem *it) {
586 if(!it) return; 566 if(!it) return;
587 mediaPlayerState->setPlaying(FALSE); 567 mediaPlayerState->setPlaying(FALSE);
588 mediaPlayerState->setPlaying(TRUE); 568 mediaPlayerState->setPlaying(TRUE);
589 d->selectedFiles->unSelect(); 569 d->selectedFiles->unSelect();
590} 570}
591 571
592 572
593void PlayListWidget::addToSelection( QListViewItem *it) { 573void PlayListWidget::addToSelection( QListViewItem *it) {
594 d->setDocumentUsed = FALSE; 574 d->setDocumentUsed = FALSE;
595 575
596 if(it) { 576 if(it) {
597 switch ( whichList()) { 577 switch ( whichList()) {
598 case 0: //playlist 578 case 0: //playlist
599 return; 579 return;
600 break; 580 break;
601 }; 581 };
602 // case 1: { 582 // case 1: {
603 DocLnk lnk; 583 DocLnk lnk;
604 QString filename; 584 QString filename;
605 585
606 filename=it->text(3); 586 filename=it->text(3);
607 lnk.setName( QFileInfo(filename).baseName() ); //sets name 587 lnk.setName( QFileInfo(filename).baseName() ); //sets name
608 lnk.setFile( filename ); //sets file name 588 lnk.setFile( filename ); //sets file name
609 d->selectedFiles->addToSelection( lnk); 589 d->selectedFiles->addToSelection( lnk);
610 590
611 writeCurrentM3u(); 591 writeCurrentM3u();
612 tabWidget->setCurrentPage(0); 592 tabWidget->setCurrentPage(0);
613 593
614 } 594 }
615} 595}
616 596
617 597
618void PlayListWidget::tabChanged(QWidget *) { 598void PlayListWidget::tabChanged(QWidget *) {
619 599
620 switch ( whichList()) { 600 switch ( whichList()) {
621 case 0: 601 case 0:
622 { 602 {
623 if( !tbDeletePlaylist->isHidden() ) { 603 if( !tbDeletePlaylist->isHidden() ) {
624 tbDeletePlaylist->hide(); 604 tbDeletePlaylist->hide();
625 } 605 }
626 d->tbRemoveFromList->setEnabled(TRUE); 606 d->tbRemoveFromList->setEnabled(TRUE);
627 d->tbAddToList->setEnabled(FALSE); 607 d->tbAddToList->setEnabled(FALSE);
628 } 608 }
629 break; 609 break;
630 case 1: 610 case 1:
631 { 611 {
632 // audioView->clear(); 612 // audioView->clear();
633 if(!audioPopulated) populateAudioView(); 613 if(!audioPopulated) populateAudioView();
634 614
635 if( !tbDeletePlaylist->isHidden() ) { 615 if( !tbDeletePlaylist->isHidden() ) {
636 tbDeletePlaylist->hide(); 616 tbDeletePlaylist->hide();
637 } 617 }
638 d->tbRemoveFromList->setEnabled(FALSE); 618 d->tbRemoveFromList->setEnabled(FALSE);
639 d->tbAddToList->setEnabled(TRUE); 619 d->tbAddToList->setEnabled(TRUE);
640 } 620 }
641 break; 621 break;
642 case 2: 622 case 2:
643 { 623 {
644 // videoView->clear(); 624 // videoView->clear();
645 if(!videoPopulated) populateVideoView(); 625 if(!videoPopulated) populateVideoView();
646 if( !tbDeletePlaylist->isHidden() ) { 626 if( !tbDeletePlaylist->isHidden() ) {
647 tbDeletePlaylist->hide(); 627 tbDeletePlaylist->hide();
648 } 628 }
649 d->tbRemoveFromList->setEnabled(FALSE); 629 d->tbRemoveFromList->setEnabled(FALSE);
650 d->tbAddToList->setEnabled(TRUE); 630 d->tbAddToList->setEnabled(TRUE);
651 } 631 }
652 break; 632 break;
653 case 3: 633 case 3:
654 { 634 {
655 if( tbDeletePlaylist->isHidden() ) { 635 if( tbDeletePlaylist->isHidden() ) {
656 tbDeletePlaylist->show(); 636 tbDeletePlaylist->show();
657 } 637 }
658 playLists->reread(); 638 playLists->reread();
659 } 639 }
660 break; 640 break;
661 }; 641 };
662} 642}
663 643
664 644
665void PlayListWidget::btnPlay(bool b) { 645void PlayListWidget::btnPlay(bool b) {
666// mediaPlayerState->setPlaying(false); 646// mediaPlayerState->setPlaying(false);
667 mediaPlayerState->setPlaying(b); 647 mediaPlayerState->setPlaying(b);
668 insanityBool=FALSE; 648 insanityBool=FALSE;
669} 649}
670 650
671void PlayListWidget::deletePlaylist() { 651void PlayListWidget::deletePlaylist() {
672 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 652 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
673 (tr("You really want to delete\nthis playlist?")), 653 (tr("You really want to delete\nthis playlist?")),
674 (tr("Yes")), (tr("No")), 0 )){ 654 (tr("Yes")), (tr("No")), 0 )){
675 case 0: // Yes clicked, 655 case 0: // Yes clicked,
676 QFile().remove(playLists->selectedDocument().file()); 656 QFile().remove(playLists->selectedDocument().file());
677 QFile().remove(playLists->selectedDocument().linkFile()); 657 QFile().remove(playLists->selectedDocument().linkFile());
678 playLists->reread(); 658 playLists->reread();
679 break; 659 break;
680 case 1: // Cancel 660 case 1: // Cancel
681 break; 661 break;
682 }; 662 };
683} 663}
684 664
685 665
686void PlayListWidget::playSelected() { 666void PlayListWidget::playSelected() {
687 btnPlay( TRUE); 667 btnPlay( TRUE);
688} 668}
689 669
690 670
691void PlayListWidget::scanForAudio() { 671void PlayListWidget::scanForAudio() {
692// qDebug("scan for audio"); 672// qDebug("scan for audio");
693 files.detachChildren(); 673 files.detachChildren();
694 QListIterator<DocLnk> sdit( files.children() ); 674 QListIterator<DocLnk> sdit( files.children() );
695 for ( ; sdit.current(); ++sdit ) { 675 for ( ; sdit.current(); ++sdit ) {
696 delete sdit.current(); 676 delete sdit.current();
697 } 677 }
698// Global::findDocuments( &files, "audio/*"); 678// Global::findDocuments( &files, "audio/*");
699 Global::findDocuments( &files, audioMimes); 679 Global::findDocuments( &files, audioMimes);
700 audioScan = true; 680 audioScan = true;
701 populateAudioView(); 681 populateAudioView();
702} 682}
703 683
704void PlayListWidget::scanForVideo() { 684void PlayListWidget::scanForVideo() {
705// qDebug("scan for video"); 685// qDebug("scan for video");
706 vFiles.detachChildren(); 686 vFiles.detachChildren();
707 QListIterator<DocLnk> sdit( vFiles.children() ); 687 QListIterator<DocLnk> sdit( vFiles.children() );
708 for ( ; sdit.current(); ++sdit ) { 688 for ( ; sdit.current(); ++sdit ) {
709 delete sdit.current(); 689 delete sdit.current();
710 } 690 }
711 Global::findDocuments(&vFiles, "video/*"); 691 Global::findDocuments(&vFiles, "video/*");
712 videoScan = true; 692 videoScan = true;
713 populateVideoView(); 693 populateVideoView();
714} 694}
715 695
716void PlayListWidget::populateAudioView() { 696void PlayListWidget::populateAudioView() {
717 audioView->clear(); 697 audioView->clear();
718 StorageInfo storageInfo; 698 StorageInfo storageInfo;
719 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 699 // const QList<FileSystem> &fs = storageInfo.fileSystems();
720 if(!audioScan) { 700 if(!audioScan) {
721 scanForAudio(); 701 scanForAudio();
722 } 702 }
723 703
724 QListIterator<DocLnk> dit( files.children() ); 704 QListIterator<DocLnk> dit( files.children() );
725 // QListIterator<FileSystem> it ( fs ); 705 // QListIterator<FileSystem> it ( fs );
726 audioView->clear(); 706 audioView->clear();
727 707
728 QString storage; 708 QString storage;
729 for ( ; dit.current(); ++dit ) { 709 for ( ; dit.current(); ++dit ) {
730// // for( ; it.current(); ++it ){ 710// // for( ; it.current(); ++it ){
731// const QString name = (*dit)->name(); 711// const QString name = (*dit)->name();
732// const QString path = (*dit)->path(); 712// const QString path = (*dit)->path();
733// if(dit.current()->file().find(path) != -1 ) { 713// if(dit.current()->file().find(path) != -1 ) {
734// storage = name; 714// storage = name;
735// // } 715// // }
736// } 716// }
737 717
738 QListViewItem * newItem; 718 QListViewItem * newItem;
739 if ( QFile( dit.current()->file()).exists() || 719 if ( QFile( dit.current()->file()).exists() ||
740 dit.current()->file().left(4) == "http" ) { 720 dit.current()->file().left(4) == "http" ) {
741 long size; 721 long size;
742 if( dit.current()->file().left(4) == "http" ) 722 if( dit.current()->file().left(4) == "http" )
743 size=0; 723 size=0;
744 else 724 else
745 size = QFile( dit.current()->file() ).size(); 725 size = QFile( dit.current()->file() ).size();
746 726
747 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 727 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
748 QString::number(size ), "" /*storage*/, 728 QString::number(size ), "" /*storage*/,
749 dit.current()->file() ); 729 dit.current()->file() );
750 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 730 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
751// qDebug("<<<< "+dit.current()->file()); 731// qDebug("<<<< "+dit.current()->file());
752 } 732 }
753 } 733 }
754 audioPopulated=true; 734 audioPopulated=true;
755} 735}
756 736
757 737
758void PlayListWidget::populateVideoView() { 738void PlayListWidget::populateVideoView() {
759 videoView->clear(); 739 videoView->clear();
760 StorageInfo storageInfo; 740 StorageInfo storageInfo;
761 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 741 // const QList<FileSystem> &fs = storageInfo.fileSystems();
762 742
763 if(!videoScan ) { 743 if(!videoScan ) {
764 scanForVideo(); 744 scanForVideo();
765 } 745 }
766 746
767 QListIterator<DocLnk> Vdit( vFiles.children() ); 747 QListIterator<DocLnk> Vdit( vFiles.children() );
768// QListIterator<FileSystem> it ( fs ); 748// QListIterator<FileSystem> it ( fs );
769 videoView->clear(); 749 videoView->clear();
770 QString storage, pathName; 750 QString storage, pathName;
771 for ( ; Vdit.current(); ++Vdit ) { 751 for ( ; Vdit.current(); ++Vdit ) {
772// // for( ; it.current(); ++it ) { 752// // for( ; it.current(); ++it ) {
773// const QString name = (*Vdit)->name(); 753// const QString name = (*Vdit)->name();
774// const QString path = (*Vdit)->path(); 754// const QString path = (*Vdit)->path();
775// if( Vdit.current()->file().find(path) != -1 ) { 755// if( Vdit.current()->file().find(path) != -1 ) {
776// storage=name; 756// storage=name;
777// pathName=path; 757// pathName=path;
778// // } 758// // }
779// } 759// }
780 760
781 QListViewItem * newItem; 761 QListViewItem * newItem;
782 if ( QFile( Vdit.current()->file() ).exists() ) { 762 if ( QFile( Vdit.current()->file() ).exists() ) {
783 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 763 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
784 QString::number( QFile( Vdit.current()->file() ).size() ), 764 QString::number( QFile( Vdit.current()->file() ).size() ),
785 ""/*storage*/, Vdit.current()->file()); 765 ""/*storage*/, Vdit.current()->file());
786 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 766 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
787 } 767 }
788 } 768 }
789 videoPopulated=true; 769 videoPopulated=true;
790} 770}
791 771
792QListView *PlayListWidget::currentFileListView() const 772QListView *PlayListWidget::currentFileListView() const
793{ 773{
794 switch ( currentTab() ) { 774 switch ( currentTab() ) {
795 case AudioFiles: return audioView; 775 case AudioFiles: return audioView;
796 case VideoFiles: return videoView; 776 case VideoFiles: return videoView;
797 default: assert( false ); 777 default: assert( false );
798 } 778 }
799 return 0; 779 return 0;
800} 780}
801 781
782bool PlayListWidget::inFileListMode() const
783{
784 TabType tab = currentTab();
785 return tab == AudioFiles || tab == VideoFiles;
786}
787
802void PlayListWidget::openFile() { 788void PlayListWidget::openFile() {
803 // http://66.28.164.33:2080 789 // http://66.28.164.33:2080
804 // http://somafm.com/star0242.m3u 790 // http://somafm.com/star0242.m3u
805 QString filename, name; 791 QString filename, name;
806 InputDialog *fileDlg; 792 InputDialog *fileDlg;
807 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 793 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
808 fileDlg->exec(); 794 fileDlg->exec();
809 if( fileDlg->result() == 1 ) { 795 if( fileDlg->result() == 1 ) {
810 filename = fileDlg->text(); 796 filename = fileDlg->text();
811 qDebug( "Selected filename is " + filename ); 797 qDebug( "Selected filename is " + filename );
812 // Om3u *m3uList; 798 // Om3u *m3uList;
813 DocLnk lnk; 799 DocLnk lnk;
814 Config cfg( "OpiePlayer" ); 800 Config cfg( "OpiePlayer" );
815 cfg.setGroup("PlayList"); 801 cfg.setGroup("PlayList");
816 802
817 if(filename.left(4) == "http") { 803 if(filename.left(4) == "http") {
818 QString m3uFile, m3uFilePath; 804 QString m3uFile, m3uFilePath;
819 if(filename.find(":",8,TRUE) != -1) { //found a port 805 if(filename.find(":",8,TRUE) != -1) { //found a port
820 m3uFile = filename.left( filename.find( ":",8,TRUE)); 806 m3uFile = filename.left( filename.find( ":",8,TRUE));
821 m3uFile = m3uFile.right( 7); 807 m3uFile = m3uFile.right( 7);
822 } else if(filename.left(4) == "http"){ 808 } else if(filename.left(4) == "http"){
823 m3uFile=filename; 809 m3uFile=filename;
824 m3uFile = m3uFile.right( m3uFile.length() - 7); 810 m3uFile = m3uFile.right( m3uFile.length() - 7);
825 } else{ 811 } else{
826 m3uFile=filename; 812 m3uFile=filename;
827 } 813 }
828 814
829// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 815// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
830 lnk.setName( filename ); //sets name 816 lnk.setName( filename ); //sets name
831 lnk.setFile( filename ); //sets file name 817 lnk.setFile( filename ); //sets file name
832 818
833// lnk.setIcon("opieplayer2/musicfile"); 819// lnk.setIcon("opieplayer2/musicfile");
834 820
835 d->selectedFiles->addToSelection( lnk ); 821 d->selectedFiles->addToSelection( lnk );
836 writeCurrentM3u(); 822 writeCurrentM3u();
837 d->selectedFiles->setSelectedItem( lnk.name()); 823 d->selectedFiles->setSelectedItem( lnk.name());
838 } 824 }
839 else if( filename.right( 3) == "m3u" ) { 825 else if( filename.right( 3) == "m3u" ) {
840 readm3u( filename ); 826 readm3u( filename );
841 827
842 } else if( filename.right(3) == "pls" ) { 828 } else if( filename.right(3) == "pls" ) {
843 readPls( filename ); 829 readPls( filename );
844 } else { 830 } else {
845 lnk.setName( QFileInfo(filename).baseName() ); //sets name 831 lnk.setName( QFileInfo(filename).baseName() ); //sets name
846 lnk.setFile( filename ); //sets file name 832 lnk.setFile( filename ); //sets file name
847 d->selectedFiles->addToSelection( lnk); 833 d->selectedFiles->addToSelection( lnk);
848 writeCurrentM3u(); 834 writeCurrentM3u();
849 d->selectedFiles->setSelectedItem( lnk.name()); 835 d->selectedFiles->setSelectedItem( lnk.name());
850 } 836 }
851 } 837 }
852 838
853 if( fileDlg ) { 839 if( fileDlg ) {
854 delete fileDlg; 840 delete fileDlg;
855 } 841 }
856} 842}
857 843
858/* 844/*
859reads m3u and shows files/urls to playlist widget */ 845reads m3u and shows files/urls to playlist widget */
860void PlayListWidget::readm3u( const QString &filename ) { 846void PlayListWidget::readm3u( const QString &filename ) {
861 qDebug( "read m3u filename " + filename ); 847 qDebug( "read m3u filename " + filename );
862 848
863 Om3u *m3uList; 849 Om3u *m3uList;
864 QString s, name; 850 QString s, name;
865 m3uList = new Om3u( filename, IO_ReadOnly ); 851 m3uList = new Om3u( filename, IO_ReadOnly );
866 m3uList->readM3u(); 852 m3uList->readM3u();
867 DocLnk lnk; 853 DocLnk lnk;
868 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 854 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
869 s = *it; 855 s = *it;
870// qDebug("reading "+ s); 856// qDebug("reading "+ s);
871 if(s.left(4)=="http") { 857 if(s.left(4)=="http") {
872 lnk.setName( s ); //sets file name 858 lnk.setName( s ); //sets file name
873 lnk.setIcon("opieplayer2/musicfile"); 859 lnk.setIcon("opieplayer2/musicfile");
874 lnk.setFile( s ); //sets file name 860 lnk.setFile( s ); //sets file name
875 861
876 } else { 862 } else {
877 // if( QFileInfo( s ).exists() ) { 863 // if( QFileInfo( s ).exists() ) {
878 lnk.setName( QFileInfo(s).baseName()); 864 lnk.setName( QFileInfo(s).baseName());
879 // if(s.right(4) == '.') {//if regular file 865 // if(s.right(4) == '.') {//if regular file
880 if(s.left(1) != "/") { 866 if(s.left(1) != "/") {
881 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 867 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
882 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 868 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
883// lnk.setIcon(MimeType(s).pixmap() ); 869// lnk.setIcon(MimeType(s).pixmap() );
884// lnk.setIcon("SoundPlayer"); 870// lnk.setIcon("SoundPlayer");
885 } else { 871 } else {
886 // qDebug("set link2 "+s); 872 // qDebug("set link2 "+s);
887 lnk.setFile( s); 873 lnk.setFile( s);
888// lnk.setIcon(MimeType(s).pixmap() ); 874// lnk.setIcon(MimeType(s).pixmap() );
889// lnk.setIcon("SoundPlayer"); 875// lnk.setIcon("SoundPlayer");
890 } 876 }
891 } 877 }
892 d->selectedFiles->addToSelection( lnk ); 878 d->selectedFiles->addToSelection( lnk );
893 } 879 }
894 Config config( "OpiePlayer" ); 880 Config config( "OpiePlayer" );
895 config.setGroup( "PlayList" ); 881 config.setGroup( "PlayList" );
896 882
897 config.writeEntry("CurrentPlaylist",filename); 883 config.writeEntry("CurrentPlaylist",filename);
898 config.write(); 884 config.write();
899 currentPlayList=filename; 885 currentPlayList=filename;
900 886
901// m3uList->write(); 887// m3uList->write();
902 m3uList->close(); 888 m3uList->close();
903 if(m3uList) delete m3uList; 889 if(m3uList) delete m3uList;
904 890
905 d->selectedFiles->setSelectedItem( s); 891 d->selectedFiles->setSelectedItem( s);
906 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 892 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
907 893
908} 894}
909 895
910/* 896/*
911reads pls and adds files/urls to playlist */ 897reads pls and adds files/urls to playlist */
912void PlayListWidget::readPls( const QString &filename ) { 898void PlayListWidget::readPls( const QString &filename ) {
913 899
914 qDebug( "pls filename is " + filename ); 900 qDebug( "pls filename is " + filename );
915 Om3u *m3uList; 901 Om3u *m3uList;
916 QString s, name; 902 QString s, name;
917 m3uList = new Om3u( filename, IO_ReadOnly ); 903 m3uList = new Om3u( filename, IO_ReadOnly );
918 m3uList->readPls(); 904 m3uList->readPls();
919 905
920 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 906 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
921 s = *it; 907 s = *it;
922 // s.replace( QRegExp( "%20" )," " ); 908 // s.replace( QRegExp( "%20" )," " );
923 DocLnk lnk( s ); 909 DocLnk lnk( s );
924 QFileInfo f( s ); 910 QFileInfo f( s );
925 QString name = f.baseName(); 911 QString name = f.baseName();
926 912
927 if( name.left( 4 ) == "http" ) { 913 if( name.left( 4 ) == "http" ) {
928 name = s.right( s.length() - 7); 914 name = s.right( s.length() - 7);
929 } else { 915 } else {
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index a608eae..238a75c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,126 +1,128 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists, NumTabTypes = 4 }; 58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists, NumTabTypes = 4 };
59 59
60 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 60 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
61 ~PlayListWidget(); 61 ~PlayListWidget();
62 DocLnkSet files; 62 DocLnkSet files;
63 DocLnkSet vFiles; 63 DocLnkSet vFiles;
64 bool fromSetDocument; 64 bool fromSetDocument;
65 bool insanityBool; 65 bool insanityBool;
66 QString setDocFileRef, currentPlayList; 66 QString setDocFileRef, currentPlayList;
67 // retrieve the current playlist entry (media file link) 67 // retrieve the current playlist entry (media file link)
68 const DocLnk *current(); 68 const DocLnk *current();
69 void useSelectedDocument(); 69 void useSelectedDocument();
70 int selected; 70 int selected;
71 int whichList() const; 71 int whichList() const;
72 TabType currentTab() const; 72 TabType currentTab() const;
73 73
74public slots: 74public slots:
75 bool first(); 75 bool first();
76 bool last(); 76 bool last();
77 bool next(); 77 bool next();
78 bool prev(); 78 bool prev();
79 void writeDefaultPlaylist( ); 79 void writeDefaultPlaylist( );
80 QString currentFileListPathName() const; 80 QString currentFileListPathName() const;
81protected: 81protected:
82 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
83 83
84private: 84private:
85 int defaultSkinIndex; 85 int defaultSkinIndex;
86 bool audioScan, videoScan, audioPopulated, videoPopulated; 86 bool audioScan, videoScan, audioPopulated, videoPopulated;
87 void readm3u(const QString &); 87 void readm3u(const QString &);
88 void readPls(const QString &); 88 void readPls(const QString &);
89 void initializeStates(); 89 void initializeStates();
90 void populateAudioView(); 90 void populateAudioView();
91 void populateVideoView(); 91 void populateVideoView();
92 92
93 QListView *currentFileListView() const; 93 QListView *currentFileListView() const;
94 94
95 bool inFileListMode() const;
96
95private slots: 97private slots:
96 void populateSkinsMenu(); 98 void populateSkinsMenu();
97 void skinsMenuActivated(int); 99 void skinsMenuActivated(int);
98 void pmViewActivated(int); 100 void pmViewActivated(int);
99 void writem3u(); 101 void writem3u();
100 void writeCurrentM3u(); 102 void writeCurrentM3u();
101 void scanForAudio(); 103 void scanForAudio();
102 void scanForVideo(); 104 void scanForVideo();
103 void openFile(); 105 void openFile();
104 void setDocument( const QString& fileref ); 106 void setDocument( const QString& fileref );
105 void addToSelection( const DocLnk& ); // Add a media file to the playlist 107 void addToSelection( const DocLnk& ); // Add a media file to the playlist
106 void addToSelection( QListViewItem* ); // Add a media file to the playlist 108 void addToSelection( QListViewItem* ); // Add a media file to the playlist
107 void setPlaylist( bool ); // Show/Hide the playlist 109 void setPlaylist( bool ); // Show/Hide the playlist
108 void clearList(); 110 void clearList();
109 void addAllToList(); 111 void addAllToList();
110 void addAllMusicToList(); 112 void addAllMusicToList();
111 void addAllVideoToList(); 113 void addAllVideoToList();
112 void saveList(); // Save the playlist 114 void saveList(); // Save the playlist
113 void loadList( const DocLnk &); // Load a playlist 115 void loadList( const DocLnk &); // Load a playlist
114 void playIt( QListViewItem *); 116 void playIt( QListViewItem *);
115 void btnPlay(bool); 117 void btnPlay(bool);
116 void deletePlaylist(); 118 void deletePlaylist();
117 void addSelected(); 119 void addSelected();
118 void removeSelected(); 120 void removeSelected();
119 void tabChanged(QWidget*); 121 void tabChanged(QWidget*);
120 void viewPressed( int, QListViewItem *, const QPoint&, int); 122 void viewPressed( int, QListViewItem *, const QPoint&, int);
121 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 123 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
122 void playSelected(); 124 void playSelected();
123}; 125};
124 126
125#endif // PLAY_LIST_WIDGET_H 127#endif // PLAY_LIST_WIDGET_H
126 128