-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 1dee422..9065d63 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -587,518 +587,517 @@ void PlayListWidget::loadList( const DocLnk & lnk) { | |||
587 | if( name.length()>1) { | 587 | if( name.length()>1) { |
588 | setCaption("OpiePlayer: "+name); | 588 | setCaption("OpiePlayer: "+name); |
589 | // qDebug("load list "+ name+".playlist"); | 589 | // qDebug("load list "+ name+".playlist"); |
590 | clearList(); | 590 | clearList(); |
591 | Config cfg( name+".playlist"); | 591 | Config cfg( name+".playlist"); |
592 | readConfig(cfg); | 592 | readConfig(cfg); |
593 | 593 | ||
594 | tabWidget->setCurrentPage(0); | 594 | tabWidget->setCurrentPage(0); |
595 | 595 | ||
596 | Config config( "OpiePlayer" ); | 596 | Config config( "OpiePlayer" ); |
597 | config.writeEntry("CurrentPlaylist", name); | 597 | config.writeEntry("CurrentPlaylist", name); |
598 | // d->selectedFiles->first(); | 598 | // d->selectedFiles->first(); |
599 | } | 599 | } |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void PlayListWidget::setPlaylist( bool shown ) { | 603 | void PlayListWidget::setPlaylist( bool shown ) { |
604 | if ( shown ) { | 604 | if ( shown ) { |
605 | d->playListFrame->show(); | 605 | d->playListFrame->show(); |
606 | } else { | 606 | } else { |
607 | d->playListFrame->hide(); | 607 | d->playListFrame->hide(); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | 610 | ||
611 | void PlayListWidget::setView( char view ) { | 611 | void PlayListWidget::setView( char view ) { |
612 | if ( view == 'l' ) | 612 | if ( view == 'l' ) |
613 | showMaximized(); | 613 | showMaximized(); |
614 | else | 614 | else |
615 | hide(); | 615 | hide(); |
616 | } | 616 | } |
617 | 617 | ||
618 | void PlayListWidget::addSelected() { | 618 | void PlayListWidget::addSelected() { |
619 | 619 | ||
620 | Config cfg( "OpiePlayer" ); | 620 | Config cfg( "OpiePlayer" ); |
621 | cfg.setGroup("PlayList"); | 621 | cfg.setGroup("PlayList"); |
622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 622 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
624 | 624 | ||
625 | switch (tabWidget->currentPageIndex()) { | 625 | switch (tabWidget->currentPageIndex()) { |
626 | case 0: //playlist | 626 | case 0: //playlist |
627 | break; | 627 | break; |
628 | case 1: { //audio | 628 | case 1: { //audio |
629 | QListViewItemIterator it( audioView ); | 629 | QListViewItemIterator it( audioView ); |
630 | // iterate through all items of the listview | 630 | // iterate through all items of the listview |
631 | for ( ; it.current(); ++it ) { | 631 | for ( ; it.current(); ++it ) { |
632 | if ( it.current()->isSelected() ) { | 632 | if ( it.current()->isSelected() ) { |
633 | QListIterator<DocLnk> dit( files.children() ); | 633 | QListIterator<DocLnk> dit( files.children() ); |
634 | for ( ; dit.current(); ++dit ) { | 634 | for ( ; dit.current(); ++dit ) { |
635 | if( dit.current()->name() == it.current()->text(0) ) { | 635 | if( dit.current()->name() == it.current()->text(0) ) { |
636 | d->selectedFiles->addToSelection( **dit ); | 636 | d->selectedFiles->addToSelection( **dit ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | audioView->setSelected( it.current(),FALSE); | 639 | audioView->setSelected( it.current(),FALSE); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | tabWidget->setCurrentPage(0); | 642 | tabWidget->setCurrentPage(0); |
643 | } | 643 | } |
644 | break; | 644 | break; |
645 | case 2: { // video | 645 | case 2: { // video |
646 | QListViewItemIterator it( videoView ); | 646 | QListViewItemIterator it( videoView ); |
647 | // iterate through all items of the listview | 647 | // iterate through all items of the listview |
648 | for ( ; it.current(); ++it ) { | 648 | for ( ; it.current(); ++it ) { |
649 | if ( it.current()->isSelected() ) { | 649 | if ( it.current()->isSelected() ) { |
650 | QListIterator<DocLnk> dit( vFiles.children() ); | 650 | QListIterator<DocLnk> dit( vFiles.children() ); |
651 | for ( ; dit.current(); ++dit ) { | 651 | for ( ; dit.current(); ++dit ) { |
652 | if( dit.current()->name() == it.current()->text(0) ) { | 652 | if( dit.current()->name() == it.current()->text(0) ) { |
653 | d->selectedFiles->addToSelection( **dit ); | 653 | d->selectedFiles->addToSelection( **dit ); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | videoView->setSelected( it.current(),FALSE); | 656 | videoView->setSelected( it.current(),FALSE); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | tabWidget->setCurrentPage(0); | 659 | tabWidget->setCurrentPage(0); |
660 | } | 660 | } |
661 | break; | 661 | break; |
662 | }; | 662 | }; |
663 | } | 663 | } |
664 | 664 | ||
665 | void PlayListWidget::removeSelected() { | 665 | void PlayListWidget::removeSelected() { |
666 | d->selectedFiles->removeSelected( ); | 666 | d->selectedFiles->removeSelected( ); |
667 | } | 667 | } |
668 | 668 | ||
669 | void PlayListWidget::playIt( QListViewItem *it) { | 669 | void PlayListWidget::playIt( QListViewItem *it) { |
670 | qDebug("playIt"); | 670 | qDebug("playIt"); |
671 | mediaPlayerState->setPlaying(FALSE); | 671 | mediaPlayerState->setPlaying(FALSE); |
672 | mediaPlayerState->setPlaying(TRUE); | 672 | mediaPlayerState->setPlaying(TRUE); |
673 | d->selectedFiles->unSelect(); | 673 | d->selectedFiles->unSelect(); |
674 | } | 674 | } |
675 | 675 | ||
676 | void PlayListWidget::addToSelection( QListViewItem *it) { | 676 | void PlayListWidget::addToSelection( QListViewItem *it) { |
677 | d->setDocumentUsed = FALSE; | 677 | d->setDocumentUsed = FALSE; |
678 | 678 | ||
679 | if(it) { | 679 | if(it) { |
680 | switch (tabWidget->currentPageIndex()) { | 680 | switch (tabWidget->currentPageIndex()) { |
681 | case 1: { | 681 | case 1: { |
682 | QListIterator<DocLnk> dit( files.children() ); | 682 | QListIterator<DocLnk> dit( files.children() ); |
683 | for ( ; dit.current(); ++dit ) { | 683 | for ( ; dit.current(); ++dit ) { |
684 | if( dit.current()->name() == it->text(0)) { | 684 | if( dit.current()->name() == it->text(0)) { |
685 | d->selectedFiles->addToSelection( **dit ); | 685 | d->selectedFiles->addToSelection( **dit ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | } | 688 | } |
689 | break; | 689 | break; |
690 | case 2: { | 690 | case 2: { |
691 | QListIterator<DocLnk> dit( vFiles.children() ); | 691 | QListIterator<DocLnk> dit( vFiles.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 692 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it->text(0)) { | 693 | if( dit.current()->name() == it->text(0)) { |
694 | d->selectedFiles->addToSelection( **dit ); | 694 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 695 | } |
696 | } | 696 | } |
697 | } | 697 | } |
698 | break; | 698 | break; |
699 | case 0: | 699 | case 0: |
700 | break; | 700 | break; |
701 | }; | 701 | }; |
702 | tabWidget->setCurrentPage(0); | 702 | tabWidget->setCurrentPage(0); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | void PlayListWidget::tabChanged(QWidget *widg) { | 706 | void PlayListWidget::tabChanged(QWidget *widg) { |
707 | 707 | ||
708 | switch ( tabWidget->currentPageIndex()) { | 708 | switch ( tabWidget->currentPageIndex()) { |
709 | case 0: | 709 | case 0: |
710 | { | 710 | { |
711 | if( !tbDeletePlaylist->isHidden()) | 711 | if( !tbDeletePlaylist->isHidden()) |
712 | tbDeletePlaylist->hide(); | 712 | tbDeletePlaylist->hide(); |
713 | d->tbRemoveFromList->setEnabled(TRUE); | 713 | d->tbRemoveFromList->setEnabled(TRUE); |
714 | d->tbAddToList->setEnabled(FALSE); | 714 | d->tbAddToList->setEnabled(FALSE); |
715 | } | 715 | } |
716 | break; | 716 | break; |
717 | case 1: | 717 | case 1: |
718 | { | 718 | { |
719 | audioView->clear(); | 719 | audioView->clear(); |
720 | populateAudioView(); | 720 | populateAudioView(); |
721 | 721 | ||
722 | if( !tbDeletePlaylist->isHidden()) | 722 | if( !tbDeletePlaylist->isHidden()) |
723 | tbDeletePlaylist->hide(); | 723 | tbDeletePlaylist->hide(); |
724 | d->tbRemoveFromList->setEnabled(FALSE); | 724 | d->tbRemoveFromList->setEnabled(FALSE); |
725 | d->tbAddToList->setEnabled(TRUE); | 725 | d->tbAddToList->setEnabled(TRUE); |
726 | } | 726 | } |
727 | break; | 727 | break; |
728 | case 2: | 728 | case 2: |
729 | { | 729 | { |
730 | videoView->clear(); | 730 | videoView->clear(); |
731 | populateVideoView(); | 731 | populateVideoView(); |
732 | if( !tbDeletePlaylist->isHidden()) | 732 | if( !tbDeletePlaylist->isHidden()) |
733 | tbDeletePlaylist->hide(); | 733 | tbDeletePlaylist->hide(); |
734 | d->tbRemoveFromList->setEnabled(FALSE); | 734 | d->tbRemoveFromList->setEnabled(FALSE); |
735 | d->tbAddToList->setEnabled(TRUE); | 735 | d->tbAddToList->setEnabled(TRUE); |
736 | } | 736 | } |
737 | break; | 737 | break; |
738 | case 3: | 738 | case 3: |
739 | { | 739 | { |
740 | if( tbDeletePlaylist->isHidden()) | 740 | if( tbDeletePlaylist->isHidden()) |
741 | tbDeletePlaylist->show(); | 741 | tbDeletePlaylist->show(); |
742 | playLists->reread(); | 742 | playLists->reread(); |
743 | } | 743 | } |
744 | break; | 744 | break; |
745 | }; | 745 | }; |
746 | } | 746 | } |
747 | 747 | ||
748 | void PlayListWidget::btnPlay(bool b) { | 748 | void PlayListWidget::btnPlay(bool b) { |
749 | 749 | ||
750 | // mediaPlayerState->setPlaying(b); | 750 | // mediaPlayerState->setPlaying(b); |
751 | switch ( tabWidget->currentPageIndex()) { | 751 | switch ( tabWidget->currentPageIndex()) { |
752 | case 0: | 752 | case 0: |
753 | { | 753 | { |
754 | mediaPlayerState->setPlaying(b); | 754 | mediaPlayerState->setPlaying(b); |
755 | } | 755 | } |
756 | break; | 756 | break; |
757 | case 1: | 757 | case 1: |
758 | { | 758 | { |
759 | addToSelection( audioView->currentItem() ); | 759 | addToSelection( audioView->currentItem() ); |
760 | mediaPlayerState->setPlaying(b); | 760 | mediaPlayerState->setPlaying(b); |
761 | d->selectedFiles->removeSelected( ); | 761 | d->selectedFiles->removeSelected( ); |
762 | tabWidget->setCurrentPage(1); | 762 | tabWidget->setCurrentPage(1); |
763 | d->selectedFiles->unSelect(); | 763 | d->selectedFiles->unSelect(); |
764 | insanityBool=FALSE; | 764 | insanityBool=FALSE; |
765 | }// audioView->clearSelection(); | 765 | }// audioView->clearSelection(); |
766 | break; | 766 | break; |
767 | case 2: | 767 | case 2: |
768 | { | 768 | { |
769 | addToSelection( videoView->currentItem() ); | 769 | addToSelection( videoView->currentItem() ); |
770 | mediaPlayerState->setPlaying(b); | 770 | mediaPlayerState->setPlaying(b); |
771 | qApp->processEvents(); | 771 | qApp->processEvents(); |
772 | d->selectedFiles->removeSelected( ); | 772 | d->selectedFiles->removeSelected( ); |
773 | tabWidget->setCurrentPage(2); | 773 | tabWidget->setCurrentPage(2); |
774 | d->selectedFiles->unSelect(); | 774 | d->selectedFiles->unSelect(); |
775 | insanityBool=FALSE; | 775 | insanityBool=FALSE; |
776 | }// videoView->clearSelection(); | 776 | }// videoView->clearSelection(); |
777 | break; | 777 | break; |
778 | }; | 778 | }; |
779 | 779 | ||
780 | } | 780 | } |
781 | 781 | ||
782 | void PlayListWidget::deletePlaylist() { | 782 | void PlayListWidget::deletePlaylist() { |
783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 783 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
784 | (tr("You really want to delete\nthis playlist?")), | 784 | (tr("You really want to delete\nthis playlist?")), |
785 | (tr("Yes")), (tr("No")), 0 )){ | 785 | (tr("Yes")), (tr("No")), 0 )){ |
786 | case 0: // Yes clicked, | 786 | case 0: // Yes clicked, |
787 | QFile().remove(playLists->selected()->file()); | 787 | QFile().remove(playLists->selected()->file()); |
788 | QFile().remove(playLists->selected()->linkFile()); | 788 | QFile().remove(playLists->selected()->linkFile()); |
789 | playLists->reread(); | 789 | playLists->reread(); |
790 | break; | 790 | break; |
791 | case 1: // Cancel | 791 | case 1: // Cancel |
792 | break; | 792 | break; |
793 | }; | 793 | }; |
794 | } | 794 | } |
795 | 795 | ||
796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
797 | switch (mouse) { | 797 | switch (mouse) { |
798 | case 1: | 798 | case 1: |
799 | break; | 799 | break; |
800 | case 2:{ | 800 | case 2:{ |
801 | QPopupMenu m; | 801 | QPopupMenu m; |
802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
804 | m.insertSeparator(); | 804 | m.insertSeparator(); |
805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
806 | m.exec( QCursor::pos() ); | 806 | m.exec( QCursor::pos() ); |
807 | } | 807 | } |
808 | break; | 808 | break; |
809 | }; | 809 | }; |
810 | } | 810 | } |
811 | 811 | ||
812 | void PlayListWidget::playSelected() { | 812 | void PlayListWidget::playSelected() { |
813 | btnPlay( TRUE); | 813 | btnPlay( TRUE); |
814 | } | 814 | } |
815 | 815 | ||
816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
817 | switch (mouse) { | 817 | switch (mouse) { |
818 | case 1: | 818 | case 1: |
819 | 819 | ||
820 | break; | 820 | break; |
821 | case 2: | 821 | case 2: |
822 | { | 822 | { |
823 | QPopupMenu m; | 823 | QPopupMenu m; |
824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
826 | m.exec( QCursor::pos() ); | 826 | m.exec( QCursor::pos() ); |
827 | } | 827 | } |
828 | break; | 828 | break; |
829 | }; | 829 | }; |
830 | } | 830 | } |
831 | 831 | ||
832 | void PlayListWidget::listDelete() { | 832 | void PlayListWidget::listDelete() { |
833 | Config cfg( "OpiePlayer" ); | 833 | Config cfg( "OpiePlayer" ); |
834 | cfg.setGroup("PlayList"); | 834 | cfg.setGroup("PlayList"); |
835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
836 | QString file; | 836 | QString file; |
837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 837 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
838 | switch ( tabWidget->currentPageIndex()) { | 838 | switch ( tabWidget->currentPageIndex()) { |
839 | case 0: | 839 | case 0: |
840 | break; | 840 | break; |
841 | case 1: | 841 | case 1: |
842 | { | 842 | { |
843 | file = audioView->selectedItem()->text(0); | 843 | file = audioView->currentItem()->text(0); |
844 | QListIterator<DocLnk> dit( files.children() ); | 844 | QListIterator<DocLnk> Pdit( files.children() ); |
845 | for ( ; dit.current(); ++dit ) { | 845 | for ( ; Pdit.current(); ++Pdit ) { |
846 | if( dit.current()->name() == file) { | 846 | if( Pdit.current()->name() == file) { |
847 | // qDebug(file); | 847 | LnkProperties prop( Pdit.current() ); |
848 | LnkProperties prop( dit.current() ); | ||
849 | prop.showMaximized(); | 848 | prop.showMaximized(); |
850 | prop.exec(); | 849 | prop.exec(); |
851 | } | 850 | } |
852 | } | 851 | } |
853 | populateAudioView(); | 852 | populateAudioView(); |
854 | } | 853 | } |
855 | break; | 854 | break; |
856 | case 2: | 855 | case 2: |
857 | { | 856 | { |
858 | 857 | ||
859 | } | 858 | } |
860 | break; | 859 | break; |
861 | }; | 860 | }; |
862 | } | 861 | } |
863 | 862 | ||
864 | void PlayListWidget::scanForAudio() { | 863 | void PlayListWidget::scanForAudio() { |
865 | qDebug("scan for audio"); | 864 | qDebug("scan for audio"); |
866 | files.detachChildren(); | 865 | files.detachChildren(); |
867 | QListIterator<DocLnk> sdit( files.children() ); | 866 | QListIterator<DocLnk> sdit( files.children() ); |
868 | for ( ; sdit.current(); ++sdit ) { | 867 | for ( ; sdit.current(); ++sdit ) { |
869 | delete sdit.current(); | 868 | delete sdit.current(); |
870 | } | 869 | } |
871 | Global::findDocuments(&files, "audio/*"); | 870 | Global::findDocuments(&files, "audio/*"); |
872 | audioScan = TRUE; | 871 | audioScan = TRUE; |
873 | } | 872 | } |
874 | void PlayListWidget::scanForVideo() { | 873 | void PlayListWidget::scanForVideo() { |
875 | qDebug("scan for video"); | 874 | qDebug("scan for video"); |
876 | vFiles.detachChildren(); | 875 | vFiles.detachChildren(); |
877 | QListIterator<DocLnk> sdit( vFiles.children() ); | 876 | QListIterator<DocLnk> sdit( vFiles.children() ); |
878 | for ( ; sdit.current(); ++sdit ) { | 877 | for ( ; sdit.current(); ++sdit ) { |
879 | delete sdit.current(); | 878 | delete sdit.current(); |
880 | } | 879 | } |
881 | Global::findDocuments(&vFiles, "video/*"); | 880 | Global::findDocuments(&vFiles, "video/*"); |
882 | videoScan = TRUE; | 881 | videoScan = TRUE; |
883 | } | 882 | } |
884 | 883 | ||
885 | void PlayListWidget::populateAudioView() { | 884 | void PlayListWidget::populateAudioView() { |
886 | 885 | ||
887 | audioView->clear(); | 886 | audioView->clear(); |
888 | StorageInfo storageInfo; | 887 | StorageInfo storageInfo; |
889 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 888 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
890 | if(!audioScan) scanForAudio(); | 889 | if(!audioScan) scanForAudio(); |
891 | 890 | ||
892 | QListIterator<DocLnk> dit( files.children() ); | 891 | QListIterator<DocLnk> dit( files.children() ); |
893 | QListIterator<FileSystem> it ( fs ); | 892 | QListIterator<FileSystem> it ( fs ); |
894 | 893 | ||
895 | QString storage; | 894 | QString storage; |
896 | for ( ; dit.current(); ++dit ) { | 895 | for ( ; dit.current(); ++dit ) { |
897 | for( ; it.current(); ++it ){ | 896 | for( ; it.current(); ++it ){ |
898 | const QString name = (*it)->name(); | 897 | const QString name = (*it)->name(); |
899 | const QString path = (*it)->path(); | 898 | const QString path = (*it)->path(); |
900 | if(dit.current()->file().find(path) != -1 ) storage=name; | 899 | if(dit.current()->file().find(path) != -1 ) storage=name; |
901 | } | 900 | } |
902 | 901 | ||
903 | QListViewItem * newItem; | 902 | QListViewItem * newItem; |
904 | if ( QFile( dit.current()->file()).exists() ) { | 903 | if ( QFile( dit.current()->file()).exists() ) { |
905 | // qDebug(dit.current()->name()); | 904 | // qDebug(dit.current()->name()); |
906 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 905 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
907 | QString::number( QFile( dit.current()->file()).size() ), storage); | 906 | QString::number( QFile( dit.current()->file()).size() ), storage); |
908 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 907 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
909 | } | 908 | } |
910 | } | 909 | } |
911 | 910 | ||
912 | } | 911 | } |
913 | 912 | ||
914 | void PlayListWidget::populateVideoView() { | 913 | void PlayListWidget::populateVideoView() { |
915 | videoView->clear(); | 914 | videoView->clear(); |
916 | StorageInfo storageInfo; | 915 | StorageInfo storageInfo; |
917 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 916 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
918 | 917 | ||
919 | if(!videoScan ) scanForVideo(); | 918 | if(!videoScan ) scanForVideo(); |
920 | 919 | ||
921 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 920 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
922 | QListIterator<FileSystem> it ( fs ); | 921 | QListIterator<FileSystem> it ( fs ); |
923 | videoView->clear(); | 922 | videoView->clear(); |
924 | QString storage; | 923 | QString storage; |
925 | for ( ; Vdit.current(); ++Vdit ) { | 924 | for ( ; Vdit.current(); ++Vdit ) { |
926 | for( ; it.current(); ++it ){ | 925 | for( ; it.current(); ++it ){ |
927 | const QString name = (*it)->name(); | 926 | const QString name = (*it)->name(); |
928 | const QString path = (*it)->path(); | 927 | const QString path = (*it)->path(); |
929 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 928 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
930 | } | 929 | } |
931 | 930 | ||
932 | QListViewItem * newItem; | 931 | QListViewItem * newItem; |
933 | if ( QFile( Vdit.current()->file()).exists() ) { | 932 | if ( QFile( Vdit.current()->file()).exists() ) { |
934 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 933 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
935 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 934 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
936 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 935 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
937 | } | 936 | } |
938 | } | 937 | } |
939 | } | 938 | } |
940 | 939 | ||
941 | void PlayListWidget::openFile() { | 940 | void PlayListWidget::openFile() { |
942 | QString filename, name; | 941 | QString filename, name; |
943 | InputDialog *fileDlg; | 942 | InputDialog *fileDlg; |
944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 943 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
945 | fileDlg->exec(); | 944 | fileDlg->exec(); |
946 | if( fileDlg->result() == 1 ) { | 945 | if( fileDlg->result() == 1 ) { |
947 | filename = fileDlg->LineEdit1->text(); | 946 | filename = fileDlg->LineEdit1->text(); |
948 | 947 | ||
949 | qDebug("Selected filename is "+filename); | 948 | qDebug("Selected filename is "+filename); |
950 | if(filename.right(3) == "m3u") { | 949 | if(filename.right(3) == "m3u") { |
951 | readm3u( filename ); | 950 | readm3u( filename ); |
952 | } else if(filename.right(3) == "pls") { | 951 | } else if(filename.right(3) == "pls") { |
953 | readPls( filename ); | 952 | readPls( filename ); |
954 | } else { | 953 | } else { |
955 | DocLnk lnk; | 954 | DocLnk lnk; |
956 | 955 | ||
957 | lnk.setName(filename); //sets file name | 956 | lnk.setName(filename); //sets file name |
958 | lnk.setFile(filename); //sets File property | 957 | lnk.setFile(filename); //sets File property |
959 | lnk.setType("audio/x-mpegurl"); | 958 | lnk.setType("audio/x-mpegurl"); |
960 | lnk.setExec("opieplayer"); | 959 | lnk.setExec("opieplayer"); |
961 | lnk.setIcon("opieplayer/MPEGPlayer"); | 960 | lnk.setIcon("opieplayer/MPEGPlayer"); |
962 | 961 | ||
963 | if(!lnk.writeLink()) { | 962 | if(!lnk.writeLink()) { |
964 | qDebug("Writing doclink did not work"); | 963 | qDebug("Writing doclink did not work"); |
965 | } | 964 | } |
966 | d->selectedFiles->addToSelection( lnk); | 965 | d->selectedFiles->addToSelection( lnk); |
967 | } | 966 | } |
968 | } | 967 | } |
969 | if(fileDlg) { | 968 | if(fileDlg) { |
970 | delete fileDlg; | 969 | delete fileDlg; |
971 | } | 970 | } |
972 | } | 971 | } |
973 | 972 | ||
974 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 973 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
975 | { | 974 | { |
976 | switch ( e->key() ) { | 975 | switch ( e->key() ) { |
977 | ////////////////////////////// Zaurus keys | 976 | ////////////////////////////// Zaurus keys |
978 | case Key_F9: //activity | 977 | case Key_F9: //activity |
979 | // if(audioUI->isHidden()) | 978 | // if(audioUI->isHidden()) |
980 | // audioUI->showMaximized(); | 979 | // audioUI->showMaximized(); |
981 | break; | 980 | break; |
982 | case Key_F10: //contacts | 981 | case Key_F10: //contacts |
983 | // if( videoUI->isHidden()) | 982 | // if( videoUI->isHidden()) |
984 | // videoUI->showMaximized(); | 983 | // videoUI->showMaximized(); |
985 | break; | 984 | break; |
986 | case Key_F11: //menu | 985 | case Key_F11: //menu |
987 | break; | 986 | break; |
988 | case Key_F12: //home | 987 | case Key_F12: //home |
989 | // doBlank(); | 988 | // doBlank(); |
990 | break; | 989 | break; |
991 | case Key_F13: //mail | 990 | case Key_F13: //mail |
992 | // doUnblank(); | 991 | // doUnblank(); |
993 | break; | 992 | break; |
994 | case Key_Q: //add to playlist | 993 | case Key_Q: //add to playlist |
995 | qDebug("Add"); | 994 | qDebug("Add"); |
996 | addSelected(); | 995 | addSelected(); |
997 | break; | 996 | break; |
998 | case Key_R: //remove from playlist | 997 | case Key_R: //remove from playlist |
999 | removeSelected(); | 998 | removeSelected(); |
1000 | break; | 999 | break; |
1001 | // case Key_P: //play | 1000 | // case Key_P: //play |
1002 | // qDebug("Play"); | 1001 | // qDebug("Play"); |
1003 | // playSelected(); | 1002 | // playSelected(); |
1004 | // break; | 1003 | // break; |
1005 | case Key_Space: | 1004 | case Key_Space: |
1006 | qDebug("Play"); | 1005 | qDebug("Play"); |
1007 | // playSelected(); puh | 1006 | // playSelected(); puh |
1008 | break; | 1007 | break; |
1009 | case Key_1: | 1008 | case Key_1: |
1010 | tabWidget->setCurrentPage(0); | 1009 | tabWidget->setCurrentPage(0); |
1011 | break; | 1010 | break; |
1012 | case Key_2: | 1011 | case Key_2: |
1013 | tabWidget->setCurrentPage(1); | 1012 | tabWidget->setCurrentPage(1); |
1014 | break; | 1013 | break; |
1015 | case Key_3: | 1014 | case Key_3: |
1016 | tabWidget->setCurrentPage(2); | 1015 | tabWidget->setCurrentPage(2); |
1017 | break; | 1016 | break; |
1018 | case Key_4: | 1017 | case Key_4: |
1019 | tabWidget->setCurrentPage(3); | 1018 | tabWidget->setCurrentPage(3); |
1020 | break; | 1019 | break; |
1021 | case Key_Down: | 1020 | case Key_Down: |
1022 | if ( !d->selectedFiles->next() ) | 1021 | if ( !d->selectedFiles->next() ) |
1023 | d->selectedFiles->first(); | 1022 | d->selectedFiles->first(); |
1024 | 1023 | ||
1025 | break; | 1024 | break; |
1026 | case Key_Up: | 1025 | case Key_Up: |
1027 | if ( !d->selectedFiles->prev() ) | 1026 | if ( !d->selectedFiles->prev() ) |
1028 | // d->selectedFiles->last(); | 1027 | // d->selectedFiles->last(); |
1029 | 1028 | ||
1030 | break; | 1029 | break; |
1031 | 1030 | ||
1032 | } | 1031 | } |
1033 | } | 1032 | } |
1034 | 1033 | ||
1035 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1034 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1036 | { | 1035 | { |
1037 | // qDebug("Key press"); | 1036 | // qDebug("Key press"); |
1038 | // switch ( e->key() ) { | 1037 | // switch ( e->key() ) { |
1039 | // ////////////////////////////// Zaurus keys | 1038 | // ////////////////////////////// Zaurus keys |
1040 | // case Key_A: //add to playlist | 1039 | // case Key_A: //add to playlist |
1041 | // qDebug("Add"); | 1040 | // qDebug("Add"); |
1042 | // addSelected(); | 1041 | // addSelected(); |
1043 | // break; | 1042 | // break; |
1044 | // case Key_R: //remove from playlist | 1043 | // case Key_R: //remove from playlist |
1045 | // removeSelected(); | 1044 | // removeSelected(); |
1046 | // break; | 1045 | // break; |
1047 | // case Key_P: //play | 1046 | // case Key_P: //play |
1048 | // qDebug("Play"); | 1047 | // qDebug("Play"); |
1049 | // playSelected(); | 1048 | // playSelected(); |
1050 | // break; | 1049 | // break; |
1051 | // case Key_Space: | 1050 | // case Key_Space: |
1052 | // qDebug("Play"); | 1051 | // qDebug("Play"); |
1053 | // playSelected(); | 1052 | // playSelected(); |
1054 | // break; | 1053 | // break; |
1055 | // } | 1054 | // } |
1056 | } | 1055 | } |
1057 | 1056 | ||
1058 | void PlayListWidget::doBlank() { | 1057 | void PlayListWidget::doBlank() { |
1059 | qDebug("do blanking"); | 1058 | qDebug("do blanking"); |
1060 | fd=open("/dev/fb0",O_RDWR); | 1059 | fd=open("/dev/fb0",O_RDWR); |
1061 | if (fd != -1) { | 1060 | if (fd != -1) { |
1062 | ioctl(fd,FBIOBLANK,1); | 1061 | ioctl(fd,FBIOBLANK,1); |
1063 | // close(fd); | 1062 | // close(fd); |
1064 | } | 1063 | } |
1065 | } | 1064 | } |
1066 | 1065 | ||
1067 | void PlayListWidget::doUnblank() { | 1066 | void PlayListWidget::doUnblank() { |
1068 | // this crashes opieplayer with a segfault | 1067 | // this crashes opieplayer with a segfault |
1069 | // int fd; | 1068 | // int fd; |
1070 | // fd=open("/dev/fb0",O_RDWR); | 1069 | // fd=open("/dev/fb0",O_RDWR); |
1071 | qDebug("do unblanking"); | 1070 | qDebug("do unblanking"); |
1072 | if (fd != -1) { | 1071 | if (fd != -1) { |
1073 | ioctl(fd,FBIOBLANK,0); | 1072 | ioctl(fd,FBIOBLANK,0); |
1074 | close(fd); | 1073 | close(fd); |
1075 | } | 1074 | } |
1076 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1075 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1077 | h <<-3;// v[1]; // -3 Force on | 1076 | h <<-3;// v[1]; // -3 Force on |
1078 | } | 1077 | } |
1079 | 1078 | ||
1080 | void PlayListWidget::readm3u(const QString &filename) { | 1079 | void PlayListWidget::readm3u(const QString &filename) { |
1081 | 1080 | ||
1082 | qDebug("m3u filename is "+filename); | 1081 | qDebug("m3u filename is "+filename); |
1083 | QFile f(filename); | 1082 | QFile f(filename); |
1084 | 1083 | ||
1085 | if(f.open(IO_ReadOnly)) { | 1084 | if(f.open(IO_ReadOnly)) { |
1086 | QTextStream t(&f); | 1085 | QTextStream t(&f); |
1087 | QString s;//, first, second; | 1086 | QString s;//, first, second; |
1088 | int i=0; | 1087 | int i=0; |
1089 | while ( !t.atEnd()) { | 1088 | while ( !t.atEnd()) { |
1090 | s=t.readLine(); | 1089 | s=t.readLine(); |
1091 | 1090 | ||
1092 | if(s.find("#",0,TRUE) == -1) { | 1091 | if(s.find("#",0,TRUE) == -1) { |
1093 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1092 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1094 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1093 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1095 | s=s.right(s.length()-2); | 1094 | s=s.right(s.length()-2); |
1096 | DocLnk lnk( s ); | 1095 | DocLnk lnk( s ); |
1097 | QFileInfo f(s); | 1096 | QFileInfo f(s); |
1098 | QString name = f.baseName(); | 1097 | QString name = f.baseName(); |
1099 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1098 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1100 | lnk.setName( name ); | 1099 | lnk.setName( name ); |
1101 | s=s.replace( QRegExp("\\"),"/"); | 1100 | s=s.replace( QRegExp("\\"),"/"); |
1102 | lnk.setFile( s ); | 1101 | lnk.setFile( s ); |
1103 | lnk.writeLink(); | 1102 | lnk.writeLink(); |
1104 | qDebug("add "+name); | 1103 | qDebug("add "+name); |