-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 16 |
2 files changed, 8 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 975dec3..2019b3a 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp | |||
@@ -105,26 +105,25 @@ const DocLnk *PlayListSelection::current() { | |||
105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
107 | QListViewItem *current = selectedItem(); | 107 | QListViewItem *current = selectedItem(); |
108 | if ( current ) | 108 | if ( current ) |
109 | item->moveItem( current ); | 109 | item->moveItem( current ); |
110 | setSelected( item, TRUE ); | 110 | setSelected( item, TRUE ); |
111 | ensureItemVisible( selectedItem() ); | 111 | ensureItemVisible( selectedItem() ); |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | void PlayListSelection::removeSelected() { | 115 | void PlayListSelection::removeSelected() { |
116 | QListViewItem *item = selectedItem(); | 116 | QListViewItem *item = selectedItem(); |
117 | if ( item ) | 117 | delete item; |
118 | delete item; | ||
119 | setSelected( currentItem(), TRUE ); | 118 | setSelected( currentItem(), TRUE ); |
120 | ensureItemVisible( selectedItem() ); | 119 | ensureItemVisible( selectedItem() ); |
121 | } | 120 | } |
122 | 121 | ||
123 | 122 | ||
124 | void PlayListSelection::moveSelectedUp() { | 123 | void PlayListSelection::moveSelectedUp() { |
125 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
126 | if ( item && item->itemAbove() ) | 125 | if ( item && item->itemAbove() ) |
127 | item->itemAbove()->moveItem( item ); | 126 | item->itemAbove()->moveItem( item ); |
128 | ensureItemVisible( selectedItem() ); | 127 | ensureItemVisible( selectedItem() ); |
129 | } | 128 | } |
130 | 129 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 86b3424..ac52b07 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -182,25 +182,25 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
182 | Om3u *m3uList; | 182 | Om3u *m3uList; |
183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
184 | if( d->selectedFiles->first() ) { | 184 | if( d->selectedFiles->first() ) { |
185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
186 | do { | 186 | do { |
187 | // qDebug(d->selectedFiles->current()->file()); | 187 | // qDebug(d->selectedFiles->current()->file()); |
188 | m3uList->add( d->selectedFiles->current()->file() ); | 188 | m3uList->add( d->selectedFiles->current()->file() ); |
189 | } | 189 | } |
190 | while ( d->selectedFiles->next() ); | 190 | while ( d->selectedFiles->next() ); |
191 | 191 | ||
192 | m3uList->write(); | 192 | m3uList->write(); |
193 | m3uList->close(); | 193 | m3uList->close(); |
194 | if(m3uList) delete m3uList; | 194 | delete m3uList; |
195 | 195 | ||
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
201 | d->setDocumentUsed = FALSE; | 201 | d->setDocumentUsed = FALSE; |
202 | if( QFileInfo( lnk.file() ).exists() || | 202 | if( QFileInfo( lnk.file() ).exists() || |
203 | lnk.file().left(4) == "http" ) { | 203 | lnk.file().left(4) == "http" ) { |
204 | d->selectedFiles->addToSelection( lnk ); | 204 | d->selectedFiles->addToSelection( lnk ); |
205 | } | 205 | } |
206 | // writeCurrentM3u(); | 206 | // writeCurrentM3u(); |
@@ -675,27 +675,25 @@ void PlayListWidget::openFile() { | |||
675 | 675 | ||
676 | } else if( filename.right(3) == "pls" ) { | 676 | } else if( filename.right(3) == "pls" ) { |
677 | readPls( filename ); | 677 | readPls( filename ); |
678 | } else { | 678 | } else { |
679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
680 | lnk.setFile( filename ); //sets file name | 680 | lnk.setFile( filename ); //sets file name |
681 | d->selectedFiles->addToSelection( lnk); | 681 | d->selectedFiles->addToSelection( lnk); |
682 | writeCurrentM3u(); | 682 | writeCurrentM3u(); |
683 | d->selectedFiles->setSelectedItem( lnk.name()); | 683 | d->selectedFiles->setSelectedItem( lnk.name()); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | if( fileDlg ) { | 687 | delete fileDlg; |
688 | delete fileDlg; | ||
689 | } | ||
690 | } | 688 | } |
691 | 689 | ||
692 | /* | 690 | /* |
693 | reads m3u and shows files/urls to playlist widget */ | 691 | reads m3u and shows files/urls to playlist widget */ |
694 | void PlayListWidget::readm3u( const QString &filename ) { | 692 | void PlayListWidget::readm3u( const QString &filename ) { |
695 | qDebug( "read m3u filename " + filename ); | 693 | qDebug( "read m3u filename " + filename ); |
696 | 694 | ||
697 | Om3u *m3uList; | 695 | Om3u *m3uList; |
698 | QString s, name; | 696 | QString s, name; |
699 | m3uList = new Om3u( filename, IO_ReadOnly ); | 697 | m3uList = new Om3u( filename, IO_ReadOnly ); |
700 | m3uList->readM3u(); | 698 | m3uList->readM3u(); |
701 | DocLnk lnk; | 699 | DocLnk lnk; |
@@ -725,25 +723,25 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
725 | } | 723 | } |
726 | d->selectedFiles->addToSelection( lnk ); | 724 | d->selectedFiles->addToSelection( lnk ); |
727 | } | 725 | } |
728 | Config config( "OpiePlayer" ); | 726 | Config config( "OpiePlayer" ); |
729 | config.setGroup( "PlayList" ); | 727 | config.setGroup( "PlayList" ); |
730 | 728 | ||
731 | config.writeEntry("CurrentPlaylist",filename); | 729 | config.writeEntry("CurrentPlaylist",filename); |
732 | config.write(); | 730 | config.write(); |
733 | currentPlayList=filename; | 731 | currentPlayList=filename; |
734 | 732 | ||
735 | // m3uList->write(); | 733 | // m3uList->write(); |
736 | m3uList->close(); | 734 | m3uList->close(); |
737 | if(m3uList) delete m3uList; | 735 | delete m3uList; |
738 | 736 | ||
739 | d->selectedFiles->setSelectedItem( s); | 737 | d->selectedFiles->setSelectedItem( s); |
740 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
741 | 739 | ||
742 | } | 740 | } |
743 | 741 | ||
744 | /* | 742 | /* |
745 | reads pls and adds files/urls to playlist */ | 743 | reads pls and adds files/urls to playlist */ |
746 | void PlayListWidget::readPls( const QString &filename ) { | 744 | void PlayListWidget::readPls( const QString &filename ) { |
747 | 745 | ||
748 | qDebug( "pls filename is " + filename ); | 746 | qDebug( "pls filename is " + filename ); |
749 | Om3u *m3uList; | 747 | Om3u *m3uList; |
@@ -773,49 +771,49 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
773 | // if( name.right( 1 ).find( '/' ) == -1) { | 771 | // if( name.right( 1 ).find( '/' ) == -1) { |
774 | // s += "/"; | 772 | // s += "/"; |
775 | // } | 773 | // } |
776 | lnk.setFile( s ); | 774 | lnk.setFile( s ); |
777 | } | 775 | } |
778 | lnk.setType( "audio/x-mpegurl" ); | 776 | lnk.setType( "audio/x-mpegurl" ); |
779 | 777 | ||
780 | lnk.writeLink(); | 778 | lnk.writeLink(); |
781 | d->selectedFiles->addToSelection( lnk ); | 779 | d->selectedFiles->addToSelection( lnk ); |
782 | } | 780 | } |
783 | 781 | ||
784 | m3uList->close(); | 782 | m3uList->close(); |
785 | if(m3uList) delete m3uList; | 783 | delete m3uList; |
786 | } | 784 | } |
787 | 785 | ||
788 | /* | 786 | /* |
789 | writes current playlist to current m3u file */ | 787 | writes current playlist to current m3u file */ |
790 | void PlayListWidget::writeCurrentM3u() { | 788 | void PlayListWidget::writeCurrentM3u() { |
791 | qDebug("writing to current m3u"); | 789 | qDebug("writing to current m3u"); |
792 | Config cfg( "OpiePlayer" ); | 790 | Config cfg( "OpiePlayer" ); |
793 | cfg.setGroup("PlayList"); | 791 | cfg.setGroup("PlayList"); |
794 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
795 | 793 | ||
796 | Om3u *m3uList; | 794 | Om3u *m3uList; |
797 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
798 | if( d->selectedFiles->first()) { | 796 | if( d->selectedFiles->first()) { |
799 | 797 | ||
800 | do { | 798 | do { |
801 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
802 | m3uList->add( d->selectedFiles->current()->file() ); | 800 | m3uList->add( d->selectedFiles->current()->file() ); |
803 | } | 801 | } |
804 | while ( d->selectedFiles->next() ); | 802 | while ( d->selectedFiles->next() ); |
805 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
806 | m3uList->write(); | 804 | m3uList->write(); |
807 | m3uList->close(); | 805 | m3uList->close(); |
808 | 806 | ||
809 | if(m3uList) delete m3uList; | 807 | delete m3uList; |
810 | } | 808 | } |
811 | 809 | ||
812 | } | 810 | } |
813 | 811 | ||
814 | /* | 812 | /* |
815 | writes current playlist to m3u file */ | 813 | writes current playlist to m3u file */ |
816 | void PlayListWidget::writem3u() { | 814 | void PlayListWidget::writem3u() { |
817 | InputDialog *fileDlg; | 815 | InputDialog *fileDlg; |
818 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 816 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
819 | fileDlg->exec(); | 817 | fileDlg->exec(); |
820 | QString name, filename, list; | 818 | QString name, filename, list; |
821 | Om3u *m3uList; | 819 | Om3u *m3uList; |
@@ -833,27 +831,27 @@ void PlayListWidget::writem3u() { | |||
833 | } | 831 | } |
834 | 832 | ||
835 | if( d->selectedFiles->first()) { | 833 | if( d->selectedFiles->first()) { |
836 | m3uList = new Om3u(filename, IO_ReadWrite); | 834 | m3uList = new Om3u(filename, IO_ReadWrite); |
837 | 835 | ||
838 | do { | 836 | do { |
839 | m3uList->add( d->selectedFiles->current()->file()); | 837 | m3uList->add( d->selectedFiles->current()->file()); |
840 | } | 838 | } |
841 | while ( d->selectedFiles->next() ); | 839 | while ( d->selectedFiles->next() ); |
842 | // qDebug( list ); | 840 | // qDebug( list ); |
843 | m3uList->write(); | 841 | m3uList->write(); |
844 | m3uList->close(); | 842 | m3uList->close(); |
845 | if(m3uList) delete m3uList; | 843 | delete m3uList; |
846 | 844 | ||
847 | if(fileDlg) delete fileDlg; | 845 | delete fileDlg; |
848 | 846 | ||
849 | DocLnk lnk; | 847 | DocLnk lnk; |
850 | lnk.setFile( filename); | 848 | lnk.setFile( filename); |
851 | lnk.setIcon("opieplayer2/playlist2"); | 849 | lnk.setIcon("opieplayer2/playlist2"); |
852 | lnk.setName( name); //sets file name | 850 | lnk.setName( name); //sets file name |
853 | 851 | ||
854 | // qDebug(filename); | 852 | // qDebug(filename); |
855 | Config config( "OpiePlayer" ); | 853 | Config config( "OpiePlayer" ); |
856 | config.setGroup( "PlayList" ); | 854 | config.setGroup( "PlayList" ); |
857 | 855 | ||
858 | config.writeEntry("CurrentPlaylist",filename); | 856 | config.writeEntry("CurrentPlaylist",filename); |
859 | currentPlayList=filename; | 857 | currentPlayList=filename; |