summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistselection.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp16
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
@@ -69,98 +69,97 @@ PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
69 69
70PlayListSelection::~PlayListSelection() { 70PlayListSelection::~PlayListSelection() {
71} 71}
72 72
73 73
74// #ifdef USE_PLAYLIST_BACKGROUND 74// #ifdef USE_PLAYLIST_BACKGROUND
75void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 75void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
76// qDebug("drawBackground"); 76// qDebug("drawBackground");
77 p->fillRect( r, QBrush( white ) ); 77 p->fillRect( r, QBrush( white ) );
78// QImage logo = Resource::loadImage( "launcher/opielogo" ); 78// QImage logo = Resource::loadImage( "launcher/opielogo" );
79// if ( !logo.isNull() ) 79// if ( !logo.isNull() )
80// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); 80// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
81} 81}
82// #endif 82// #endif
83 83
84 84
85void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 85void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
86 if ( event->state() == QMouseEvent::LeftButton ) { 86 if ( event->state() == QMouseEvent::LeftButton ) {
87 QListViewItem *currentItem = selectedItem(); 87 QListViewItem *currentItem = selectedItem();
88 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 88 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
89 if ( currentItem && currentItem->itemAbove() == itemUnder ) 89 if ( currentItem && currentItem->itemAbove() == itemUnder )
90 moveSelectedUp(); 90 moveSelectedUp();
91 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 91 else if ( currentItem && currentItem->itemBelow() == itemUnder )
92 moveSelectedDown(); 92 moveSelectedDown();
93 } 93 }
94} 94}
95 95
96 96
97const DocLnk *PlayListSelection::current() { 97const DocLnk *PlayListSelection::current() {
98 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 98 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
99 if ( item ) 99 if ( item )
100 return item->file(); 100 return item->file();
101 return NULL; 101 return NULL;
102} 102}
103 103
104 104
105void PlayListSelection::addToSelection( const DocLnk &lnk ) { 105void 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
115void PlayListSelection::removeSelected() { 115void 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
124void PlayListSelection::moveSelectedUp() { 123void 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
131 130
132void PlayListSelection::moveSelectedDown() { 131void PlayListSelection::moveSelectedDown() {
133 QListViewItem *item = selectedItem(); 132 QListViewItem *item = selectedItem();
134 if ( item && item->itemBelow() ) 133 if ( item && item->itemBelow() )
135 item->moveItem( item->itemBelow() ); 134 item->moveItem( item->itemBelow() );
136 ensureItemVisible( selectedItem() ); 135 ensureItemVisible( selectedItem() );
137} 136}
138 137
139 138
140bool PlayListSelection::prev() { 139bool PlayListSelection::prev() {
141 QListViewItem *item = selectedItem(); 140 QListViewItem *item = selectedItem();
142 if ( item && item->itemAbove() ) 141 if ( item && item->itemAbove() )
143 setSelected( item->itemAbove(), TRUE ); 142 setSelected( item->itemAbove(), TRUE );
144 else 143 else
145 return FALSE; 144 return FALSE;
146 ensureItemVisible( selectedItem() ); 145 ensureItemVisible( selectedItem() );
147 return TRUE; 146 return TRUE;
148} 147}
149 148
150bool PlayListSelection::next() { 149bool PlayListSelection::next() {
151 QListViewItem *item = selectedItem(); 150 QListViewItem *item = selectedItem();
152 if ( item && item->itemBelow() ) 151 if ( item && item->itemBelow() )
153 setSelected( item->itemBelow(), TRUE ); 152 setSelected( item->itemBelow(), TRUE );
154 else 153 else
155 return FALSE; 154 return FALSE;
156 ensureItemVisible( selectedItem() ); 155 ensureItemVisible( selectedItem() );
157 return TRUE; 156 return TRUE;
158} 157}
159 158
160 159
161bool PlayListSelection::first() { 160bool PlayListSelection::first() {
162 QListViewItem *item = firstChild(); 161 QListViewItem *item = firstChild();
163 if ( item ) 162 if ( item )
164 setSelected( item, TRUE ); 163 setSelected( item, TRUE );
165 else 164 else
166 return FALSE; 165 return FALSE;
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
@@ -146,97 +146,97 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
146 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 146 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
147 d->tbShuffle, SLOT( setOn( bool ) ) ); 147 d->tbShuffle, SLOT( setOn( bool ) ) );
148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
149 this, SLOT( playIt( QListViewItem *) ) ); 149 this, SLOT( playIt( QListViewItem *) ) );
150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
151 &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 151 &mediaPlayerState, SLOT( setVideoGamma( int ) ) );
152 152
153 // see which skins are installed 153 // see which skins are installed
154 populateSkinsMenu(); 154 populateSkinsMenu();
155 initializeStates(); 155 initializeStates();
156 156
157 cfg.setGroup("PlayList"); 157 cfg.setGroup("PlayList");
158 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 158 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
159 loadList(DocLnk( currentPlaylist ) ); 159 loadList(DocLnk( currentPlaylist ) );
160} 160}
161 161
162 162
163PlayListWidget::~PlayListWidget() { 163PlayListWidget::~PlayListWidget() {
164 delete d; 164 delete d;
165} 165}
166 166
167 167
168void PlayListWidget::initializeStates() { 168void PlayListWidget::initializeStates() {
169 d->tbPlay->setOn( mediaPlayerState.isPlaying() ); 169 d->tbPlay->setOn( mediaPlayerState.isPlaying() );
170 d->tbLoop->setOn( mediaPlayerState.isLooping() ); 170 d->tbLoop->setOn( mediaPlayerState.isLooping() );
171 d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); 171 d->tbShuffle->setOn( mediaPlayerState.isShuffled() );
172 d->playListFrame->show(); 172 d->playListFrame->show();
173} 173}
174 174
175void PlayListWidget::writeDefaultPlaylist() { 175void PlayListWidget::writeDefaultPlaylist() {
176 176
177 Config config( "OpiePlayer" ); 177 Config config( "OpiePlayer" );
178 config.setGroup( "PlayList" ); 178 config.setGroup( "PlayList" );
179 QString filename=QPEApplication::documentDir() + "/default.m3u"; 179 QString filename=QPEApplication::documentDir() + "/default.m3u";
180 QString currentString = config.readEntry( "CurrentPlaylist", filename); 180 QString currentString = config.readEntry( "CurrentPlaylist", filename);
181 if( currentString == filename) { 181 if( currentString == filename) {
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
200void PlayListWidget::addToSelection( const DocLnk& lnk ) { 200void 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();
207} 207}
208 208
209 209
210void PlayListWidget::clearList() { 210void PlayListWidget::clearList() {
211 while ( first() ) { 211 while ( first() ) {
212 d->selectedFiles->removeSelected(); 212 d->selectedFiles->removeSelected();
213 } 213 }
214} 214}
215 215
216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
217 switch (mouse) { 217 switch (mouse) {
218 case 1: 218 case 1:
219 break; 219 break;
220 case 2: 220 case 2:
221 { 221 {
222 QPopupMenu m; 222 QPopupMenu m;
223 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 223 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
224 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 224 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
225 m.exec( QCursor::pos() ); 225 m.exec( QCursor::pos() );
226 } 226 }
227 break; 227 break;
228 } 228 }
229} 229}
230 230
231 231
232void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 232void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
233 switch (mouse) { 233 switch (mouse) {
234 case 1: 234 case 1:
235 break; 235 break;
236 case 2: 236 case 2:
237 { 237 {
238 QPopupMenu m; 238 QPopupMenu m;
239 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 239 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
240 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 240 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
241 m.exec( QCursor::pos() ); 241 m.exec( QCursor::pos() );
242 } 242 }
@@ -639,257 +639,255 @@ void PlayListWidget::openFile() {
639 QString filename, name; 639 QString filename, name;
640 InputDialog *fileDlg; 640 InputDialog *fileDlg;
641 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 641 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
642 fileDlg->exec(); 642 fileDlg->exec();
643 if( fileDlg->result() == 1 ) { 643 if( fileDlg->result() == 1 ) {
644 filename = fileDlg->text(); 644 filename = fileDlg->text();
645 qDebug( "Selected filename is " + filename ); 645 qDebug( "Selected filename is " + filename );
646 // Om3u *m3uList; 646 // Om3u *m3uList;
647 DocLnk lnk; 647 DocLnk lnk;
648 Config cfg( "OpiePlayer" ); 648 Config cfg( "OpiePlayer" );
649 cfg.setGroup("PlayList"); 649 cfg.setGroup("PlayList");
650 650
651 if(filename.left(4) == "http") { 651 if(filename.left(4) == "http") {
652 QString m3uFile, m3uFilePath; 652 QString m3uFile, m3uFilePath;
653 if(filename.find(":",8,TRUE) != -1) { //found a port 653 if(filename.find(":",8,TRUE) != -1) { //found a port
654 m3uFile = filename.left( filename.find( ":",8,TRUE)); 654 m3uFile = filename.left( filename.find( ":",8,TRUE));
655 m3uFile = m3uFile.right( 7); 655 m3uFile = m3uFile.right( 7);
656 } else if(filename.left(4) == "http"){ 656 } else if(filename.left(4) == "http"){
657 m3uFile=filename; 657 m3uFile=filename;
658 m3uFile = m3uFile.right( m3uFile.length() - 7); 658 m3uFile = m3uFile.right( m3uFile.length() - 7);
659 } else{ 659 } else{
660 m3uFile=filename; 660 m3uFile=filename;
661 } 661 }
662 662
663// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 663// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
664 lnk.setName( filename ); //sets name 664 lnk.setName( filename ); //sets name
665 lnk.setFile( filename ); //sets file name 665 lnk.setFile( filename ); //sets file name
666 666
667// lnk.setIcon("opieplayer2/musicfile"); 667// lnk.setIcon("opieplayer2/musicfile");
668 668
669 d->selectedFiles->addToSelection( lnk ); 669 d->selectedFiles->addToSelection( lnk );
670 writeCurrentM3u(); 670 writeCurrentM3u();
671 d->selectedFiles->setSelectedItem( lnk.name()); 671 d->selectedFiles->setSelectedItem( lnk.name());
672 } 672 }
673 else if( filename.right( 3) == "m3u" ) { 673 else if( filename.right( 3) == "m3u" ) {
674 readm3u( filename ); 674 readm3u( filename );
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/*
693reads m3u and shows files/urls to playlist widget */ 691reads m3u and shows files/urls to playlist widget */
694void PlayListWidget::readm3u( const QString &filename ) { 692void 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;
702 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 700 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
703 s = *it; 701 s = *it;
704// qDebug("reading "+ s); 702// qDebug("reading "+ s);
705 if(s.left(4)=="http") { 703 if(s.left(4)=="http") {
706 lnk.setName( s ); //sets file name 704 lnk.setName( s ); //sets file name
707 lnk.setIcon("opieplayer2/musicfile"); 705 lnk.setIcon("opieplayer2/musicfile");
708 lnk.setFile( s ); //sets file name 706 lnk.setFile( s ); //sets file name
709 707
710 } else { 708 } else {
711 // if( QFileInfo( s ).exists() ) { 709 // if( QFileInfo( s ).exists() ) {
712 lnk.setName( QFileInfo(s).baseName()); 710 lnk.setName( QFileInfo(s).baseName());
713 // if(s.right(4) == '.') {//if regular file 711 // if(s.right(4) == '.') {//if regular file
714 if(s.left(1) != "/") { 712 if(s.left(1) != "/") {
715 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 713 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
716 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 714 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
717// lnk.setIcon(MimeType(s).pixmap() ); 715// lnk.setIcon(MimeType(s).pixmap() );
718// lnk.setIcon("SoundPlayer"); 716// lnk.setIcon("SoundPlayer");
719 } else { 717 } else {
720 // qDebug("set link2 "+s); 718 // qDebug("set link2 "+s);
721 lnk.setFile( s); 719 lnk.setFile( s);
722// lnk.setIcon(MimeType(s).pixmap() ); 720// lnk.setIcon(MimeType(s).pixmap() );
723// lnk.setIcon("SoundPlayer"); 721// lnk.setIcon("SoundPlayer");
724 } 722 }
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/*
745reads pls and adds files/urls to playlist */ 743reads pls and adds files/urls to playlist */
746void PlayListWidget::readPls( const QString &filename ) { 744void 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;
750 QString s, name; 748 QString s, name;
751 m3uList = new Om3u( filename, IO_ReadOnly ); 749 m3uList = new Om3u( filename, IO_ReadOnly );
752 m3uList->readPls(); 750 m3uList->readPls();
753 751
754 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 752 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
755 s = *it; 753 s = *it;
756 // s.replace( QRegExp( "%20" )," " ); 754 // s.replace( QRegExp( "%20" )," " );
757 DocLnk lnk( s ); 755 DocLnk lnk( s );
758 QFileInfo f( s ); 756 QFileInfo f( s );
759 QString name = f.baseName(); 757 QString name = f.baseName();
760 758
761 if( name.left( 4 ) == "http" ) { 759 if( name.left( 4 ) == "http" ) {
762 name = s.right( s.length() - 7); 760 name = s.right( s.length() - 7);
763 } else { 761 } else {
764 name = s; 762 name = s;
765 } 763 }
766 764
767 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 765 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
768 766
769 lnk.setName( name ); 767 lnk.setName( name );
770 if( s.at( s.length() - 4) == '.') {// if this is probably a file 768 if( s.at( s.length() - 4) == '.') {// if this is probably a file
771 lnk.setFile( s ); 769 lnk.setFile( s );
772 } else { //if its a url 770 } else { //if its a url
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 */
790void PlayListWidget::writeCurrentM3u() { 788void 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 */
816void PlayListWidget::writem3u() { 814void 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;
822 820
823 if( fileDlg->result() == 1 ) { 821 if( fileDlg->result() == 1 ) {
824 name = fileDlg->text(); 822 name = fileDlg->text();
825// qDebug( filename ); 823// qDebug( filename );
826 824
827 if( name.left( 1) != "/" ) { 825 if( name.left( 1) != "/" ) {
828 filename = QPEApplication::documentDir() + "/" + name; 826 filename = QPEApplication::documentDir() + "/" + name;
829 } 827 }
830 828
831 if( name.right( 3 ) != "m3u" ) { 829 if( name.right( 3 ) != "m3u" ) {
832 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 830 filename = QPEApplication::documentDir() + "/" +name+".m3u";
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;
860 858
861 if(!lnk.writeLink()) { 859 if(!lnk.writeLink()) {
862 qDebug("Writing doclink did not work"); 860 qDebug("Writing doclink did not work");
863 } 861 }
864 862
865 setCaption(tr("OpiePlayer: ") + name); 863 setCaption(tr("OpiePlayer: ") + name);
866 } 864 }
867 } 865 }
868} 866}
869 867
870void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 868void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
871 switch ( e->key() ) { 869 switch ( e->key() ) {
872 ////////////////////////////// Zaurus keys 870 ////////////////////////////// Zaurus keys
873 case Key_F9: //activity 871 case Key_F9: //activity
874 // if(audioUI->isHidden()) 872 // if(audioUI->isHidden())
875 // audioUI->showMaximized(); 873 // audioUI->showMaximized();
876 break; 874 break;
877 case Key_F10: //contacts 875 case Key_F10: //contacts
878 // if( videoUI->isHidden()) 876 // if( videoUI->isHidden())
879 // videoUI->showMaximized(); 877 // videoUI->showMaximized();
880 break; 878 break;
881 case Key_F11: //menu 879 case Key_F11: //menu
882 break; 880 break;
883 case Key_F12: //home 881 case Key_F12: //home
884 // doBlank(); 882 // doBlank();
885 break; 883 break;
886 case Key_F13: //mail 884 case Key_F13: //mail
887 // doUnblank(); 885 // doUnblank();
888 break; 886 break;
889 case Key_Q: //add to playlist 887 case Key_Q: //add to playlist
890 addSelected(); 888 addSelected();
891 break; 889 break;
892 case Key_R: //remove from playlist 890 case Key_R: //remove from playlist
893 removeSelected(); 891 removeSelected();
894 break; 892 break;
895 // case Key_P: //play 893 // case Key_P: //play