author | harlekin <harlekin> | 2002-08-19 20:47:11 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-19 20:47:11 (UTC) |
commit | 7f1a7e9b3272f7848423583ea5fc04eb67d97f14 (patch) (unidiff) | |
tree | b8496afa48a9cddfe8ec701aac44cb90f926e165 | |
parent | 6c0751d0d1869089066269430b4664655e1dbe68 (diff) | |
download | opie-7f1a7e9b3272f7848423583ea5fc04eb67d97f14.zip opie-7f1a7e9b3272f7848423583ea5fc04eb67d97f14.tar.gz opie-7f1a7e9b3272f7848423583ea5fc04eb67d97f14.tar.bz2 |
properties editing is opie only and should not be in the mediaplayer
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 32 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 1 |
2 files changed, 0 insertions, 33 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6299328..10f1792 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -456,826 +456,794 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | void PlayListWidget::setActiveWindow() { | 460 | void PlayListWidget::setActiveWindow() { |
461 | qDebug("SETTING active window"); | 461 | qDebug("SETTING active window"); |
462 | // When we get raised we need to ensure that it switches views | 462 | // When we get raised we need to ensure that it switches views |
463 | char origView = mediaPlayerState->view(); | 463 | char origView = mediaPlayerState->view(); |
464 | mediaPlayerState->setView( 'l' ); // invalidate | 464 | mediaPlayerState->setView( 'l' ); // invalidate |
465 | mediaPlayerState->setView( origView ); // now switch back | 465 | mediaPlayerState->setView( origView ); // now switch back |
466 | } | 466 | } |
467 | 467 | ||
468 | 468 | ||
469 | void PlayListWidget::useSelectedDocument() { | 469 | void PlayListWidget::useSelectedDocument() { |
470 | d->setDocumentUsed = FALSE; | 470 | d->setDocumentUsed = FALSE; |
471 | } | 471 | } |
472 | 472 | ||
473 | 473 | ||
474 | const DocLnk *PlayListWidget::current() { // this is fugly | 474 | const DocLnk *PlayListWidget::current() { // this is fugly |
475 | 475 | ||
476 | switch (tabWidget->currentPageIndex()) { | 476 | switch (tabWidget->currentPageIndex()) { |
477 | case 0: //playlist | 477 | case 0: //playlist |
478 | { | 478 | { |
479 | qDebug("playlist"); | 479 | qDebug("playlist"); |
480 | if ( mediaPlayerState->playlist() ) { | 480 | if ( mediaPlayerState->playlist() ) { |
481 | return d->selectedFiles->current(); | 481 | return d->selectedFiles->current(); |
482 | } else if ( d->setDocumentUsed && d->current ) { | 482 | } else if ( d->setDocumentUsed && d->current ) { |
483 | return d->current; | 483 | return d->current; |
484 | } else { | 484 | } else { |
485 | return d->files->selected(); | 485 | return d->files->selected(); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | break; | 488 | break; |
489 | case 1://audio | 489 | case 1://audio |
490 | { | 490 | { |
491 | qDebug("audioView"); | 491 | qDebug("audioView"); |
492 | QListIterator<DocLnk> dit( files.children() ); | 492 | QListIterator<DocLnk> dit( files.children() ); |
493 | for ( ; dit.current(); ++dit ) { | 493 | for ( ; dit.current(); ++dit ) { |
494 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 494 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
495 | qDebug("here"); | 495 | qDebug("here"); |
496 | insanityBool=TRUE; | 496 | insanityBool=TRUE; |
497 | return dit; | 497 | return dit; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | } | 500 | } |
501 | break; | 501 | break; |
502 | case 2: // video | 502 | case 2: // video |
503 | { | 503 | { |
504 | qDebug("videoView"); | 504 | qDebug("videoView"); |
505 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 505 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
506 | for ( ; Vdit.current(); ++Vdit ) { | 506 | for ( ; Vdit.current(); ++Vdit ) { |
507 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 507 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
508 | insanityBool=TRUE; | 508 | insanityBool=TRUE; |
509 | return Vdit; | 509 | return Vdit; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | } | 512 | } |
513 | break; | 513 | break; |
514 | }; | 514 | }; |
515 | return 0; | 515 | return 0; |
516 | } | 516 | } |
517 | 517 | ||
518 | bool PlayListWidget::prev() { | 518 | bool PlayListWidget::prev() { |
519 | if ( mediaPlayerState->playlist() ) { | 519 | if ( mediaPlayerState->playlist() ) { |
520 | if ( mediaPlayerState->shuffled() ) { | 520 | if ( mediaPlayerState->shuffled() ) { |
521 | const DocLnk *cur = current(); | 521 | const DocLnk *cur = current(); |
522 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 522 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
523 | for ( int i = 0; i < j; i++ ) { | 523 | for ( int i = 0; i < j; i++ ) { |
524 | if ( !d->selectedFiles->next() ) | 524 | if ( !d->selectedFiles->next() ) |
525 | d->selectedFiles->first(); | 525 | d->selectedFiles->first(); |
526 | } | 526 | } |
527 | if ( cur == current() ) | 527 | if ( cur == current() ) |
528 | if ( !d->selectedFiles->next() ) | 528 | if ( !d->selectedFiles->next() ) |
529 | d->selectedFiles->first(); | 529 | d->selectedFiles->first(); |
530 | return TRUE; | 530 | return TRUE; |
531 | } else { | 531 | } else { |
532 | if ( !d->selectedFiles->prev() ) { | 532 | if ( !d->selectedFiles->prev() ) { |
533 | if ( mediaPlayerState->looping() ) { | 533 | if ( mediaPlayerState->looping() ) { |
534 | return d->selectedFiles->last(); | 534 | return d->selectedFiles->last(); |
535 | } else { | 535 | } else { |
536 | return FALSE; | 536 | return FALSE; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | return TRUE; | 539 | return TRUE; |
540 | } | 540 | } |
541 | } else { | 541 | } else { |
542 | return mediaPlayerState->looping(); | 542 | return mediaPlayerState->looping(); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | 545 | ||
546 | 546 | ||
547 | bool PlayListWidget::next() { | 547 | bool PlayListWidget::next() { |
548 | if ( mediaPlayerState->playlist() ) { | 548 | if ( mediaPlayerState->playlist() ) { |
549 | if ( mediaPlayerState->shuffled() ) { | 549 | if ( mediaPlayerState->shuffled() ) { |
550 | return prev(); | 550 | return prev(); |
551 | } else { | 551 | } else { |
552 | if ( !d->selectedFiles->next() ) { | 552 | if ( !d->selectedFiles->next() ) { |
553 | if ( mediaPlayerState->looping() ) { | 553 | if ( mediaPlayerState->looping() ) { |
554 | return d->selectedFiles->first(); | 554 | return d->selectedFiles->first(); |
555 | } else { | 555 | } else { |
556 | return FALSE; | 556 | return FALSE; |
557 | } | 557 | } |
558 | } | 558 | } |
559 | return TRUE; | 559 | return TRUE; |
560 | } | 560 | } |
561 | } else { | 561 | } else { |
562 | return mediaPlayerState->looping(); | 562 | return mediaPlayerState->looping(); |
563 | } | 563 | } |
564 | } | 564 | } |
565 | 565 | ||
566 | 566 | ||
567 | bool PlayListWidget::first() { | 567 | bool PlayListWidget::first() { |
568 | if ( mediaPlayerState->playlist() ) | 568 | if ( mediaPlayerState->playlist() ) |
569 | return d->selectedFiles->first(); | 569 | return d->selectedFiles->first(); |
570 | else | 570 | else |
571 | return mediaPlayerState->looping(); | 571 | return mediaPlayerState->looping(); |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | bool PlayListWidget::last() { | 575 | bool PlayListWidget::last() { |
576 | if ( mediaPlayerState->playlist() ) | 576 | if ( mediaPlayerState->playlist() ) |
577 | return d->selectedFiles->last(); | 577 | return d->selectedFiles->last(); |
578 | else | 578 | else |
579 | return mediaPlayerState->looping(); | 579 | return mediaPlayerState->looping(); |
580 | } | 580 | } |
581 | 581 | ||
582 | 582 | ||
583 | void PlayListWidget::saveList() { | 583 | void PlayListWidget::saveList() { |
584 | 584 | ||
585 | QString filename; | 585 | QString filename; |
586 | InputDialog *fileDlg = 0l; | 586 | InputDialog *fileDlg = 0l; |
587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
588 | fileDlg->exec(); | 588 | fileDlg->exec(); |
589 | if( fileDlg->result() == 1 ) { | 589 | if( fileDlg->result() == 1 ) { |
590 | if ( d->current ) | 590 | if ( d->current ) |
591 | delete d->current; | 591 | delete d->current; |
592 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 592 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
593 | // qDebug("saving playlist "+filename+".playlist"); | 593 | // qDebug("saving playlist "+filename+".playlist"); |
594 | Config cfg( filename +".playlist"); | 594 | Config cfg( filename +".playlist"); |
595 | writeConfig( cfg ); | 595 | writeConfig( cfg ); |
596 | 596 | ||
597 | DocLnk lnk; | 597 | DocLnk lnk; |
598 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 598 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
599 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 599 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
600 | lnk.setIcon("opieplayer2/playlist2"); | 600 | lnk.setIcon("opieplayer2/playlist2"); |
601 | lnk.setName( filename); //sets file name | 601 | lnk.setName( filename); //sets file name |
602 | // qDebug(filename); | 602 | // qDebug(filename); |
603 | if(!lnk.writeLink()) { | 603 | if(!lnk.writeLink()) { |
604 | qDebug("Writing doclink did not work"); | 604 | qDebug("Writing doclink did not work"); |
605 | } | 605 | } |
606 | } | 606 | } |
607 | Config config( "OpiePlayer" ); | 607 | Config config( "OpiePlayer" ); |
608 | config.writeEntry("CurrentPlaylist",filename); | 608 | config.writeEntry("CurrentPlaylist",filename); |
609 | setCaption(tr("OpiePlayer: ")+filename); | 609 | setCaption(tr("OpiePlayer: ")+filename); |
610 | d->selectedFiles->first(); | 610 | d->selectedFiles->first(); |
611 | if(fileDlg) { | 611 | if(fileDlg) { |
612 | delete fileDlg; | 612 | delete fileDlg; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | 615 | ||
616 | void PlayListWidget::loadList( const DocLnk & lnk) { | 616 | void PlayListWidget::loadList( const DocLnk & lnk) { |
617 | QString name= lnk.name(); | 617 | QString name= lnk.name(); |
618 | // qDebug("currentList is "+name); | 618 | // qDebug("currentList is "+name); |
619 | if( name.length()>1) { | 619 | if( name.length()>1) { |
620 | setCaption("OpiePlayer: "+name); | 620 | setCaption("OpiePlayer: "+name); |
621 | // qDebug("load list "+ name+".playlist"); | 621 | // qDebug("load list "+ name+".playlist"); |
622 | clearList(); | 622 | clearList(); |
623 | Config cfg( name+".playlist"); | 623 | Config cfg( name+".playlist"); |
624 | readConfig(cfg); | 624 | readConfig(cfg); |
625 | 625 | ||
626 | tabWidget->setCurrentPage(0); | 626 | tabWidget->setCurrentPage(0); |
627 | 627 | ||
628 | Config config( "OpiePlayer" ); | 628 | Config config( "OpiePlayer" ); |
629 | config.writeEntry("CurrentPlaylist", name); | 629 | config.writeEntry("CurrentPlaylist", name); |
630 | // d->selectedFiles->first(); | 630 | // d->selectedFiles->first(); |
631 | } | 631 | } |
632 | 632 | ||
633 | } | 633 | } |
634 | 634 | ||
635 | void PlayListWidget::setPlaylist( bool shown ) { | 635 | void PlayListWidget::setPlaylist( bool shown ) { |
636 | if ( shown ) { | 636 | if ( shown ) { |
637 | d->playListFrame->show(); | 637 | d->playListFrame->show(); |
638 | } else { | 638 | } else { |
639 | d->playListFrame->hide(); | 639 | d->playListFrame->hide(); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | void PlayListWidget::setView( char view ) { | 643 | void PlayListWidget::setView( char view ) { |
644 | if ( view == 'l' ) | 644 | if ( view == 'l' ) |
645 | showMaximized(); | 645 | showMaximized(); |
646 | else | 646 | else |
647 | hide(); | 647 | hide(); |
648 | } | 648 | } |
649 | 649 | ||
650 | void PlayListWidget::addSelected() { | 650 | void PlayListWidget::addSelected() { |
651 | 651 | ||
652 | Config cfg( "OpiePlayer" ); | 652 | Config cfg( "OpiePlayer" ); |
653 | cfg.setGroup("PlayList"); | 653 | cfg.setGroup("PlayList"); |
654 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 654 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
655 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 655 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
656 | 656 | ||
657 | switch (tabWidget->currentPageIndex()) { | 657 | switch (tabWidget->currentPageIndex()) { |
658 | case 0: //playlist | 658 | case 0: //playlist |
659 | break; | 659 | break; |
660 | case 1: { //audio | 660 | case 1: { //audio |
661 | QListViewItemIterator it( audioView ); | 661 | QListViewItemIterator it( audioView ); |
662 | // iterate through all items of the listview | 662 | // iterate through all items of the listview |
663 | for ( ; it.current(); ++it ) { | 663 | for ( ; it.current(); ++it ) { |
664 | if ( it.current()->isSelected() ) { | 664 | if ( it.current()->isSelected() ) { |
665 | QListIterator<DocLnk> dit( files.children() ); | 665 | QListIterator<DocLnk> dit( files.children() ); |
666 | for ( ; dit.current(); ++dit ) { | 666 | for ( ; dit.current(); ++dit ) { |
667 | if( dit.current()->name() == it.current()->text(0) ) { | 667 | if( dit.current()->name() == it.current()->text(0) ) { |
668 | if(QFileInfo( dit.current()->file()).exists()) | 668 | if(QFileInfo( dit.current()->file()).exists()) |
669 | d->selectedFiles->addToSelection( **dit ); | 669 | d->selectedFiles->addToSelection( **dit ); |
670 | } | 670 | } |
671 | } | 671 | } |
672 | audioView->setSelected( it.current(),FALSE); | 672 | audioView->setSelected( it.current(),FALSE); |
673 | } | 673 | } |
674 | } | 674 | } |
675 | tabWidget->setCurrentPage(0); | 675 | tabWidget->setCurrentPage(0); |
676 | } | 676 | } |
677 | break; | 677 | break; |
678 | case 2: { // video | 678 | case 2: { // video |
679 | QListViewItemIterator it( videoView ); | 679 | QListViewItemIterator it( videoView ); |
680 | // iterate through all items of the listview | 680 | // iterate through all items of the listview |
681 | for ( ; it.current(); ++it ) { | 681 | for ( ; it.current(); ++it ) { |
682 | if ( it.current()->isSelected() ) { | 682 | if ( it.current()->isSelected() ) { |
683 | QListIterator<DocLnk> dit( vFiles.children() ); | 683 | QListIterator<DocLnk> dit( vFiles.children() ); |
684 | for ( ; dit.current(); ++dit ) { | 684 | for ( ; dit.current(); ++dit ) { |
685 | if( dit.current()->name() == it.current()->text(0) ) { | 685 | if( dit.current()->name() == it.current()->text(0) ) { |
686 | if(QFileInfo( dit.current()->file()).exists()) | 686 | if(QFileInfo( dit.current()->file()).exists()) |
687 | d->selectedFiles->addToSelection( **dit ); | 687 | d->selectedFiles->addToSelection( **dit ); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | videoView->setSelected( it.current(),FALSE); | 690 | videoView->setSelected( it.current(),FALSE); |
691 | } | 691 | } |
692 | } | 692 | } |
693 | tabWidget->setCurrentPage(0); | 693 | tabWidget->setCurrentPage(0); |
694 | } | 694 | } |
695 | break; | 695 | break; |
696 | }; | 696 | }; |
697 | } | 697 | } |
698 | 698 | ||
699 | void PlayListWidget::removeSelected() { | 699 | void PlayListWidget::removeSelected() { |
700 | d->selectedFiles->removeSelected( ); | 700 | d->selectedFiles->removeSelected( ); |
701 | } | 701 | } |
702 | 702 | ||
703 | void PlayListWidget::playIt( QListViewItem *it) { | 703 | void PlayListWidget::playIt( QListViewItem *it) { |
704 | if(!it) return; | 704 | if(!it) return; |
705 | mediaPlayerState->setPlaying(FALSE); | 705 | mediaPlayerState->setPlaying(FALSE); |
706 | mediaPlayerState->setPlaying(TRUE); | 706 | mediaPlayerState->setPlaying(TRUE); |
707 | d->selectedFiles->unSelect(); | 707 | d->selectedFiles->unSelect(); |
708 | } | 708 | } |
709 | 709 | ||
710 | void PlayListWidget::addToSelection( QListViewItem *it) { | 710 | void PlayListWidget::addToSelection( QListViewItem *it) { |
711 | d->setDocumentUsed = FALSE; | 711 | d->setDocumentUsed = FALSE; |
712 | 712 | ||
713 | if(it) { | 713 | if(it) { |
714 | switch (tabWidget->currentPageIndex()) { | 714 | switch (tabWidget->currentPageIndex()) { |
715 | case 1: { | 715 | case 1: { |
716 | QListIterator<DocLnk> dit( files.children() ); | 716 | QListIterator<DocLnk> dit( files.children() ); |
717 | for ( ; dit.current(); ++dit ) { | 717 | for ( ; dit.current(); ++dit ) { |
718 | if( dit.current()->name() == it->text(0)) { | 718 | if( dit.current()->name() == it->text(0)) { |
719 | if(QFileInfo( dit.current()->file()).exists()) | 719 | if(QFileInfo( dit.current()->file()).exists()) |
720 | d->selectedFiles->addToSelection( **dit ); | 720 | d->selectedFiles->addToSelection( **dit ); |
721 | } | 721 | } |
722 | } | 722 | } |
723 | } | 723 | } |
724 | break; | 724 | break; |
725 | case 2: { | 725 | case 2: { |
726 | QListIterator<DocLnk> dit( vFiles.children() ); | 726 | QListIterator<DocLnk> dit( vFiles.children() ); |
727 | for ( ; dit.current(); ++dit ) { | 727 | for ( ; dit.current(); ++dit ) { |
728 | if( dit.current()->name() == it->text(0)) { | 728 | if( dit.current()->name() == it->text(0)) { |
729 | if(QFileInfo( dit.current()->file()).exists()) | 729 | if(QFileInfo( dit.current()->file()).exists()) |
730 | d->selectedFiles->addToSelection( **dit ); | 730 | d->selectedFiles->addToSelection( **dit ); |
731 | } | 731 | } |
732 | } | 732 | } |
733 | } | 733 | } |
734 | break; | 734 | break; |
735 | case 0: | 735 | case 0: |
736 | break; | 736 | break; |
737 | }; | 737 | }; |
738 | tabWidget->setCurrentPage(0); | 738 | tabWidget->setCurrentPage(0); |
739 | } | 739 | } |
740 | } | 740 | } |
741 | 741 | ||
742 | void PlayListWidget::tabChanged(QWidget *) { | 742 | void PlayListWidget::tabChanged(QWidget *) { |
743 | 743 | ||
744 | switch ( tabWidget->currentPageIndex()) { | 744 | switch ( tabWidget->currentPageIndex()) { |
745 | case 0: | 745 | case 0: |
746 | { | 746 | { |
747 | if( !tbDeletePlaylist->isHidden()) | 747 | if( !tbDeletePlaylist->isHidden()) |
748 | tbDeletePlaylist->hide(); | 748 | tbDeletePlaylist->hide(); |
749 | d->tbRemoveFromList->setEnabled(TRUE); | 749 | d->tbRemoveFromList->setEnabled(TRUE); |
750 | d->tbAddToList->setEnabled(FALSE); | 750 | d->tbAddToList->setEnabled(FALSE); |
751 | } | 751 | } |
752 | break; | 752 | break; |
753 | case 1: | 753 | case 1: |
754 | { | 754 | { |
755 | audioView->clear(); | 755 | audioView->clear(); |
756 | populateAudioView(); | 756 | populateAudioView(); |
757 | 757 | ||
758 | if( !tbDeletePlaylist->isHidden()) | 758 | if( !tbDeletePlaylist->isHidden()) |
759 | tbDeletePlaylist->hide(); | 759 | tbDeletePlaylist->hide(); |
760 | d->tbRemoveFromList->setEnabled(FALSE); | 760 | d->tbRemoveFromList->setEnabled(FALSE); |
761 | d->tbAddToList->setEnabled(TRUE); | 761 | d->tbAddToList->setEnabled(TRUE); |
762 | } | 762 | } |
763 | break; | 763 | break; |
764 | case 2: | 764 | case 2: |
765 | { | 765 | { |
766 | videoView->clear(); | 766 | videoView->clear(); |
767 | populateVideoView(); | 767 | populateVideoView(); |
768 | if( !tbDeletePlaylist->isHidden()) | 768 | if( !tbDeletePlaylist->isHidden()) |
769 | tbDeletePlaylist->hide(); | 769 | tbDeletePlaylist->hide(); |
770 | d->tbRemoveFromList->setEnabled(FALSE); | 770 | d->tbRemoveFromList->setEnabled(FALSE); |
771 | d->tbAddToList->setEnabled(TRUE); | 771 | d->tbAddToList->setEnabled(TRUE); |
772 | } | 772 | } |
773 | break; | 773 | break; |
774 | case 3: | 774 | case 3: |
775 | { | 775 | { |
776 | if( tbDeletePlaylist->isHidden()) | 776 | if( tbDeletePlaylist->isHidden()) |
777 | tbDeletePlaylist->show(); | 777 | tbDeletePlaylist->show(); |
778 | playLists->reread(); | 778 | playLists->reread(); |
779 | } | 779 | } |
780 | break; | 780 | break; |
781 | }; | 781 | }; |
782 | } | 782 | } |
783 | 783 | ||
784 | void PlayListWidget::btnPlay(bool b) { | 784 | void PlayListWidget::btnPlay(bool b) { |
785 | 785 | ||
786 | // mediaPlayerState->setPlaying(b); | 786 | // mediaPlayerState->setPlaying(b); |
787 | switch ( tabWidget->currentPageIndex()) { | 787 | switch ( tabWidget->currentPageIndex()) { |
788 | case 0: | 788 | case 0: |
789 | { | 789 | { |
790 | mediaPlayerState->setPlaying(b); | 790 | mediaPlayerState->setPlaying(b); |
791 | } | 791 | } |
792 | break; | 792 | break; |
793 | case 1: | 793 | case 1: |
794 | { | 794 | { |
795 | addToSelection( audioView->currentItem() ); | 795 | addToSelection( audioView->currentItem() ); |
796 | mediaPlayerState->setPlaying(b); | 796 | mediaPlayerState->setPlaying(b); |
797 | d->selectedFiles->removeSelected( ); | 797 | d->selectedFiles->removeSelected( ); |
798 | tabWidget->setCurrentPage(1); | 798 | tabWidget->setCurrentPage(1); |
799 | d->selectedFiles->unSelect(); | 799 | d->selectedFiles->unSelect(); |
800 | insanityBool=FALSE; | 800 | insanityBool=FALSE; |
801 | }// audioView->clearSelection(); | 801 | }// audioView->clearSelection(); |
802 | break; | 802 | break; |
803 | case 2: | 803 | case 2: |
804 | { | 804 | { |
805 | addToSelection( videoView->currentItem() ); | 805 | addToSelection( videoView->currentItem() ); |
806 | mediaPlayerState->setPlaying(b); | 806 | mediaPlayerState->setPlaying(b); |
807 | qApp->processEvents(); | 807 | qApp->processEvents(); |
808 | d->selectedFiles->removeSelected( ); | 808 | d->selectedFiles->removeSelected( ); |
809 | tabWidget->setCurrentPage(2); | 809 | tabWidget->setCurrentPage(2); |
810 | d->selectedFiles->unSelect(); | 810 | d->selectedFiles->unSelect(); |
811 | insanityBool=FALSE; | 811 | insanityBool=FALSE; |
812 | }// videoView->clearSelection(); | 812 | }// videoView->clearSelection(); |
813 | break; | 813 | break; |
814 | }; | 814 | }; |
815 | 815 | ||
816 | } | 816 | } |
817 | 817 | ||
818 | void PlayListWidget::deletePlaylist() { | 818 | void PlayListWidget::deletePlaylist() { |
819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
820 | (tr("You really want to delete\nthis playlist?")), | 820 | (tr("You really want to delete\nthis playlist?")), |
821 | (tr("Yes")), (tr("No")), 0 )){ | 821 | (tr("Yes")), (tr("No")), 0 )){ |
822 | case 0: // Yes clicked, | 822 | case 0: // Yes clicked, |
823 | QFile().remove(playLists->selected()->file()); | 823 | QFile().remove(playLists->selected()->file()); |
824 | QFile().remove(playLists->selected()->linkFile()); | 824 | QFile().remove(playLists->selected()->linkFile()); |
825 | playLists->reread(); | 825 | playLists->reread(); |
826 | break; | 826 | break; |
827 | case 1: // Cancel | 827 | case 1: // Cancel |
828 | break; | 828 | break; |
829 | }; | 829 | }; |
830 | } | 830 | } |
831 | 831 | ||
832 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 832 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
833 | switch (mouse) { | 833 | switch (mouse) { |
834 | case 1: | 834 | case 1: |
835 | break; | 835 | break; |
836 | case 2:{ | 836 | case 2:{ |
837 | QPopupMenu m; | 837 | QPopupMenu m; |
838 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 838 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
839 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 839 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
840 | m.insertSeparator(); | ||
841 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | ||
842 | m.exec( QCursor::pos() ); | 840 | m.exec( QCursor::pos() ); |
843 | } | 841 | } |
844 | break; | 842 | break; |
845 | }; | 843 | }; |
846 | } | 844 | } |
847 | 845 | ||
848 | void PlayListWidget::playSelected() { | 846 | void PlayListWidget::playSelected() { |
849 | btnPlay( TRUE); | 847 | btnPlay( TRUE); |
850 | } | 848 | } |
851 | 849 | ||
852 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 850 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
853 | switch (mouse) { | 851 | switch (mouse) { |
854 | case 1: | 852 | case 1: |
855 | 853 | ||
856 | break; | 854 | break; |
857 | case 2: | 855 | case 2: |
858 | { | 856 | { |
859 | QPopupMenu m; | 857 | QPopupMenu m; |
860 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 858 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
861 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 859 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
862 | m.exec( QCursor::pos() ); | 860 | m.exec( QCursor::pos() ); |
863 | } | 861 | } |
864 | break; | 862 | break; |
865 | }; | 863 | }; |
866 | } | 864 | } |
867 | 865 | ||
868 | void PlayListWidget::listDelete() { | ||
869 | Config cfg( "OpiePlayer" ); | ||
870 | cfg.setGroup("PlayList"); | ||
871 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
872 | QString file; | ||
873 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | ||
874 | switch ( tabWidget->currentPageIndex()) { | ||
875 | case 0: | ||
876 | break; | ||
877 | case 1: | ||
878 | { | ||
879 | file = audioView->currentItem()->text(0); | ||
880 | QListIterator<DocLnk> Pdit( files.children() ); | ||
881 | for ( ; Pdit.current(); ++Pdit ) { | ||
882 | if( Pdit.current()->name() == file) { | ||
883 | LnkProperties prop( Pdit.current() ); | ||
884 | prop.showMaximized(); | ||
885 | prop.exec(); | ||
886 | } | ||
887 | } | ||
888 | populateAudioView(); | ||
889 | } | ||
890 | break; | ||
891 | case 2: | ||
892 | { | ||
893 | |||
894 | } | ||
895 | break; | ||
896 | }; | ||
897 | } | ||
898 | 866 | ||
899 | void PlayListWidget::scanForAudio() { | 867 | void PlayListWidget::scanForAudio() { |
900 | qDebug("scan for audio"); | 868 | qDebug("scan for audio"); |
901 | files.detachChildren(); | 869 | files.detachChildren(); |
902 | QListIterator<DocLnk> sdit( files.children() ); | 870 | QListIterator<DocLnk> sdit( files.children() ); |
903 | for ( ; sdit.current(); ++sdit ) { | 871 | for ( ; sdit.current(); ++sdit ) { |
904 | delete sdit.current(); | 872 | delete sdit.current(); |
905 | } | 873 | } |
906 | Global::findDocuments(&files, "audio/*"); | 874 | Global::findDocuments(&files, "audio/*"); |
907 | audioScan = TRUE; | 875 | audioScan = TRUE; |
908 | } | 876 | } |
909 | 877 | ||
910 | void PlayListWidget::scanForVideo() { | 878 | void PlayListWidget::scanForVideo() { |
911 | qDebug("scan for video"); | 879 | qDebug("scan for video"); |
912 | vFiles.detachChildren(); | 880 | vFiles.detachChildren(); |
913 | QListIterator<DocLnk> sdit( vFiles.children() ); | 881 | QListIterator<DocLnk> sdit( vFiles.children() ); |
914 | for ( ; sdit.current(); ++sdit ) { | 882 | for ( ; sdit.current(); ++sdit ) { |
915 | delete sdit.current(); | 883 | delete sdit.current(); |
916 | } | 884 | } |
917 | Global::findDocuments(&vFiles, "video/*"); | 885 | Global::findDocuments(&vFiles, "video/*"); |
918 | videoScan = TRUE; | 886 | videoScan = TRUE; |
919 | } | 887 | } |
920 | 888 | ||
921 | void PlayListWidget::populateAudioView() { | 889 | void PlayListWidget::populateAudioView() { |
922 | 890 | ||
923 | audioView->clear(); | 891 | audioView->clear(); |
924 | StorageInfo storageInfo; | 892 | StorageInfo storageInfo; |
925 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 893 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
926 | if(!audioScan) scanForAudio(); | 894 | if(!audioScan) scanForAudio(); |
927 | 895 | ||
928 | QListIterator<DocLnk> dit( files.children() ); | 896 | QListIterator<DocLnk> dit( files.children() ); |
929 | QListIterator<FileSystem> it ( fs ); | 897 | QListIterator<FileSystem> it ( fs ); |
930 | 898 | ||
931 | QString storage; | 899 | QString storage; |
932 | for ( ; dit.current(); ++dit ) { | 900 | for ( ; dit.current(); ++dit ) { |
933 | for( ; it.current(); ++it ){ | 901 | for( ; it.current(); ++it ){ |
934 | const QString name = (*it)->name(); | 902 | const QString name = (*it)->name(); |
935 | const QString path = (*it)->path(); | 903 | const QString path = (*it)->path(); |
936 | if(dit.current()->file().find(path) != -1 ) storage=name; | 904 | if(dit.current()->file().find(path) != -1 ) storage=name; |
937 | } | 905 | } |
938 | 906 | ||
939 | QListViewItem * newItem; | 907 | QListViewItem * newItem; |
940 | if ( QFile( dit.current()->file()).exists() ) { | 908 | if ( QFile( dit.current()->file()).exists() ) { |
941 | // qDebug(dit.current()->name()); | 909 | // qDebug(dit.current()->name()); |
942 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 910 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
943 | QString::number( QFile( dit.current()->file()).size() ), storage); | 911 | QString::number( QFile( dit.current()->file()).size() ), storage); |
944 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); | 912 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); |
945 | } | 913 | } |
946 | } | 914 | } |
947 | 915 | ||
948 | } | 916 | } |
949 | 917 | ||
950 | void PlayListWidget::populateVideoView() { | 918 | void PlayListWidget::populateVideoView() { |
951 | videoView->clear(); | 919 | videoView->clear(); |
952 | StorageInfo storageInfo; | 920 | StorageInfo storageInfo; |
953 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 921 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
954 | 922 | ||
955 | if(!videoScan ) scanForVideo(); | 923 | if(!videoScan ) scanForVideo(); |
956 | 924 | ||
957 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 925 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
958 | QListIterator<FileSystem> it ( fs ); | 926 | QListIterator<FileSystem> it ( fs ); |
959 | videoView->clear(); | 927 | videoView->clear(); |
960 | QString storage; | 928 | QString storage; |
961 | for ( ; Vdit.current(); ++Vdit ) { | 929 | for ( ; Vdit.current(); ++Vdit ) { |
962 | for( ; it.current(); ++it ){ | 930 | for( ; it.current(); ++it ){ |
963 | const QString name = (*it)->name(); | 931 | const QString name = (*it)->name(); |
964 | const QString path = (*it)->path(); | 932 | const QString path = (*it)->path(); |
965 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 933 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
966 | } | 934 | } |
967 | 935 | ||
968 | QListViewItem * newItem; | 936 | QListViewItem * newItem; |
969 | if ( QFile( Vdit.current()->file()).exists() ) { | 937 | if ( QFile( Vdit.current()->file()).exists() ) { |
970 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 938 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
971 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 939 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
972 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); | 940 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); |
973 | } | 941 | } |
974 | } | 942 | } |
975 | } | 943 | } |
976 | 944 | ||
977 | void PlayListWidget::openFile() { | 945 | void PlayListWidget::openFile() { |
978 | QString filename, name; | 946 | QString filename, name; |
979 | InputDialog *fileDlg; | 947 | InputDialog *fileDlg; |
980 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 948 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
981 | fileDlg->exec(); | 949 | fileDlg->exec(); |
982 | if( fileDlg->result() == 1 ) { | 950 | if( fileDlg->result() == 1 ) { |
983 | filename = fileDlg->LineEdit1->text(); | 951 | filename = fileDlg->LineEdit1->text(); |
984 | 952 | ||
985 | qDebug("Selected filename is "+filename); | 953 | qDebug("Selected filename is "+filename); |
986 | if(filename.right(3) == "m3u") { | 954 | if(filename.right(3) == "m3u") { |
987 | readm3u( filename ); | 955 | readm3u( filename ); |
988 | } else if(filename.right(3) == "pls") { | 956 | } else if(filename.right(3) == "pls") { |
989 | readPls( filename ); | 957 | readPls( filename ); |
990 | } else { | 958 | } else { |
991 | DocLnk lnk; | 959 | DocLnk lnk; |
992 | 960 | ||
993 | lnk.setName(filename); //sets file name | 961 | lnk.setName(filename); //sets file name |
994 | lnk.setFile(filename); //sets File property | 962 | lnk.setFile(filename); //sets File property |
995 | lnk.setType("audio/x-mpegurl"); | 963 | lnk.setType("audio/x-mpegurl"); |
996 | lnk.setExec("opieplayer"); | 964 | lnk.setExec("opieplayer"); |
997 | lnk.setIcon("opieplayer2/MPEGPlayer"); | 965 | lnk.setIcon("opieplayer2/MPEGPlayer"); |
998 | 966 | ||
999 | if(!lnk.writeLink()) { | 967 | if(!lnk.writeLink()) { |
1000 | qDebug("Writing doclink did not work"); | 968 | qDebug("Writing doclink did not work"); |
1001 | } | 969 | } |
1002 | d->selectedFiles->addToSelection( lnk); | 970 | d->selectedFiles->addToSelection( lnk); |
1003 | } | 971 | } |
1004 | } | 972 | } |
1005 | if(fileDlg) { | 973 | if(fileDlg) { |
1006 | delete fileDlg; | 974 | delete fileDlg; |
1007 | } | 975 | } |
1008 | } | 976 | } |
1009 | 977 | ||
1010 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 978 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1011 | { | 979 | { |
1012 | switch ( e->key() ) { | 980 | switch ( e->key() ) { |
1013 | ////////////////////////////// Zaurus keys | 981 | ////////////////////////////// Zaurus keys |
1014 | case Key_F9: //activity | 982 | case Key_F9: //activity |
1015 | // if(audioUI->isHidden()) | 983 | // if(audioUI->isHidden()) |
1016 | // audioUI->showMaximized(); | 984 | // audioUI->showMaximized(); |
1017 | break; | 985 | break; |
1018 | case Key_F10: //contacts | 986 | case Key_F10: //contacts |
1019 | // if( videoUI->isHidden()) | 987 | // if( videoUI->isHidden()) |
1020 | // videoUI->showMaximized(); | 988 | // videoUI->showMaximized(); |
1021 | break; | 989 | break; |
1022 | case Key_F11: //menu | 990 | case Key_F11: //menu |
1023 | break; | 991 | break; |
1024 | case Key_F12: //home | 992 | case Key_F12: //home |
1025 | // doBlank(); | 993 | // doBlank(); |
1026 | break; | 994 | break; |
1027 | case Key_F13: //mail | 995 | case Key_F13: //mail |
1028 | // doUnblank(); | 996 | // doUnblank(); |
1029 | break; | 997 | break; |
1030 | case Key_Q: //add to playlist | 998 | case Key_Q: //add to playlist |
1031 | qDebug("Add"); | 999 | qDebug("Add"); |
1032 | addSelected(); | 1000 | addSelected(); |
1033 | break; | 1001 | break; |
1034 | case Key_R: //remove from playlist | 1002 | case Key_R: //remove from playlist |
1035 | removeSelected(); | 1003 | removeSelected(); |
1036 | break; | 1004 | break; |
1037 | // case Key_P: //play | 1005 | // case Key_P: //play |
1038 | // qDebug("Play"); | 1006 | // qDebug("Play"); |
1039 | // playSelected(); | 1007 | // playSelected(); |
1040 | // break; | 1008 | // break; |
1041 | case Key_Space: | 1009 | case Key_Space: |
1042 | qDebug("Play"); | 1010 | qDebug("Play"); |
1043 | // playSelected(); puh | 1011 | // playSelected(); puh |
1044 | break; | 1012 | break; |
1045 | case Key_1: | 1013 | case Key_1: |
1046 | tabWidget->setCurrentPage(0); | 1014 | tabWidget->setCurrentPage(0); |
1047 | break; | 1015 | break; |
1048 | case Key_2: | 1016 | case Key_2: |
1049 | tabWidget->setCurrentPage(1); | 1017 | tabWidget->setCurrentPage(1); |
1050 | break; | 1018 | break; |
1051 | case Key_3: | 1019 | case Key_3: |
1052 | tabWidget->setCurrentPage(2); | 1020 | tabWidget->setCurrentPage(2); |
1053 | break; | 1021 | break; |
1054 | case Key_4: | 1022 | case Key_4: |
1055 | tabWidget->setCurrentPage(3); | 1023 | tabWidget->setCurrentPage(3); |
1056 | break; | 1024 | break; |
1057 | case Key_Down: | 1025 | case Key_Down: |
1058 | if ( !d->selectedFiles->next() ) | 1026 | if ( !d->selectedFiles->next() ) |
1059 | d->selectedFiles->first(); | 1027 | d->selectedFiles->first(); |
1060 | 1028 | ||
1061 | break; | 1029 | break; |
1062 | case Key_Up: | 1030 | case Key_Up: |
1063 | if ( !d->selectedFiles->prev() ) | 1031 | if ( !d->selectedFiles->prev() ) |
1064 | // d->selectedFiles->last(); | 1032 | // d->selectedFiles->last(); |
1065 | 1033 | ||
1066 | break; | 1034 | break; |
1067 | 1035 | ||
1068 | } | 1036 | } |
1069 | } | 1037 | } |
1070 | 1038 | ||
1071 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1039 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1072 | { | 1040 | { |
1073 | // qDebug("Key press"); | 1041 | // qDebug("Key press"); |
1074 | // switch ( e->key() ) { | 1042 | // switch ( e->key() ) { |
1075 | // ////////////////////////////// Zaurus keys | 1043 | // ////////////////////////////// Zaurus keys |
1076 | // case Key_A: //add to playlist | 1044 | // case Key_A: //add to playlist |
1077 | // qDebug("Add"); | 1045 | // qDebug("Add"); |
1078 | // addSelected(); | 1046 | // addSelected(); |
1079 | // break; | 1047 | // break; |
1080 | // case Key_R: //remove from playlist | 1048 | // case Key_R: //remove from playlist |
1081 | // removeSelected(); | 1049 | // removeSelected(); |
1082 | // break; | 1050 | // break; |
1083 | // case Key_P: //play | 1051 | // case Key_P: //play |
1084 | // qDebug("Play"); | 1052 | // qDebug("Play"); |
1085 | // playSelected(); | 1053 | // playSelected(); |
1086 | // break; | 1054 | // break; |
1087 | // case Key_Space: | 1055 | // case Key_Space: |
1088 | // qDebug("Play"); | 1056 | // qDebug("Play"); |
1089 | // playSelected(); | 1057 | // playSelected(); |
1090 | // break; | 1058 | // break; |
1091 | // } | 1059 | // } |
1092 | } | 1060 | } |
1093 | 1061 | ||
1094 | 1062 | ||
1095 | 1063 | ||
1096 | void PlayListWidget::readm3u(const QString &filename) { | 1064 | void PlayListWidget::readm3u(const QString &filename) { |
1097 | 1065 | ||
1098 | qDebug("m3u filename is "+filename); | 1066 | qDebug("m3u filename is "+filename); |
1099 | QFile f(filename); | 1067 | QFile f(filename); |
1100 | 1068 | ||
1101 | if(f.open(IO_ReadOnly)) { | 1069 | if(f.open(IO_ReadOnly)) { |
1102 | QTextStream t(&f); | 1070 | QTextStream t(&f); |
1103 | QString s;//, first, second; | 1071 | QString s;//, first, second; |
1104 | int i=0; | 1072 | int i=0; |
1105 | while ( !t.atEnd()) { | 1073 | while ( !t.atEnd()) { |
1106 | s=t.readLine(); | 1074 | s=t.readLine(); |
1107 | 1075 | ||
1108 | if(s.find("#",0,TRUE) == -1) { | 1076 | if(s.find("#",0,TRUE) == -1) { |
1109 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1077 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1110 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1078 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1111 | s=s.right(s.length()-2); | 1079 | s=s.right(s.length()-2); |
1112 | // if(QFile(s).exists()) { | 1080 | // if(QFile(s).exists()) { |
1113 | DocLnk lnk( s ); | 1081 | DocLnk lnk( s ); |
1114 | QFileInfo f(s); | 1082 | QFileInfo f(s); |
1115 | QString name = f.baseName(); | 1083 | QString name = f.baseName(); |
1116 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1084 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1117 | lnk.setName( name ); | 1085 | lnk.setName( name ); |
1118 | s=s.replace( QRegExp("\\"),"/"); | 1086 | s=s.replace( QRegExp("\\"),"/"); |
1119 | lnk.setFile( s ); | 1087 | lnk.setFile( s ); |
1120 | lnk.writeLink(); | 1088 | lnk.writeLink(); |
1121 | qDebug("add "+name); | 1089 | qDebug("add "+name); |
1122 | d->selectedFiles->addToSelection( lnk); | 1090 | d->selectedFiles->addToSelection( lnk); |
1123 | // } | 1091 | // } |
1124 | } else { // is url | 1092 | } else { // is url |
1125 | s.replace(QRegExp("%20")," "); | 1093 | s.replace(QRegExp("%20")," "); |
1126 | DocLnk lnk( s ); | 1094 | DocLnk lnk( s ); |
1127 | QString name; | 1095 | QString name; |
1128 | if(name.left(4)=="http") { | 1096 | if(name.left(4)=="http") { |
1129 | name = s.right( s.length() - 7); | 1097 | name = s.right( s.length() - 7); |
1130 | } else { | 1098 | } else { |
1131 | name = s; | 1099 | name = s; |
1132 | } | 1100 | } |
1133 | lnk.setName(name); | 1101 | lnk.setName(name); |
1134 | if(s.at(s.length()-4) == '.') { | 1102 | if(s.at(s.length()-4) == '.') { |
1135 | lnk.setFile( s); | 1103 | lnk.setFile( s); |
1136 | } else { | 1104 | } else { |
1137 | lnk.setFile( s+"/"); | 1105 | lnk.setFile( s+"/"); |
1138 | } | 1106 | } |
1139 | lnk.setType("audio/x-mpegurl"); | 1107 | lnk.setType("audio/x-mpegurl"); |
1140 | lnk.writeLink(); | 1108 | lnk.writeLink(); |
1141 | d->selectedFiles->addToSelection( lnk); | 1109 | d->selectedFiles->addToSelection( lnk); |
1142 | } | 1110 | } |
1143 | i++; | 1111 | i++; |
1144 | } | 1112 | } |
1145 | } | 1113 | } |
1146 | } | 1114 | } |
1147 | } | 1115 | } |
1148 | f.close(); | 1116 | f.close(); |
1149 | } | 1117 | } |
1150 | 1118 | ||
1151 | void PlayListWidget::writem3u() { | 1119 | void PlayListWidget::writem3u() { |
1152 | 1120 | ||
1153 | InputDialog *fileDlg; | 1121 | InputDialog *fileDlg; |
1154 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1122 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1155 | fileDlg->exec(); | 1123 | fileDlg->exec(); |
1156 | QString filename,list; | 1124 | QString filename,list; |
1157 | if( fileDlg->result() == 1 ) { | 1125 | if( fileDlg->result() == 1 ) { |
1158 | filename = fileDlg->LineEdit1->text(); | 1126 | filename = fileDlg->LineEdit1->text(); |
1159 | qDebug(filename); | 1127 | qDebug(filename); |
1160 | int noOfFiles = 0; | 1128 | int noOfFiles = 0; |
1161 | d->selectedFiles->first(); | 1129 | d->selectedFiles->first(); |
1162 | do { | 1130 | do { |
1163 | // we dont check for existance because of url's | 1131 | // we dont check for existance because of url's |
1164 | // qDebug(d->selectedFiles->current()->file()); | 1132 | // qDebug(d->selectedFiles->current()->file()); |
1165 | list += d->selectedFiles->current()->file()+"\n"; | 1133 | list += d->selectedFiles->current()->file()+"\n"; |
1166 | noOfFiles++; | 1134 | noOfFiles++; |
1167 | } | 1135 | } |
1168 | while ( d->selectedFiles->next() ); | 1136 | while ( d->selectedFiles->next() ); |
1169 | qDebug(list); | 1137 | qDebug(list); |
1170 | if(filename.left(1) != "/") | 1138 | if(filename.left(1) != "/") |
1171 | filename=QPEApplication::documentDir()+"/"+filename; | 1139 | filename=QPEApplication::documentDir()+"/"+filename; |
1172 | if(filename.right(3) != "m3u") | 1140 | if(filename.right(3) != "m3u") |
1173 | filename=filename+".m3u"; | 1141 | filename=filename+".m3u"; |
1174 | 1142 | ||
1175 | QFile f(filename); | 1143 | QFile f(filename); |
1176 | f.open(IO_WriteOnly); | 1144 | f.open(IO_WriteOnly); |
1177 | f.writeBlock(list, list.length()); | 1145 | f.writeBlock(list, list.length()); |
1178 | f.close(); | 1146 | f.close(); |
1179 | } | 1147 | } |
1180 | if(fileDlg) delete fileDlg; | 1148 | if(fileDlg) delete fileDlg; |
1181 | } | 1149 | } |
1182 | 1150 | ||
1183 | void PlayListWidget::readPls(const QString &filename) { | 1151 | void PlayListWidget::readPls(const QString &filename) { |
1184 | 1152 | ||
1185 | qDebug("pls filename is "+filename); | 1153 | qDebug("pls filename is "+filename); |
1186 | QFile f(filename); | 1154 | QFile f(filename); |
1187 | 1155 | ||
1188 | if(f.open(IO_ReadOnly)) { | 1156 | if(f.open(IO_ReadOnly)) { |
1189 | QTextStream t(&f); | 1157 | QTextStream t(&f); |
1190 | QString s;//, first, second; | 1158 | QString s;//, first, second; |
1191 | int i=0; | 1159 | int i=0; |
1192 | while ( !t.atEnd()) { | 1160 | while ( !t.atEnd()) { |
1193 | s=t.readLine(); | 1161 | s=t.readLine(); |
1194 | if(s.left(4) == "File") { | 1162 | if(s.left(4) == "File") { |
1195 | s=s.right(s.length() - 6); | 1163 | s=s.right(s.length() - 6); |
1196 | s.replace(QRegExp("%20")," "); | 1164 | s.replace(QRegExp("%20")," "); |
1197 | qDebug("adding "+s+" to playlist"); | 1165 | qDebug("adding "+s+" to playlist"); |
1198 | // numberofentries=2 | 1166 | // numberofentries=2 |
1199 | // File1=http | 1167 | // File1=http |
1200 | // Title | 1168 | // Title |
1201 | // Length | 1169 | // Length |
1202 | // Version | 1170 | // Version |
1203 | // File2=http | 1171 | // File2=http |
1204 | s=s.replace( QRegExp("\\"),"/"); | 1172 | s=s.replace( QRegExp("\\"),"/"); |
1205 | DocLnk lnk( s ); | 1173 | DocLnk lnk( s ); |
1206 | QFileInfo f(s); | 1174 | QFileInfo f(s); |
1207 | QString name = f.baseName(); | 1175 | QString name = f.baseName(); |
1208 | if(name.left(4)=="http") | 1176 | if(name.left(4)=="http") |
1209 | name = s.right( s.length() - 7); | 1177 | name = s.right( s.length() - 7); |
1210 | else | 1178 | else |
1211 | name=s; | 1179 | name=s; |
1212 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1180 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1213 | lnk.setName( name); | 1181 | lnk.setName( name); |
1214 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1182 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1215 | lnk.setFile( s); | 1183 | lnk.setFile( s); |
1216 | else { //if its a url | 1184 | else { //if its a url |
1217 | if( name.right(1).find('/') == -1) | 1185 | if( name.right(1).find('/') == -1) |
1218 | s+="/"; | 1186 | s+="/"; |
1219 | lnk.setFile( s); | 1187 | lnk.setFile( s); |
1220 | } | 1188 | } |
1221 | lnk.setType("audio/x-mpegurl"); | 1189 | lnk.setType("audio/x-mpegurl"); |
1222 | 1190 | ||
1223 | qDebug("DocLnk add "+name); | 1191 | qDebug("DocLnk add "+name); |
1224 | d->selectedFiles->addToSelection( lnk); | 1192 | d->selectedFiles->addToSelection( lnk); |
1225 | } | 1193 | } |
1226 | } | 1194 | } |
1227 | i++; | 1195 | i++; |
1228 | } | 1196 | } |
1229 | } | 1197 | } |
1230 | 1198 | ||
1231 | void PlayListWidget::pmViewActivated(int index) { | 1199 | void PlayListWidget::pmViewActivated(int index) { |
1232 | qDebug("%d", index); | 1200 | qDebug("%d", index); |
1233 | switch(index) { | 1201 | switch(index) { |
1234 | case -16: | 1202 | case -16: |
1235 | { | 1203 | { |
1236 | 1204 | ||
1237 | mediaPlayerState->toggleFullscreen(); | 1205 | mediaPlayerState->toggleFullscreen(); |
1238 | bool b=mediaPlayerState->fullscreen(); | 1206 | bool b=mediaPlayerState->fullscreen(); |
1239 | pmView->setItemChecked( index,b); | 1207 | pmView->setItemChecked( index,b); |
1240 | Config cfg( "OpiePlayer" ); | 1208 | Config cfg( "OpiePlayer" ); |
1241 | cfg.writeEntry("FullScreen", b); | 1209 | cfg.writeEntry("FullScreen", b); |
1242 | 1210 | ||
1243 | } | 1211 | } |
1244 | break; | 1212 | break; |
1245 | }; | 1213 | }; |
1246 | } | 1214 | } |
1247 | 1215 | ||
1248 | void PlayListWidget::populateSkinsMenu() { | 1216 | void PlayListWidget::populateSkinsMenu() { |
1249 | int item=0; | 1217 | int item=0; |
1250 | defaultSkinIndex=0; | 1218 | defaultSkinIndex=0; |
1251 | QString skinName; | 1219 | QString skinName; |
1252 | Config cfg( "OpiePlayer" ); | 1220 | Config cfg( "OpiePlayer" ); |
1253 | cfg.setGroup("Options"); | 1221 | cfg.setGroup("Options"); |
1254 | QString skin = cfg.readEntry("Skin","default"); | 1222 | QString skin = cfg.readEntry("Skin","default"); |
1255 | 1223 | ||
1256 | QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); | 1224 | QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); |
1257 | skinsDir.setFilter( QDir::Dirs); | 1225 | skinsDir.setFilter( QDir::Dirs); |
1258 | skinsDir.setSorting(QDir::Name); | 1226 | skinsDir.setSorting(QDir::Name); |
1259 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1227 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1260 | QFileInfoListIterator it( *skinslist ); | 1228 | QFileInfoListIterator it( *skinslist ); |
1261 | QFileInfo *fi; | 1229 | QFileInfo *fi; |
1262 | while ( (fi=it.current()) ) { | 1230 | while ( (fi=it.current()) ) { |
1263 | skinName = fi->fileName(); | 1231 | skinName = fi->fileName(); |
1264 | qDebug( fi->fileName()); | 1232 | qDebug( fi->fileName()); |
1265 | if( skinName != "." && skinName != ".." && skinName !="CVS") | 1233 | if( skinName != "." && skinName != ".." && skinName !="CVS") |
1266 | item = skinsMenu->insertItem( fi->fileName()); | 1234 | item = skinsMenu->insertItem( fi->fileName()); |
1267 | if( skinName == "default") | 1235 | if( skinName == "default") |
1268 | defaultSkinIndex = item; | 1236 | defaultSkinIndex = item; |
1269 | if( skinName == skin) | 1237 | if( skinName == skin) |
1270 | skinsMenu->setItemChecked( item, TRUE); | 1238 | skinsMenu->setItemChecked( item, TRUE); |
1271 | 1239 | ||
1272 | ++it; | 1240 | ++it; |
1273 | } | 1241 | } |
1274 | } | 1242 | } |
1275 | 1243 | ||
1276 | void PlayListWidget::skinsMenuActivated(int item) { | 1244 | void PlayListWidget::skinsMenuActivated(int item) { |
1277 | for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { | 1245 | for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { |
1278 | skinsMenu->setItemChecked( i, FALSE); | 1246 | skinsMenu->setItemChecked( i, FALSE); |
1279 | } | 1247 | } |
1280 | skinsMenu->setItemChecked( item, TRUE); | 1248 | skinsMenu->setItemChecked( item, TRUE); |
1281 | 1249 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index dd4bee0..8076707 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,112 +1,111 @@ | |||
1 | 1 | ||
2 | #ifndef PLAY_LIST_WIDGET_H | 2 | #ifndef PLAY_LIST_WIDGET_H |
3 | #define PLAY_LIST_WIDGET_H | 3 | #define PLAY_LIST_WIDGET_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | #include <qtabwidget.h> | 7 | #include <qtabwidget.h> |
8 | #include <qpe/fileselector.h> | 8 | #include <qpe/fileselector.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qpopupmenu.h> | 10 | #include <qpopupmenu.h> |
11 | 11 | ||
12 | /* #include <qtimer.h> */ | 12 | /* #include <qtimer.h> */ |
13 | 13 | ||
14 | 14 | ||
15 | class PlayListWidgetPrivate; | 15 | class PlayListWidgetPrivate; |
16 | class Config; | 16 | class Config; |
17 | class QListViewItem; | 17 | class QListViewItem; |
18 | class QListView; | 18 | class QListView; |
19 | class QPoint; | 19 | class QPoint; |
20 | class QAction; | 20 | class QAction; |
21 | class QLabel; | 21 | class QLabel; |
22 | 22 | ||
23 | class PlayListWidget : public QMainWindow { | 23 | class PlayListWidget : public QMainWindow { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
27 | ~PlayListWidget(); | 27 | ~PlayListWidget(); |
28 | QTabWidget * tabWidget; | 28 | QTabWidget * tabWidget; |
29 | // MenuItem *fullScreenButton, *scaleButton; | 29 | // MenuItem *fullScreenButton, *scaleButton; |
30 | // QAction *fullScreenButton, *scaleButton; | 30 | // QAction *fullScreenButton, *scaleButton; |
31 | DocLnkSet files; | 31 | DocLnkSet files; |
32 | DocLnkSet vFiles; | 32 | DocLnkSet vFiles; |
33 | QListView *audioView, *videoView, *playlistView; | 33 | QListView *audioView, *videoView, *playlistView; |
34 | QLabel *libString; | 34 | QLabel *libString; |
35 | QPopupMenu *pmView ; | 35 | QPopupMenu *pmView ; |
36 | bool fromSetDocument; | 36 | bool fromSetDocument; |
37 | bool insanityBool; | 37 | bool insanityBool; |
38 | QString setDocFileRef; | 38 | QString setDocFileRef; |
39 | // retrieve the current playlist entry (media file link) | 39 | // retrieve the current playlist entry (media file link) |
40 | const DocLnk *current(); | 40 | const DocLnk *current(); |
41 | void useSelectedDocument(); | 41 | void useSelectedDocument(); |
42 | /* QTimer * menuTimer; */ | 42 | /* QTimer * menuTimer; */ |
43 | FileSelector* playLists; | 43 | FileSelector* playLists; |
44 | QPushButton *tbDeletePlaylist; | 44 | QPushButton *tbDeletePlaylist; |
45 | int selected; | 45 | int selected; |
46 | public slots: | 46 | public slots: |
47 | bool first(); | 47 | bool first(); |
48 | bool last(); | 48 | bool last(); |
49 | bool next(); | 49 | bool next(); |
50 | bool prev(); | 50 | bool prev(); |
51 | /* void setFullScreen(); */ | 51 | /* void setFullScreen(); */ |
52 | /* void setScaled(); */ | 52 | /* void setScaled(); */ |
53 | protected: | 53 | protected: |
54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
56 | void keyReleaseEvent( QKeyEvent *e); | 56 | void keyReleaseEvent( QKeyEvent *e); |
57 | void keyPressEvent( QKeyEvent *e); | 57 | void keyPressEvent( QKeyEvent *e); |
58 | private: | 58 | private: |
59 | int defaultSkinIndex; | 59 | int defaultSkinIndex; |
60 | QPopupMenu *skinsMenu; | 60 | QPopupMenu *skinsMenu; |
61 | bool audioScan, videoScan; | 61 | bool audioScan, videoScan; |
62 | void readm3u(const QString &); | 62 | void readm3u(const QString &); |
63 | void readPls(const QString &); | 63 | void readPls(const QString &); |
64 | 64 | ||
65 | void initializeStates(); | 65 | void initializeStates(); |
66 | void readConfig( Config& cfg ); | 66 | void readConfig( Config& cfg ); |
67 | void writeConfig( Config& cfg ) const; | 67 | void writeConfig( Config& cfg ) const; |
68 | PlayListWidgetPrivate *d; // Private implementation data | 68 | PlayListWidgetPrivate *d; // Private implementation data |
69 | void populateAudioView(); | 69 | void populateAudioView(); |
70 | void populateVideoView(); | 70 | void populateVideoView(); |
71 | private slots: | 71 | private slots: |
72 | void populateSkinsMenu(); | 72 | void populateSkinsMenu(); |
73 | void skinsMenuActivated(int); | 73 | void skinsMenuActivated(int); |
74 | void pmViewActivated(int); | 74 | void pmViewActivated(int); |
75 | void writem3u(); | 75 | void writem3u(); |
76 | void scanForAudio(); | 76 | void scanForAudio(); |
77 | void scanForVideo(); | 77 | void scanForVideo(); |
78 | void openFile(); | 78 | void openFile(); |
79 | void setDocument( const QString& fileref ); | 79 | void setDocument( const QString& fileref ); |
80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
82 | void setActiveWindow(); // need to handle this to show the right view | 82 | void setActiveWindow(); // need to handle this to show the right view |
83 | void setPlaylist( bool ); // Show/Hide the playlist | 83 | void setPlaylist( bool ); // Show/Hide the playlist |
84 | void setView( char ); | 84 | void setView( char ); |
85 | void clearList(); | 85 | void clearList(); |
86 | void addAllToList(); | 86 | void addAllToList(); |
87 | void addAllMusicToList(); | 87 | void addAllMusicToList(); |
88 | void addAllVideoToList(); | 88 | void addAllVideoToList(); |
89 | void saveList(); // Save the playlist | 89 | void saveList(); // Save the playlist |
90 | void loadList( const DocLnk &); // Load a playlist | 90 | void loadList( const DocLnk &); // Load a playlist |
91 | void playIt( QListViewItem *); | 91 | void playIt( QListViewItem *); |
92 | 92 | ||
93 | void btnPlay(bool); | 93 | void btnPlay(bool); |
94 | void deletePlaylist(); | 94 | void deletePlaylist(); |
95 | void addSelected(); | 95 | void addSelected(); |
96 | void removeSelected(); | 96 | void removeSelected(); |
97 | void tabChanged(QWidget*); | 97 | void tabChanged(QWidget*); |
98 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 98 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
100 | void playSelected(); | 100 | void playSelected(); |
101 | void listDelete(); | ||
102 | 101 | ||
103 | protected slots: | 102 | protected slots: |
104 | /* void cancelMenuTimer(); */ | 103 | /* void cancelMenuTimer(); */ |
105 | /* void showFileMenu(); */ | 104 | /* void showFileMenu(); */ |
106 | 105 | ||
107 | 106 | ||
108 | }; | 107 | }; |
109 | 108 | ||
110 | 109 | ||
111 | #endif // PLAY_LIST_WIDGET_H | 110 | #endif // PLAY_LIST_WIDGET_H |
112 | 111 | ||