-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 | |||
@@ -715,262 +715,261 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
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() ) { |