Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e28efd0..f9192e8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -164,61 +164,63 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
164 | 164 | ||
165 | 165 | ||
166 | PlayListWidget::~PlayListWidget() { | 166 | PlayListWidget::~PlayListWidget() { |
167 | if ( d->current ) { | 167 | if ( d->current ) { |
168 | delete d->current; | 168 | delete d->current; |
169 | } | 169 | } |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void PlayListWidget::initializeStates() { | 174 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 175 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
176 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 176 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
178 | setPlaylist( true ); | 178 | setPlaylist( true ); |
179 | } | 179 | } |
180 | 180 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 181 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 182 | ||
183 | Config config( "OpiePlayer" ); | 183 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 184 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 187 | if( currentString == filename) { |
188 | Om3u *m3uList; | 188 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | ||
190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
191 | d->selectedFiles->first(); | ||
192 | do { | 192 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 193 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 194 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 195 | } |
196 | while ( d->selectedFiles->next() ); | 196 | while ( d->selectedFiles->next() ); |
197 | 197 | ||
198 | m3uList->write(); | 198 | m3uList->write(); |
199 | m3uList->close(); | 199 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 200 | if(m3uList) delete m3uList; |
201 | |||
202 | } | ||
201 | } | 203 | } |
202 | } | 204 | } |
203 | 205 | ||
204 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
205 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
206 | if ( mediaPlayerState->playlist() ) { | 208 | if ( mediaPlayerState->playlist() ) { |
207 | if( QFileInfo( lnk.file() ).exists() || | 209 | if( QFileInfo( lnk.file() ).exists() || |
208 | lnk.file().left(4) == "http" ) | 210 | lnk.file().left(4) == "http" ) |
209 | d->selectedFiles->addToSelection( lnk ); | 211 | d->selectedFiles->addToSelection( lnk ); |
210 | // writeCurrentM3u(); | 212 | // writeCurrentM3u(); |
211 | } | 213 | } |
212 | else | 214 | else |
213 | mediaPlayerState->setPlaying( TRUE ); | 215 | mediaPlayerState->setPlaying( TRUE ); |
214 | } | 216 | } |
215 | 217 | ||
216 | 218 | ||
217 | void PlayListWidget::clearList() { | 219 | void PlayListWidget::clearList() { |
218 | while ( first() ) { | 220 | while ( first() ) { |
219 | d->selectedFiles->removeSelected(); | 221 | d->selectedFiles->removeSelected(); |
220 | } | 222 | } |
221 | } | 223 | } |
222 | 224 | ||
223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
224 | switch (mouse) { | 226 | switch (mouse) { |
@@ -832,119 +834,121 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
832 | } else { //if its a url | 834 | } else { //if its a url |
833 | if( name.right( 1 ).find( '/' ) == -1) { | 835 | if( name.right( 1 ).find( '/' ) == -1) { |
834 | s += "/"; | 836 | s += "/"; |
835 | } | 837 | } |
836 | lnk.setFile( s ); | 838 | lnk.setFile( s ); |
837 | } | 839 | } |
838 | lnk.setType( "audio/x-mpegurl" ); | 840 | lnk.setType( "audio/x-mpegurl" ); |
839 | 841 | ||
840 | lnk.writeLink(); | 842 | lnk.writeLink(); |
841 | d->selectedFiles->addToSelection( lnk ); | 843 | d->selectedFiles->addToSelection( lnk ); |
842 | } | 844 | } |
843 | 845 | ||
844 | m3uList->close(); | 846 | m3uList->close(); |
845 | if(m3uList) delete m3uList; | 847 | if(m3uList) delete m3uList; |
846 | } | 848 | } |
847 | 849 | ||
848 | /* | 850 | /* |
849 | writes current playlist to current m3u file */ | 851 | writes current playlist to current m3u file */ |
850 | void PlayListWidget::writeCurrentM3u() { | 852 | void PlayListWidget::writeCurrentM3u() { |
851 | qDebug("writing to current m3u"); | 853 | qDebug("writing to current m3u"); |
852 | Config cfg( "OpiePlayer" ); | 854 | Config cfg( "OpiePlayer" ); |
853 | cfg.setGroup("PlayList"); | 855 | cfg.setGroup("PlayList"); |
854 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 856 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
855 | 857 | ||
858 | if( d->selectedFiles->first()) { | ||
856 | Om3u *m3uList; | 859 | Om3u *m3uList; |
857 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 860 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
858 | d->selectedFiles->first(); | 861 | |
862 | |||
859 | qDebug( d->selectedFiles->current()->file()); | 863 | qDebug( d->selectedFiles->current()->file()); |
860 | do { | 864 | do { |
861 | qDebug( d->selectedFiles->current()->file()); | 865 | qDebug( d->selectedFiles->current()->file()); |
862 | m3uList->add( d->selectedFiles->current()->file() ); | 866 | m3uList->add( d->selectedFiles->current()->file() ); |
863 | } | 867 | } |
864 | while ( d->selectedFiles->next() ); | 868 | while ( d->selectedFiles->next() ); |
865 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 869 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
866 | m3uList->write(); | 870 | m3uList->write(); |
867 | m3uList->close(); | 871 | m3uList->close(); |
868 | 872 | ||
869 | if(m3uList) delete m3uList; | 873 | if(m3uList) delete m3uList; |
874 | } | ||
870 | } | 875 | } |
871 | 876 | ||
872 | /* | 877 | /* |
873 | writes current playlist to m3u file */ | 878 | writes current playlist to m3u file */ |
874 | void PlayListWidget::writem3u() { | 879 | void PlayListWidget::writem3u() { |
875 | InputDialog *fileDlg; | 880 | InputDialog *fileDlg; |
876 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 881 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
877 | fileDlg->exec(); | 882 | fileDlg->exec(); |
878 | QString name, filename, list; | 883 | QString name, filename, list; |
879 | Om3u *m3uList; | 884 | Om3u *m3uList; |
880 | 885 | ||
881 | if( fileDlg->result() == 1 ) { | 886 | if( fileDlg->result() == 1 ) { |
882 | name = fileDlg->text(); | 887 | name = fileDlg->text(); |
883 | // qDebug( filename ); | 888 | // qDebug( filename ); |
884 | 889 | ||
885 | if( name.left( 1) != "/" ) { | 890 | if( name.left( 1) != "/" ) { |
886 | filename = QPEApplication::documentDir() + "/" + name; | 891 | filename = QPEApplication::documentDir() + "/" + name; |
887 | } | 892 | } |
888 | 893 | ||
889 | if( name.right( 3 ) != "m3u" ) { | 894 | if( name.right( 3 ) != "m3u" ) { |
890 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 895 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
891 | } | 896 | } |
892 | 897 | ||
898 | if( d->selectedFiles->first()) { | ||
893 | m3uList = new Om3u(filename, IO_ReadWrite); | 899 | m3uList = new Om3u(filename, IO_ReadWrite); |
894 | |||
895 | d->selectedFiles->first(); | ||
896 | 900 | ||
897 | do { | 901 | do { |
898 | m3uList->add( d->selectedFiles->current()->file()); | 902 | m3uList->add( d->selectedFiles->current()->file()); |
899 | } | 903 | } |
900 | while ( d->selectedFiles->next() ); | 904 | while ( d->selectedFiles->next() ); |
901 | // qDebug( list ); | 905 | // qDebug( list ); |
902 | m3uList->write(); | 906 | m3uList->write(); |
903 | m3uList->close(); | 907 | m3uList->close(); |
904 | if(m3uList) delete m3uList; | 908 | if(m3uList) delete m3uList; |
905 | 909 | ||
906 | if(fileDlg) delete fileDlg; | 910 | if(fileDlg) delete fileDlg; |
907 | 911 | ||
908 | DocLnk lnk; | 912 | DocLnk lnk; |
909 | lnk.setFile( filename); | 913 | lnk.setFile( filename); |
910 | lnk.setIcon("opieplayer2/playlist2"); | 914 | lnk.setIcon("opieplayer2/playlist2"); |
911 | lnk.setName( name); //sets file name | 915 | lnk.setName( name); //sets file name |
912 | 916 | ||
913 | // qDebug(filename); | 917 | // qDebug(filename); |
914 | Config config( "OpiePlayer" ); | 918 | Config config( "OpiePlayer" ); |
915 | config.setGroup( "PlayList" ); | 919 | config.setGroup( "PlayList" ); |
916 | 920 | ||
917 | config.writeEntry("CurrentPlaylist",filename); | 921 | config.writeEntry("CurrentPlaylist",filename); |
918 | currentPlayList=filename; | 922 | currentPlayList=filename; |
919 | 923 | ||
920 | if(!lnk.writeLink()) { | 924 | if(!lnk.writeLink()) { |
921 | qDebug("Writing doclink did not work"); | 925 | qDebug("Writing doclink did not work"); |
922 | } | 926 | } |
923 | 927 | ||
924 | setCaption(tr("OpiePlayer: ") + name); | 928 | setCaption(tr("OpiePlayer: ") + name); |
929 | } | ||
925 | } | 930 | } |
926 | |||
927 | } | 931 | } |
928 | 932 | ||
929 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 933 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
930 | switch ( e->key() ) { | 934 | switch ( e->key() ) { |
931 | ////////////////////////////// Zaurus keys | 935 | ////////////////////////////// Zaurus keys |
932 | case Key_F9: //activity | 936 | case Key_F9: //activity |
933 | // if(audioUI->isHidden()) | 937 | // if(audioUI->isHidden()) |
934 | // audioUI->showMaximized(); | 938 | // audioUI->showMaximized(); |
935 | break; | 939 | break; |
936 | case Key_F10: //contacts | 940 | case Key_F10: //contacts |
937 | // if( videoUI->isHidden()) | 941 | // if( videoUI->isHidden()) |
938 | // videoUI->showMaximized(); | 942 | // videoUI->showMaximized(); |
939 | break; | 943 | break; |
940 | case Key_F11: //menu | 944 | case Key_F11: //menu |
941 | break; | 945 | break; |
942 | case Key_F12: //home | 946 | case Key_F12: //home |
943 | // doBlank(); | 947 | // doBlank(); |
944 | break; | 948 | break; |
945 | case Key_F13: //mail | 949 | case Key_F13: //mail |
946 | // doUnblank(); | 950 | // doUnblank(); |
947 | break; | 951 | break; |
948 | case Key_Q: //add to playlist | 952 | case Key_Q: //add to playlist |
949 | addSelected(); | 953 | addSelected(); |
950 | break; | 954 | break; |