-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index f9192e8..7ada5ee 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -454,45 +454,45 @@ void PlayListWidget::addSelected() { | |||
454 | if ( it.current()->isSelected() ) { | 454 | if ( it.current()->isSelected() ) { |
455 | QListIterator<DocLnk> dit( files.children() ); | 455 | QListIterator<DocLnk> dit( files.children() ); |
456 | for ( ; dit.current(); ++dit ) { | 456 | for ( ; dit.current(); ++dit ) { |
457 | if( dit.current()->name() == it.current()->text(0) ) { | 457 | if( dit.current()->name() == it.current()->text(0) ) { |
458 | if( QFileInfo( dit.current()->file()).exists()) { | 458 | if( QFileInfo( dit.current()->file()).exists()) { |
459 | d->selectedFiles->addToSelection( **dit ); | 459 | d->selectedFiles->addToSelection( **dit ); |
460 | audioView->setSelected( it.current(),FALSE); | 460 | audioView->setSelected( it.current(),FALSE); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | tabWidget->setCurrentPage(0); | 466 | // tabWidget->setCurrentPage(0); |
467 | writeCurrentM3u(); | 467 | writeCurrentM3u(); |
468 | } | 468 | } |
469 | break; | 469 | break; |
470 | case 2: { // video | 470 | case 2: { // video |
471 | QListViewItemIterator it( videoView ); | 471 | QListViewItemIterator it( videoView ); |
472 | // iterate through all items of the listview | 472 | // iterate through all items of the listview |
473 | for ( ; it.current(); ++it ) { | 473 | for ( ; it.current(); ++it ) { |
474 | if ( it.current()->isSelected() ) { | 474 | if ( it.current()->isSelected() ) { |
475 | QListIterator<DocLnk> dit( vFiles.children() ); | 475 | QListIterator<DocLnk> dit( vFiles.children() ); |
476 | for ( ; dit.current(); ++dit ) { | 476 | for ( ; dit.current(); ++dit ) { |
477 | if( dit.current()->name() == it.current()->text(0) ) { | 477 | if( dit.current()->name() == it.current()->text(0) ) { |
478 | if(QFileInfo( dit.current()->file()).exists()) { | 478 | if(QFileInfo( dit.current()->file()).exists()) { |
479 | d->selectedFiles->addToSelection( **dit ); | 479 | d->selectedFiles->addToSelection( **dit ); |
480 | videoView->setSelected( it.current(),FALSE); | 480 | videoView->setSelected( it.current(),FALSE); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | tabWidget->setCurrentPage(0); | 486 | // tabWidget->setCurrentPage(0); |
487 | writeCurrentM3u(); | 487 | writeCurrentM3u(); |
488 | } | 488 | } |
489 | break; | 489 | break; |
490 | }; | 490 | }; |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | void PlayListWidget::removeSelected() { | 494 | void PlayListWidget::removeSelected() { |
495 | d->selectedFiles->removeSelected( ); | 495 | d->selectedFiles->removeSelected( ); |
496 | writeCurrentM3u(); | 496 | writeCurrentM3u(); |
497 | } | 497 | } |
498 | 498 | ||
@@ -759,42 +759,48 @@ void PlayListWidget::openFile() { | |||
759 | /* | 759 | /* |
760 | reads m3u and shows files/urls to playlist widget */ | 760 | reads m3u and shows files/urls to playlist widget */ |
761 | void PlayListWidget::readm3u( const QString &filename ) { | 761 | void PlayListWidget::readm3u( const QString &filename ) { |
762 | qDebug( "read m3u filename " + filename ); | 762 | qDebug( "read m3u filename " + filename ); |
763 | 763 | ||
764 | Om3u *m3uList; | 764 | Om3u *m3uList; |
765 | QString s, name; | 765 | QString s, name; |
766 | m3uList = new Om3u( filename, IO_ReadOnly ); | 766 | m3uList = new Om3u( filename, IO_ReadOnly ); |
767 | m3uList->readM3u(); | 767 | m3uList->readM3u(); |
768 | DocLnk lnk; | 768 | DocLnk lnk; |
769 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 769 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
770 | s = *it; | 770 | s = *it; |
771 | // s.replace( QRegExp( "%20" )," " ); | ||
772 | // qDebug("reading "+ s); | 771 | // qDebug("reading "+ s); |
773 | if(s.left(4)=="http") { | 772 | if(s.left(4)=="http") { |
774 | lnk.setName( s ); //sets file name | 773 | lnk.setName( s ); //sets file name |
774 | lnk.setIcon("opieplayer2/musicfile"); | ||
775 | if(s.right(4) != '.' || s.right(5) != '.') | ||
776 | lnk.setFile( s+"/"); //if url with no extension | ||
777 | else | ||
775 | lnk.setFile( s ); //sets file name | 778 | lnk.setFile( s ); //sets file name |
776 | lnk.setIcon("opieplayer2/musicfile"); | 779 | |
780 | } else { | ||
781 | // if( QFileInfo( s ).exists() ) { | ||
782 | lnk.setName( QFileInfo(s).baseName()); | ||
783 | // if(s.right(4) == '.') {//if regular file | ||
784 | if(s.left(1) != "/") { | ||
785 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | ||
786 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | ||
787 | lnk.setIcon("SoundPlayer"); | ||
788 | } else { | ||
789 | // qDebug("set link2 "+s); | ||
790 | lnk.setFile( s); | ||
791 | lnk.setIcon("SoundPlayer"); | ||
792 | } | ||
777 | } | 793 | } |
778 | else { | 794 | d->selectedFiles->addToSelection( lnk ); |
779 | if( QFileInfo( s ).exists() ) { | ||
780 | lnk.setName( QFileInfo(s).baseName()); | ||
781 | // qDebug("set link "+s); | ||
782 | if(s.at(s.length()-4) == '.') //if regular file | ||
783 | lnk.setFile( s); | ||
784 | else | ||
785 | lnk.setFile( s+"/"); //if url with no extension | ||
786 | } | ||
787 | } | ||
788 | d->selectedFiles->addToSelection( lnk ); | ||
789 | } | 795 | } |
790 | Config config( "OpiePlayer" ); | 796 | Config config( "OpiePlayer" ); |
791 | config.setGroup( "PlayList" ); | 797 | config.setGroup( "PlayList" ); |
792 | 798 | ||
793 | config.writeEntry("CurrentPlaylist",filename); | 799 | config.writeEntry("CurrentPlaylist",filename); |
794 | config.write(); | 800 | config.write(); |
795 | currentPlayList=filename; | 801 | currentPlayList=filename; |
796 | 802 | ||
797 | // m3uList->write(); | 803 | // m3uList->write(); |
798 | m3uList->close(); | 804 | m3uList->close(); |
799 | if(m3uList) delete m3uList; | 805 | if(m3uList) delete m3uList; |
800 | 806 | ||
@@ -850,28 +856,26 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
850 | /* | 856 | /* |
851 | writes current playlist to current m3u file */ | 857 | writes current playlist to current m3u file */ |
852 | void PlayListWidget::writeCurrentM3u() { | 858 | void PlayListWidget::writeCurrentM3u() { |
853 | qDebug("writing to current m3u"); | 859 | qDebug("writing to current m3u"); |
854 | Config cfg( "OpiePlayer" ); | 860 | Config cfg( "OpiePlayer" ); |
855 | cfg.setGroup("PlayList"); | 861 | cfg.setGroup("PlayList"); |
856 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 862 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
857 | 863 | ||
858 | if( d->selectedFiles->first()) { | 864 | if( d->selectedFiles->first()) { |
859 | Om3u *m3uList; | 865 | Om3u *m3uList; |
860 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 866 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
861 | 867 | ||
862 | |||
863 | qDebug( d->selectedFiles->current()->file()); | ||
864 | do { | 868 | do { |
865 | qDebug( d->selectedFiles->current()->file()); | 869 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
866 | m3uList->add( d->selectedFiles->current()->file() ); | 870 | m3uList->add( d->selectedFiles->current()->file() ); |
867 | } | 871 | } |
868 | while ( d->selectedFiles->next() ); | 872 | while ( d->selectedFiles->next() ); |
869 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 873 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
870 | m3uList->write(); | 874 | m3uList->write(); |
871 | m3uList->close(); | 875 | m3uList->close(); |
872 | 876 | ||
873 | if(m3uList) delete m3uList; | 877 | if(m3uList) delete m3uList; |
874 | } | 878 | } |
875 | } | 879 | } |
876 | 880 | ||
877 | /* | 881 | /* |