author | zecke <zecke> | 2004-09-23 21:38:02 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-23 21:38:02 (UTC) |
commit | 97ab73d99688443d02086b4f00d1de7c81faa3c7 (patch) (unidiff) | |
tree | 63864e847abc41442d2ed88ca27a27ad1942c15a /noncore/multimedia/opieplayer2/playlistwidget.cpp | |
parent | 3080b2095fd9dddc4937cbf74037ce1dbc7fa6b2 (diff) | |
download | opie-97ab73d99688443d02086b4f00d1de7c81faa3c7.zip opie-97ab73d99688443d02086b4f00d1de7c81faa3c7.tar.gz opie-97ab73d99688443d02086b4f00d1de7c81faa3c7.tar.bz2 |
-Remove bogus whitespaces
-Remove stl dependency
-Make switching from fullscreen video to audio work
-Remove debug output
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 36f77be..d73f0cd 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -181,18 +181,16 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
181 | 181 | ||
182 | Config config( "OpiePlayer" ); | 182 | Config config( "OpiePlayer" ); |
183 | config.setGroup( "PlayList" ); | 183 | config.setGroup( "PlayList" ); |
184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
186 | if( currentString == filename) { | 186 | if( currentString == filename) { |
187 | Om3u *m3uList; | 187 | Om3u *m3uList; |
188 | // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; | ||
189 | if( d->selectedFiles->first() ) { | 188 | if( d->selectedFiles->first() ) { |
190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 189 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
191 | do { | 190 | do { |
192 | // odebug << d->selectedFiles->current()->file() << oendl; | ||
193 | m3uList->add( d->selectedFiles->current()->file() ); | 191 | m3uList->add( d->selectedFiles->current()->file() ); |
194 | } | 192 | } |
195 | while ( d->selectedFiles->next() ); | 193 | while ( d->selectedFiles->next() ); |
196 | 194 | ||
197 | m3uList->write(); | 195 | m3uList->write(); |
198 | m3uList->close(); | 196 | m3uList->close(); |
@@ -205,13 +203,12 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
205 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 203 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
206 | d->setDocumentUsed = FALSE; | 204 | d->setDocumentUsed = FALSE; |
207 | if( QFileInfo( lnk.file() ).exists() || | 205 | if( QFileInfo( lnk.file() ).exists() || |
208 | lnk.file().left(4) == "http" ) { | 206 | lnk.file().left(4) == "http" ) { |
209 | d->selectedFiles->addToSelection( lnk ); | 207 | d->selectedFiles->addToSelection( lnk ); |
210 | } | 208 | } |
211 | // writeCurrentM3u(); | ||
212 | } | 209 | } |
213 | 210 | ||
214 | 211 | ||
215 | void PlayListWidget::clearList() { | 212 | void PlayListWidget::clearList() { |
216 | while ( first() ) { | 213 | while ( first() ) { |
217 | d->selectedFiles->removeSelected(); | 214 | d->selectedFiles->removeSelected(); |
@@ -325,20 +322,20 @@ void PlayListWidget::addAllVideoToList() { | |||
325 | writeCurrentM3u(); | 322 | writeCurrentM3u(); |
326 | d->selectedFiles->first(); | 323 | d->selectedFiles->first(); |
327 | } | 324 | } |
328 | 325 | ||
329 | 326 | ||
330 | void PlayListWidget::setDocument( const QString& _fileref ) { | 327 | void PlayListWidget::setDocument( const QString& _fileref ) { |
331 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; | 328 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; |
332 | QString fileref = _fileref; | 329 | QString fileref = _fileref; |
333 | fromSetDocument = TRUE; | 330 | fromSetDocument = TRUE; |
334 | 331 | ||
335 | DocLnk lnk(_fileref); | 332 | DocLnk lnk(_fileref); |
336 | if(lnk.isValid()) | 333 | if(lnk.isValid()) |
337 | fileref = lnk.file(); | 334 | fileref = lnk.file(); |
338 | 335 | ||
339 | QFileInfo fileInfo(fileref); | 336 | QFileInfo fileInfo(fileref); |
340 | 337 | ||
341 | if ( !fileInfo.exists() ) { | 338 | if ( !fileInfo.exists() ) { |
342 | QMessageBox::warning( this, tr( "Invalid File" ), | 339 | QMessageBox::warning( this, tr( "Invalid File" ), |
343 | tr( "There was a problem in getting the file." ) ); | 340 | tr( "There was a problem in getting the file." ) ); |
344 | return; | 341 | return; |
@@ -407,13 +404,13 @@ bool PlayListWidget::prev() { | |||
407 | return TRUE; | 404 | return TRUE; |
408 | } | 405 | } |
409 | } | 406 | } |
410 | 407 | ||
411 | 408 | ||
412 | bool PlayListWidget::next() { | 409 | bool PlayListWidget::next() { |
413 | //odebug << "<<<<<<<<<<<<next()" << oendl; | 410 | //odebug << "<<<<<<<<<<<<next()" << oendl; |
414 | if ( mediaPlayerState->isShuffled() ) { | 411 | if ( mediaPlayerState->isShuffled() ) { |
415 | return prev(); | 412 | return prev(); |
416 | } else { | 413 | } else { |
417 | if ( !d->selectedFiles->next() ) { | 414 | if ( !d->selectedFiles->next() ) { |
418 | if ( mediaPlayerState->isLooping() ) { | 415 | if ( mediaPlayerState->isLooping() ) { |
419 | return d->selectedFiles->first(); | 416 | return d->selectedFiles->first(); |
@@ -618,13 +615,13 @@ void PlayListWidget::openURL() { | |||
618 | QString filename, name; | 615 | QString filename, name; |
619 | InputDialog *fileDlg; | 616 | InputDialog *fileDlg; |
620 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 617 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
621 | fileDlg->exec(); | 618 | fileDlg->exec(); |
622 | if( fileDlg->result() == 1 ) { | 619 | if( fileDlg->result() == 1 ) { |
623 | filename = fileDlg->text(); | 620 | filename = fileDlg->text(); |
624 | odebug << "Selected filename is " + filename << oendl; | 621 | odebug << "Selected filename is " + filename << oendl; |
625 | // Om3u *m3uList; | 622 | // Om3u *m3uList; |
626 | DocLnk lnk; | 623 | DocLnk lnk; |
627 | Config cfg( "OpiePlayer" ); | 624 | Config cfg( "OpiePlayer" ); |
628 | cfg.setGroup("PlayList"); | 625 | cfg.setGroup("PlayList"); |
629 | 626 | ||
630 | if(filename.left(4) == "http") { | 627 | if(filename.left(4) == "http") { |
@@ -694,13 +691,13 @@ void PlayListWidget::openFile() { | |||
694 | str=str.right(str.length()-1); | 691 | str=str.right(str.length()-1); |
695 | } | 692 | } |
696 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 693 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
697 | 694 | ||
698 | if( !str.isEmpty() ) { | 695 | if( !str.isEmpty() ) { |
699 | 696 | ||
700 | odebug << "Selected filename is " + str << oendl; | 697 | odebug << "Selected filename is " + str << oendl; |
701 | filename = str; | 698 | filename = str; |
702 | DocLnk lnk; | 699 | DocLnk lnk; |
703 | 700 | ||
704 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 701 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
705 | readListFromFile( filename ); | 702 | readListFromFile( filename ); |
706 | } else { | 703 | } else { |
@@ -712,26 +709,26 @@ void PlayListWidget::openFile() { | |||
712 | } | 709 | } |
713 | } | 710 | } |
714 | } | 711 | } |
715 | 712 | ||
716 | 713 | ||
717 | void PlayListWidget::readListFromFile( const QString &filename ) { | 714 | void PlayListWidget::readListFromFile( const QString &filename ) { |
718 | odebug << "read list filename " + filename << oendl; | 715 | odebug << "read list filename " + filename << oendl; |
719 | QFileInfo fi(filename); | 716 | QFileInfo fi(filename); |
720 | Om3u *m3uList; | 717 | Om3u *m3uList; |
721 | QString s, name; | 718 | QString s, name; |
722 | m3uList = new Om3u( filename, IO_ReadOnly ); | 719 | m3uList = new Om3u( filename, IO_ReadOnly ); |
723 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 720 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
724 | m3uList->readM3u(); | 721 | m3uList->readM3u(); |
725 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 722 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
726 | m3uList->readPls(); | 723 | m3uList->readPls(); |
727 | 724 | ||
728 | DocLnk lnk; | 725 | DocLnk lnk; |
729 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 726 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
730 | s = *it; | 727 | s = *it; |
731 | // odebug << s << oendl; | 728 | // odebug << s << oendl; |
732 | if(s.left(4)=="http") { | 729 | if(s.left(4)=="http") { |
733 | lnk.setName( s ); //sets file name | 730 | lnk.setName( s ); //sets file name |
734 | lnk.setIcon("opieplayer2/musicfile"); | 731 | lnk.setIcon("opieplayer2/musicfile"); |
735 | lnk.setFile( s ); //sets file name | 732 | lnk.setFile( s ); //sets file name |
736 | 733 | ||
737 | } else { //is file | 734 | } else { //is file |
@@ -759,27 +756,27 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
759 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 756 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
760 | 757 | ||
761 | } | 758 | } |
762 | 759 | ||
763 | // writes current playlist to current m3u file */ | 760 | // writes current playlist to current m3u file */ |
764 | void PlayListWidget::writeCurrentM3u() { | 761 | void PlayListWidget::writeCurrentM3u() { |
765 | odebug << "writing to current m3u" << oendl; | 762 | odebug << "writing to current m3u" << oendl; |
766 | Config cfg( "OpiePlayer" ); | 763 | Config cfg( "OpiePlayer" ); |
767 | cfg.setGroup("PlayList"); | 764 | cfg.setGroup("PlayList"); |
768 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 765 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
769 | 766 | ||
770 | Om3u *m3uList; | 767 | Om3u *m3uList; |
771 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 768 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
772 | if( d->selectedFiles->first()) { | 769 | if( d->selectedFiles->first()) { |
773 | 770 | ||
774 | do { | 771 | do { |
775 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 772 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
776 | m3uList->add( d->selectedFiles->current()->file() ); | 773 | m3uList->add( d->selectedFiles->current()->file() ); |
777 | } | 774 | } |
778 | while ( d->selectedFiles->next() ); | 775 | while ( d->selectedFiles->next() ); |
779 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 776 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
780 | m3uList->write(); | 777 | m3uList->write(); |
781 | m3uList->close(); | 778 | m3uList->close(); |
782 | } | 779 | } |
783 | delete m3uList; | 780 | delete m3uList; |
784 | 781 | ||
785 | } | 782 | } |
@@ -818,13 +815,13 @@ void PlayListWidget::writem3u() { | |||
818 | QString name, filename, list; | 815 | QString name, filename, list; |
819 | Om3u *m3uList; | 816 | Om3u *m3uList; |
820 | 817 | ||
821 | if( !str.isEmpty() ) { | 818 | if( !str.isEmpty() ) { |
822 | name = str; | 819 | name = str; |
823 | // name = fileDlg->text(); | 820 | // name = fileDlg->text(); |
824 | // odebug << filename << oendl; | 821 | // odebug << filename << oendl; |
825 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 822 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
826 | filename = name; | 823 | filename = name; |
827 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 824 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
828 | } | 825 | } |
829 | else //otherwise dump it somewhere noticable | 826 | else //otherwise dump it somewhere noticable |
830 | filename = QPEApplication::documentDir() + "/" + name; | 827 | filename = QPEApplication::documentDir() + "/" + name; |
@@ -836,33 +833,33 @@ void PlayListWidget::writem3u() { | |||
836 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 833 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
837 | 834 | ||
838 | do { | 835 | do { |
839 | m3uList->add( d->selectedFiles->current()->file()); | 836 | m3uList->add( d->selectedFiles->current()->file()); |
840 | } | 837 | } |
841 | while ( d->selectedFiles->next() ); | 838 | while ( d->selectedFiles->next() ); |
842 | // odebug << list << oendl; | 839 | // odebug << list << oendl; |
843 | m3uList->write(); | 840 | m3uList->write(); |
844 | m3uList->close(); | 841 | m3uList->close(); |
845 | delete m3uList; | 842 | delete m3uList; |
846 | 843 | ||
847 | //delete fileDlg; | 844 | //delete fileDlg; |
848 | 845 | ||
849 | DocLnk lnk; | 846 | DocLnk lnk; |
850 | lnk.setFile( filename); | 847 | lnk.setFile( filename); |
851 | lnk.setIcon("opieplayer2/playlist2"); | 848 | lnk.setIcon("opieplayer2/playlist2"); |
852 | lnk.setName( name); //sets file name | 849 | lnk.setName( name); //sets file name |
853 | 850 | ||
854 | // odebug << filename << oendl; | 851 | // odebug << filename << oendl; |
855 | Config config( "OpiePlayer" ); | 852 | Config config( "OpiePlayer" ); |
856 | config.setGroup( "PlayList" ); | 853 | config.setGroup( "PlayList" ); |
857 | 854 | ||
858 | config.writeEntry("CurrentPlaylist",filename); | 855 | config.writeEntry("CurrentPlaylist",filename); |
859 | currentPlayList=filename; | 856 | currentPlayList=filename; |
860 | 857 | ||
861 | if(!lnk.writeLink()) { | 858 | if(!lnk.writeLink()) { |
862 | odebug << "Writing doclink did not work" << oendl; | 859 | odebug << "Writing doclink did not work" << oendl; |
863 | } | 860 | } |
864 | 861 | ||
865 | setCaption(tr("OpiePlayer: ") + name); | 862 | setCaption(tr("OpiePlayer: ") + name); |
866 | } | 863 | } |
867 | } | 864 | } |
868 | } | 865 | } |
@@ -890,13 +887,13 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | |||
890 | addSelected(); | 887 | addSelected(); |
891 | break; | 888 | break; |
892 | case Key_R: //remove from playlist | 889 | case Key_R: //remove from playlist |
893 | removeSelected(); | 890 | removeSelected(); |
894 | break; | 891 | break; |
895 | // case Key_P: //play | 892 | // case Key_P: //play |
896 | // odebug << "Play" << oendl; | 893 | // odebug << "Play" << oendl; |
897 | // playSelected(); | 894 | // playSelected(); |
898 | // break; | 895 | // break; |
899 | case Key_Space: | 896 | case Key_Space: |
900 | // playSelected(); puh | 897 | // playSelected(); puh |
901 | break; | 898 | break; |
902 | case Key_1: | 899 | case Key_1: |
@@ -920,13 +917,13 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | |||
920 | // d->selectedFiles->last(); | 917 | // d->selectedFiles->last(); |
921 | break; | 918 | break; |
922 | } | 919 | } |
923 | } | 920 | } |
924 | 921 | ||
925 | void PlayListWidget::pmViewActivated(int index) { | 922 | void PlayListWidget::pmViewActivated(int index) { |
926 | // odebug << "" << index << "" << oendl; | 923 | // odebug << "" << index << "" << oendl; |
927 | switch(index) { | 924 | switch(index) { |
928 | case -16: | 925 | case -16: |
929 | { | 926 | { |
930 | mediaPlayerState->toggleFullscreen(); | 927 | mediaPlayerState->toggleFullscreen(); |
931 | bool b=mediaPlayerState->isFullscreen(); | 928 | bool b=mediaPlayerState->isFullscreen(); |
932 | pmView->setItemChecked( index, b); | 929 | pmView->setItemChecked( index, b); |
@@ -950,13 +947,13 @@ void PlayListWidget::populateSkinsMenu() { | |||
950 | skinsDir.setSorting(QDir::Name ); | 947 | skinsDir.setSorting(QDir::Name ); |
951 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 948 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
952 | QFileInfoListIterator it( *skinslist ); | 949 | QFileInfoListIterator it( *skinslist ); |
953 | QFileInfo *fi; | 950 | QFileInfo *fi; |
954 | while ( ( fi = it.current() ) ) { | 951 | while ( ( fi = it.current() ) ) { |
955 | skinName = fi->fileName(); | 952 | skinName = fi->fileName(); |
956 | // odebug << fi->fileName() << oendl; | 953 | // odebug << fi->fileName() << oendl; |
957 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 954 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
958 | item = skinsMenu->insertItem( fi->fileName() ) ; | 955 | item = skinsMenu->insertItem( fi->fileName() ) ; |
959 | } | 956 | } |
960 | if( skinName == "default" ) { | 957 | if( skinName == "default" ) { |
961 | defaultSkinIndex = item; | 958 | defaultSkinIndex = item; |
962 | } | 959 | } |
@@ -1006,13 +1003,13 @@ PlayListWidget::Entry PlayListWidget::currentEntry() const | |||
1006 | QString PlayListWidget::currentFileListPathName() const { | 1003 | QString PlayListWidget::currentFileListPathName() const { |
1007 | return currentFileListView->currentItem()->text( 3 ); | 1004 | return currentFileListView->currentItem()->text( 3 ); |
1008 | } | 1005 | } |
1009 | 1006 | ||
1010 | 1007 | ||
1011 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1008 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1012 | odebug << "qcop message "+msg << oendl; | 1009 | odebug << "qcop message "+msg << oendl; |
1013 | QDataStream stream ( data, IO_ReadOnly ); | 1010 | QDataStream stream ( data, IO_ReadOnly ); |
1014 | if ( msg == "play()" ) { //plays current selection | 1011 | if ( msg == "play()" ) { //plays current selection |
1015 | btnPlay( true); | 1012 | btnPlay( true); |
1016 | } else if ( msg == "stop()" ) { | 1013 | } else if ( msg == "stop()" ) { |
1017 | mediaPlayerState->setPlaying( false); | 1014 | mediaPlayerState->setPlaying( false); |
1018 | } else if ( msg == "togglePause()" ) { | 1015 | } else if ( msg == "togglePause()" ) { |