author | llornkcor <llornkcor> | 2002-04-20 18:29:06 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-20 18:29:06 (UTC) |
commit | 758c9e817087252894b15c6f7476c1f16a02f65d (patch) (unidiff) | |
tree | de3a2fa88c3eeffae5602928b3a57c8f9ac2ac86 | |
parent | b37f1e1eec635165da7dbf06e968cd5368d92d4e (diff) | |
download | opie-758c9e817087252894b15c6f7476c1f16a02f65d.zip opie-758c9e817087252894b15c6f7476c1f16a02f65d.tar.gz opie-758c9e817087252894b15c6f7476c1f16a02f65d.tar.bz2 |
file/url
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 11f9752..4b1ff22 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -733,273 +733,271 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
733 | if( dit.current()->name() == it->text(0)) { | 733 | if( dit.current()->name() == it->text(0)) { |
734 | d->selectedFiles->addToSelection( **dit ); | 734 | d->selectedFiles->addToSelection( **dit ); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | } | 737 | } |
738 | break; | 738 | break; |
739 | case 2: { | 739 | case 2: { |
740 | QListIterator<DocLnk> dit( vFiles.children() ); | 740 | QListIterator<DocLnk> dit( vFiles.children() ); |
741 | for ( ; dit.current(); ++dit ) { | 741 | for ( ; dit.current(); ++dit ) { |
742 | if( dit.current()->name() == it->text(0)) { | 742 | if( dit.current()->name() == it->text(0)) { |
743 | d->selectedFiles->addToSelection( **dit ); | 743 | d->selectedFiles->addToSelection( **dit ); |
744 | } | 744 | } |
745 | } | 745 | } |
746 | } | 746 | } |
747 | break; | 747 | break; |
748 | case 0: | 748 | case 0: |
749 | break; | 749 | break; |
750 | }; | 750 | }; |
751 | tabWidget->setCurrentPage(0); | 751 | tabWidget->setCurrentPage(0); |
752 | } | 752 | } |
753 | } | 753 | } |
754 | 754 | ||
755 | void PlayListWidget::tabChanged(QWidget *widg) { | 755 | void PlayListWidget::tabChanged(QWidget *widg) { |
756 | 756 | ||
757 | switch ( tabWidget->currentPageIndex()) { | 757 | switch ( tabWidget->currentPageIndex()) { |
758 | case 0: | 758 | case 0: |
759 | { | 759 | { |
760 | if( !tbDeletePlaylist->isHidden()) | 760 | if( !tbDeletePlaylist->isHidden()) |
761 | tbDeletePlaylist->hide(); | 761 | tbDeletePlaylist->hide(); |
762 | d->tbRemoveFromList->setEnabled(TRUE); | 762 | d->tbRemoveFromList->setEnabled(TRUE); |
763 | d->tbAddToList->setEnabled(FALSE); | 763 | d->tbAddToList->setEnabled(FALSE); |
764 | } | 764 | } |
765 | break; | 765 | break; |
766 | case 1: | 766 | case 1: |
767 | { | 767 | { |
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 2: | 774 | case 2: |
775 | { | 775 | { |
776 | if( !tbDeletePlaylist->isHidden()) | 776 | if( !tbDeletePlaylist->isHidden()) |
777 | tbDeletePlaylist->hide(); | 777 | tbDeletePlaylist->hide(); |
778 | d->tbRemoveFromList->setEnabled(FALSE); | 778 | d->tbRemoveFromList->setEnabled(FALSE); |
779 | d->tbAddToList->setEnabled(TRUE); | 779 | d->tbAddToList->setEnabled(TRUE); |
780 | } | 780 | } |
781 | break; | 781 | break; |
782 | case 3: | 782 | case 3: |
783 | { | 783 | { |
784 | if( tbDeletePlaylist->isHidden()) | 784 | if( tbDeletePlaylist->isHidden()) |
785 | tbDeletePlaylist->show(); | 785 | tbDeletePlaylist->show(); |
786 | playLists->reread(); | 786 | playLists->reread(); |
787 | } | 787 | } |
788 | break; | 788 | break; |
789 | }; | 789 | }; |
790 | } | 790 | } |
791 | 791 | ||
792 | 792 | ||
793 | 793 | ||
794 | void PlayListWidget::btnPlay(bool b) { | 794 | void PlayListWidget::btnPlay(bool b) { |
795 | 795 | ||
796 | // mediaPlayerState->setPlaying(b); | 796 | // mediaPlayerState->setPlaying(b); |
797 | switch ( tabWidget->currentPageIndex()) { | 797 | switch ( tabWidget->currentPageIndex()) { |
798 | case 0: | 798 | case 0: |
799 | { | 799 | { |
800 | mediaPlayerState->setPlaying(b); | 800 | mediaPlayerState->setPlaying(b); |
801 | } | 801 | } |
802 | break; | 802 | break; |
803 | case 1: | 803 | case 1: |
804 | { | 804 | { |
805 | addToSelection( audioView->selectedItem() ); | 805 | addToSelection( audioView->selectedItem() ); |
806 | mediaPlayerState->setPlaying(b); | 806 | mediaPlayerState->setPlaying(b); |
807 | d->selectedFiles->removeSelected( ); | 807 | d->selectedFiles->removeSelected( ); |
808 | tabWidget->setCurrentPage(1); | 808 | tabWidget->setCurrentPage(1); |
809 | d->selectedFiles->unSelect(); | 809 | d->selectedFiles->unSelect(); |
810 | // audioView->clearSelection(); | 810 | // audioView->clearSelection(); |
811 | } | 811 | } |
812 | break; | 812 | break; |
813 | case 2: | 813 | case 2: |
814 | { | 814 | { |
815 | addToSelection( videoView->selectedItem() ); | 815 | addToSelection( videoView->selectedItem() ); |
816 | mediaPlayerState->setPlaying(b); | 816 | mediaPlayerState->setPlaying(b); |
817 | qApp->processEvents(); | 817 | qApp->processEvents(); |
818 | d->selectedFiles->removeSelected( ); | 818 | d->selectedFiles->removeSelected( ); |
819 | tabWidget->setCurrentPage(2); | 819 | tabWidget->setCurrentPage(2); |
820 | d->selectedFiles->unSelect(); | 820 | d->selectedFiles->unSelect(); |
821 | // videoView->clearSelection(); | 821 | // videoView->clearSelection(); |
822 | } | 822 | } |
823 | break; | 823 | break; |
824 | }; | 824 | }; |
825 | } | 825 | } |
826 | 826 | ||
827 | void PlayListWidget::deletePlaylist() { | 827 | void PlayListWidget::deletePlaylist() { |
828 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 828 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
829 | (tr("You really want to delete\nthis playlist?")), | 829 | (tr("You really want to delete\nthis playlist?")), |
830 | (tr("Yes")), (tr("No")), 0 )){ | 830 | (tr("Yes")), (tr("No")), 0 )){ |
831 | case 0: // Yes clicked, | 831 | case 0: // Yes clicked, |
832 | QFile().remove(playLists->selected()->file()); | 832 | QFile().remove(playLists->selected()->file()); |
833 | QFile().remove(playLists->selected()->linkFile()); | 833 | QFile().remove(playLists->selected()->linkFile()); |
834 | playLists->reread(); | 834 | playLists->reread(); |
835 | break; | 835 | break; |
836 | case 1: // Cancel | 836 | case 1: // Cancel |
837 | break; | 837 | break; |
838 | }; | 838 | }; |
839 | 839 | ||
840 | } | 840 | } |
841 | 841 | ||
842 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 842 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
843 | { | 843 | { |
844 | switch (mouse) { | 844 | switch (mouse) { |
845 | case 1: | 845 | case 1: |
846 | break; | 846 | break; |
847 | case 2:{ | 847 | case 2:{ |
848 | QPopupMenu m; | 848 | QPopupMenu m; |
849 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 849 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
850 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 850 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
851 | m.insertSeparator(); | 851 | m.insertSeparator(); |
852 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 852 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
853 | m.exec( QCursor::pos() ); | 853 | m.exec( QCursor::pos() ); |
854 | } | 854 | } |
855 | break; | 855 | break; |
856 | }; | 856 | }; |
857 | } | 857 | } |
858 | 858 | ||
859 | void PlayListWidget::playSelected() | 859 | void PlayListWidget::playSelected() |
860 | { | 860 | { |
861 | btnPlay( TRUE); | 861 | btnPlay( TRUE); |
862 | } | 862 | } |
863 | 863 | ||
864 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 864 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
865 | { | 865 | { |
866 | switch (mouse) { | 866 | switch (mouse) { |
867 | case 1: | 867 | case 1: |
868 | break; | 868 | break; |
869 | case 2:{ | 869 | case 2:{ |
870 | QPopupMenu m; | 870 | QPopupMenu m; |
871 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 871 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
872 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 872 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
873 | // m.insertSeparator(); | 873 | // m.insertSeparator(); |
874 | m.exec( QCursor::pos() ); | 874 | m.exec( QCursor::pos() ); |
875 | } | 875 | } |
876 | break; | 876 | break; |
877 | }; | 877 | }; |
878 | 878 | ||
879 | } | 879 | } |
880 | 880 | ||
881 | void PlayListWidget::listDelete() { | 881 | void PlayListWidget::listDelete() { |
882 | Config cfg( "MediaPlayer" ); | 882 | Config cfg( "MediaPlayer" ); |
883 | cfg.setGroup("PlayList"); | 883 | cfg.setGroup("PlayList"); |
884 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 884 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
885 | QString file; | 885 | QString file; |
886 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 886 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
887 | switch ( tabWidget->currentPageIndex()) { | 887 | switch ( tabWidget->currentPageIndex()) { |
888 | case 0: | 888 | case 0: |
889 | break; | 889 | break; |
890 | case 1: | 890 | case 1: |
891 | { | 891 | { |
892 | file = audioView->selectedItem()->text(0); | 892 | file = audioView->selectedItem()->text(0); |
893 | // Global::findDocuments(&files, "audio/*"); | 893 | // Global::findDocuments(&files, "audio/*"); |
894 | // AppLnkSet appFiles; | 894 | // AppLnkSet appFiles; |
895 | QListIterator<DocLnk> dit( files.children() ); | 895 | QListIterator<DocLnk> dit( files.children() ); |
896 | for ( ; dit.current(); ++dit ) { | 896 | for ( ; dit.current(); ++dit ) { |
897 | if( dit.current()->name() == file) { | 897 | if( dit.current()->name() == file) { |
898 | // qDebug(file); | 898 | // qDebug(file); |
899 | LnkProperties prop( dit.current() ); | 899 | LnkProperties prop( dit.current() ); |
900 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 900 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
901 | prop.showMaximized(); | 901 | prop.showMaximized(); |
902 | prop.exec(); | 902 | prop.exec(); |
903 | } | 903 | } |
904 | } | 904 | } |
905 | populateAudioView(); | 905 | populateAudioView(); |
906 | } | 906 | } |
907 | break; | 907 | break; |
908 | case 2: | 908 | case 2: |
909 | { | 909 | { |
910 | // file = videoView->selectedItem()->text(0); | 910 | // file = videoView->selectedItem()->text(0); |
911 | // for ( int i = 0; i < noOfFiles; i++ ) { | 911 | // for ( int i = 0; i < noOfFiles; i++ ) { |
912 | // QString entryName; | 912 | // QString entryName; |
913 | // entryName.sprintf( "File%i", i + 1 ); | 913 | // entryName.sprintf( "File%i", i + 1 ); |
914 | // QString linkFile = cfg.readEntry( entryName ); | 914 | // QString linkFile = cfg.readEntry( entryName ); |
915 | // AppLnk lnk( AppLnk(linkFile)); | 915 | // AppLnk lnk( AppLnk(linkFile)); |
916 | // if( lnk.name() == file ) { | 916 | // if( lnk.name() == file ) { |
917 | // LnkProperties prop( &lnk); | 917 | // LnkProperties prop( &lnk); |
918 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 918 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
919 | // prop.showMaximized(); | 919 | // prop.showMaximized(); |
920 | // prop.exec(); | 920 | // prop.exec(); |
921 | // } | 921 | // } |
922 | // } | 922 | // } |
923 | } | 923 | } |
924 | break; | 924 | break; |
925 | }; | 925 | }; |
926 | } | 926 | } |
927 | 927 | ||
928 | void PlayListWidget::populateAudioView() { | 928 | void PlayListWidget::populateAudioView() { |
929 | // if(files) | 929 | // if(files) |
930 | // files.~DocLnkSet(); | 930 | // files.~DocLnkSet(); |
931 | StorageInfo storageInfo; | 931 | StorageInfo storageInfo; |
932 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 932 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
933 | 933 | ||
934 | Global::findDocuments(&files, "audio/*"); | 934 | Global::findDocuments(&files, "audio/*"); |
935 | QListIterator<DocLnk> dit( files.children() ); | 935 | QListIterator<DocLnk> dit( files.children() ); |
936 | QListIterator<FileSystem> it ( fs ); | 936 | QListIterator<FileSystem> it ( fs ); |
937 | audioView->clear(); | 937 | audioView->clear(); |
938 | QString storage; | 938 | QString storage; |
939 | for ( ; dit.current(); ++dit ) { | 939 | for ( ; dit.current(); ++dit ) { |
940 | for( ; it.current(); ++it ){ | 940 | for( ; it.current(); ++it ){ |
941 | const QString name = (*it)->name(); | 941 | const QString name = (*it)->name(); |
942 | const QString path = (*it)->path(); | 942 | const QString path = (*it)->path(); |
943 | if(dit.current()->file().find(path) != -1 ) storage=name; | 943 | if(dit.current()->file().find(path) != -1 ) storage=name; |
944 | } | 944 | } |
945 | 945 | ||
946 | QListViewItem * newItem; | 946 | QListViewItem * newItem; |
947 | if ( QFile( dit.current()->file()).exists() ) { | 947 | if ( QFile( dit.current()->file()).exists() ) { |
948 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 948 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
949 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 949 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | } | 952 | } |
953 | 953 | ||
954 | void PlayListWidget::populateVideoView() { | 954 | void PlayListWidget::populateVideoView() { |
955 | StorageInfo storageInfo; | 955 | StorageInfo storageInfo; |
956 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 956 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
957 | 957 | ||
958 | Global::findDocuments(&vFiles, "video/*"); | 958 | Global::findDocuments(&vFiles, "video/*"); |
959 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 959 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
960 | QListIterator<FileSystem> it ( fs ); | 960 | QListIterator<FileSystem> it ( fs ); |
961 | videoView->clear(); | 961 | videoView->clear(); |
962 | QString storage; | 962 | QString storage; |
963 | for ( ; Vdit.current(); ++Vdit ) { | 963 | for ( ; Vdit.current(); ++Vdit ) { |
964 | for( ; it.current(); ++it ){ | 964 | for( ; it.current(); ++it ){ |
965 | const QString name = (*it)->name(); | 965 | const QString name = (*it)->name(); |
966 | const QString path = (*it)->path(); | 966 | const QString path = (*it)->path(); |
967 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 967 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
968 | } | 968 | } |
969 | 969 | ||
970 | QListViewItem * newItem; | 970 | QListViewItem * newItem; |
971 | if ( QFile( Vdit.current()->file()).exists() ) { | 971 | if ( QFile( Vdit.current()->file()).exists() ) { |
972 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 972 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
973 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 973 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
974 | } | 974 | } |
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | void PlayListWidget::openFile() { | 978 | void PlayListWidget::openFile() { |
979 | QString filename; | 979 | QString filename; |
980 | InputDialog *fileDlg; | 980 | InputDialog *fileDlg; |
981 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 981 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
982 | fileDlg->exec(); | 982 | fileDlg->exec(); |
983 | if( fileDlg->result() == 1 ) { | 983 | if( fileDlg->result() == 1 ) { |
984 | filename = fileDlg->LineEdit1->text(); | 984 | filename = fileDlg->LineEdit1->text(); |
985 | } | 985 | } |
986 | qDebug(filename); | 986 | qDebug(filename); |
987 | DocLnk lnk; | 987 | DocLnk lnk; |
988 | QString name = filename.right(filename.length()-filename.find("http://")-7); | 988 | QString name = filename.right(filename.length()-filename.find("http://")-7); |
989 | qDebug(name); | ||
989 | lnk.setName( name); //sets file name | 990 | lnk.setName( name); //sets file name |
990 | // lnk.setComment(); | 991 | // lnk.setComment(); |
991 | lnk.setFile(filename); //sets File property | 992 | lnk.setFile(filename); //sets File property |
992 | // problem is, the launcher sees this as a broken link and does not display it :( | 993 | // problem is, the launcher sees this as a broken link and does not display it :( |
993 | |||
994 | lnk.setType("audio/x-mpegurl"); | 994 | lnk.setType("audio/x-mpegurl"); |
995 | lnk.setExec("opieplayer"); | 995 | lnk.setExec("opieplayer"); |
996 | lnk.setIcon("opieplayer/MPEGPlayer"); | 996 | lnk.setIcon("opieplayer/MPEGPlayer"); |
997 | QString cmd="touch "+QPEApplication::documentDir()+"audio/x-mpegurl/"+name; | ||
998 | system( cmd.latin1()); | ||
999 | // d->selectedFiles->addToSelection( **dit ); | ||
1000 | 997 | ||
1001 | if(!lnk.writeLink()) | 998 | if(!lnk.writeLink()) |
1002 | qDebug("Writing doclink did not work"); | 999 | qDebug("Writing doclink did not work"); |
1000 | d->selectedFiles->addToSelection( lnk); | ||
1003 | if(fileDlg) | 1001 | if(fileDlg) |
1004 | delete fileDlg; | 1002 | delete fileDlg; |
1005 | } | 1003 | } |