summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-08 18:31:28 (UTC)
committer llornkcor <llornkcor>2002-10-08 18:31:28 (UTC)
commit7599e0a20572d44ca805e6effb878601c707fd05 (patch) (unidiff)
tree2bc2342b16338ca395528456705e38ede850d653
parent9475b63d025c1ca386764784b7dad460935f45b0 (diff)
downloadopie-7599e0a20572d44ca805e6effb878601c707fd05.zip
opie-7599e0a20572d44ca805e6effb878601c707fd05.tar.gz
opie-7599e0a20572d44ca805e6effb878601c707fd05.tar.bz2
more fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp235
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
4 files changed, 104 insertions, 161 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 8da7f73..5069a49 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -336,11 +336,11 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
336 } 336 }
337} 337}
338 338
339void MediaPlayer::cleanUp() {// this happens on closing 339void MediaPlayer::cleanUp() {// this happens on closing
340 Config cfg( "OpiePlayer" ); 340 Config cfg( "OpiePlayer" );
341 mediaPlayerState->writeConfig( cfg ); 341 mediaPlayerState->writeConfig( cfg );
342 playList->writeConfig( cfg ); 342 playList->writeDefaultPlaylist( );
343 343
344// QPEApplication::grabKeyboard(); 344// QPEApplication::grabKeyboard();
345// QPEApplication::ungrabKeyboard(); 345// QPEApplication::ungrabKeyboard();
346} 346}
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index c947033..0be727b 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -60,36 +60,36 @@ Om3u::Om3u( const QString &filePath, int mode)
60 f.open(mode); 60 f.open(mode);
61 61
62} 62}
63 63
64Om3u::~Om3u(){} 64Om3u::~Om3u(){}
65 65
66void Om3u::readM3u() { //it's m3u 66void Om3u::readM3u() {
67// qDebug("<<<<<<reading m3u "+f.name()); 67// qDebug("<<<<<<reading m3u "+f.name());
68 QTextStream t(&f); 68 QTextStream t(&f);
69 QString s; 69 QString s;
70 while ( !t.atEnd() ) { 70 while ( !t.atEnd() ) {
71 s=t.readLine(); 71 s=t.readLine();
72 // qDebug(s); 72 qDebug(s);
73 if( s.find( "#", 0, TRUE) == -1 ) { 73 if( s.find( "#", 0, TRUE) == -1 ) {
74 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 74 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
75 s = s.right( s.length() -2 ); 75 s = s.right( s.length() -2 );
76 QFileInfo f( s ); 76 QFileInfo f( s );
77 QString name = f.baseName(); 77 QString name = f.baseName();
78 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 78 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
79 s=s.replace( QRegExp( "\\" ), "/" ); 79 s=s.replace( QRegExp( "\\" ), "/" );
80 append(s); 80 append(s);
81// qDebug(s); 81// qDebug(s);
82 } else { // is url 82 } else { // is url
83 s.replace( QRegExp( "%20" )," " ); 83 s.replace( QRegExp( "%20" )," " );
84 QString name; 84 QString name;
85 if( name.left( 4 ) == "http" ) { 85// if( name.left( 4 ) == "http" ) {
86 name = s.right( s.length() - 7 ); 86// name = s.right( s.length() - 7 );
87 } else { 87// } else {
88 name = s; 88 name = s;
89 } 89// }
90 append(name); 90 append(name);
91// qDebug(name); 91// qDebug(name);
92 } 92 }
93 } 93 }
94 } 94 }
95} 95}
@@ -134,24 +134,35 @@ void Om3u::write() { //writes list to m3u file
134 QString list; 134 QString list;
135 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 135 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
136 qDebug(*it); 136 qDebug(*it);
137 list += *it+"\n"; 137 list += *it+"\n";
138 } 138 }
139 f.writeBlock( list, list.length() ); 139 f.writeBlock( list, list.length() );
140 f.close(); 140// f.close();
141} 141}
142 142
143void Om3u::add(const QString &filePath) { //adds to m3u file 143void Om3u::add(const QString &filePath) { //adds to m3u file
144 append(filePath); 144 append(filePath);
145} 145}
146 146
147void Om3u::remove(const QString &filePath) { //removes from m3u list 147void Om3u::remove(const QString &filePath) { //removes from m3u list
148 QString list, currentFile;
149 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
150 currentFile=*it;
151// qDebug(*it);
152
153 if( filePath != currentFile)
154 list += currentFile+"\n";
155 }
156 f.writeBlock( list, list.length() );
148 157
149} 158}
150 159
151void Om3u::deleteFile(const QString &filePath) {//deletes m3u file 160void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
161 f.close();
162 f.remove();
152 163
153} 164}
154 165
155void Om3u::close() { //closes m3u file 166void Om3u::close() { //closes m3u file
156 f.close(); 167 f.close();
157} 168}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 897c458..cc4be23 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -173,107 +173,33 @@ void PlayListWidget::initializeStates() {
173 d->tbPlay->setOn( mediaPlayerState->playing() ); 173 d->tbPlay->setOn( mediaPlayerState->playing() );
174 d->tbLoop->setOn( mediaPlayerState->looping() ); 174 d->tbLoop->setOn( mediaPlayerState->looping() );
175 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 175 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
176 setPlaylist( true ); 176 setPlaylist( true );
177} 177}
178 178
179void PlayListWidget::writeDefaultPlaylist() {
179 180
180void PlayListWidget::readConfig( Config& cfg ) { 181 Config config( "OpiePlayer" );
181 182 config.setGroup( "PlayList" );
182 cfg.setGroup( "PlayList" ); 183 QString filename=QPEApplication::documentDir() + "/default.m3u";
183 QString currentString = cfg.readEntry( "current", "" ); 184 QString currentString = config.readEntry( "CurrentPlaylist", filename);
184 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); 185 if( currentString == filename) {
185
186 for ( int i = 0; i < noOfFiles; i++ ) {
187 QString entryName;
188 entryName.sprintf( "File%i", i + 1 );
189
190 QString linkFile = cfg.readEntry( entryName );
191
192 qDebug("reading "+linkFile);
193
194 if( QFileInfo( linkFile ).exists() ) {
195
196 DocLnk lnk( linkFile );
197
198 if ( QFileInfo( lnk.file() ).exists() ||
199
200 linkFile.find( "http" , 0, TRUE) != -1) {
201
202 d->selectedFiles->addToSelection( lnk );
203 }
204 }
205 }
206 d->selectedFiles->setSelectedItem( currentString );
207}
208
209
210void PlayListWidget::writeConfig( Config& cfg ) const {
211
212 Config config( "OpiePlayer" );
213 config.setGroup( "PlayList" );
214
215// if(config.readBoolEntry("newPlaylist")) {
216// new for testing
217 QString name, filename, list;
218 Om3u *m3uList; 186 Om3u *m3uList;
219 name = "default"; 187// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
220 188 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
221 filename=QPEApplication::documentDir() + "/" + name+".m3u";
222 m3uList = new Om3u(filename, IO_ReadWrite);
223 d->selectedFiles->first(); 189 d->selectedFiles->first();
224 do { 190 do {
225 qDebug(d->selectedFiles->current()->file()); 191// qDebug(d->selectedFiles->current()->file());
226 m3uList->add( d->selectedFiles->current()->file() ); 192 m3uList->add( d->selectedFiles->current()->file() );
227 } 193 }
228 while ( d->selectedFiles->next() ); 194 while ( d->selectedFiles->next() );
229 // qDebug( list );
230 195
231 // m3uList->write(); 196 m3uList->write();
232 m3uList->close(); 197 m3uList->close();
233 if(m3uList) delete m3uList; 198 if(m3uList) delete m3uList;
234 199 }
235 DocLnk lnk;
236 lnk.setFile( filename);
237 lnk.setIcon("opieplayer2/playlist2");
238 lnk.setName( name); //sets file name
239
240 qDebug("writing default playlist "+filename);
241
242 config.writeEntry("CurrentPlaylist", filename);
243// currentPlayList=filename;
244 if(!lnk.writeLink()) {
245 qDebug("Writing doclink did not work");
246 }
247// } else {
248
249// d->selectedFiles->writeCurrent( cfg );
250// int noOfFiles = 0;
251// d->selectedFiles->first();
252
253// do {
254// const DocLnk *lnk = d->selectedFiles->current();
255
256// if ( lnk ) {
257
258// QString entryName;
259// entryName.sprintf( "File%i", noOfFiles + 1 );
260
261// cfg.writeEntry( entryName, lnk->linkFile() );
262// // if this link does exist, add it so we have the file
263// // next time...
264
265// if ( !QFile::exists( lnk->linkFile() ) ) {
266// lnk->writeLink();
267// }
268// }
269// noOfFiles++;
270// }
271// while ( d->selectedFiles->next() );
272// cfg.writeEntry("NumberOfFiles", noOfFiles );
273// }
274} 200}
275 201
276void PlayListWidget::addToSelection( const DocLnk& lnk ) { 202void PlayListWidget::addToSelection( const DocLnk& lnk ) {
277 d->setDocumentUsed = FALSE; 203 d->setDocumentUsed = FALSE;
278 if ( mediaPlayerState->playlist() ) { 204 if ( mediaPlayerState->playlist() ) {
279 if( QFileInfo( lnk.file() ).exists() || 205 if( QFileInfo( lnk.file() ).exists() ||
@@ -357,30 +283,30 @@ void PlayListWidget::addAllVideoToList() {
357 } 283 }
358 writeCurrentM3u(); 284 writeCurrentM3u();
359} 285}
360 286
361 287
362void PlayListWidget::setDocument( const QString& fileref ) { 288void PlayListWidget::setDocument( const QString& fileref ) {
363 //qDebug( fileref ); 289 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
364 fromSetDocument = TRUE; 290 fromSetDocument = TRUE;
365 if ( fileref.isNull() ) { 291 if ( fileref.isNull() ) {
366 QMessageBox::critical( 0, tr( "Invalid File" ), 292 QMessageBox::critical( 0, tr( "Invalid File" ),
367 tr( "There was a problem in getting the file." ) ); 293 tr( "There was a problem in getting the file." ) );
368 return; 294 return;
369 } 295 }
370 296
371 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 297 clearList();
298 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
372 readm3u( fileref ); 299 readm3u( fileref );
300 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
301 readm3u( DocLnk( fileref).file() );
373 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 302 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
374 readPls( fileref ); 303 readPls( fileref );
375 }// else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist 304 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
376// clearList(); 305 readPls( DocLnk( fileref).file() );
377// loadList( DocLnk( fileref ) ); 306 } else {
378// d->selectedFiles->first();
379// }
380 else {
381 clearList(); 307 clearList();
382 addToSelection( DocLnk( fileref ) ); 308 addToSelection( DocLnk( fileref ) );
383 d->setDocumentUsed = TRUE; 309 d->setDocumentUsed = TRUE;
384 mediaPlayerState->setPlaying( FALSE ); 310 mediaPlayerState->setPlaying( FALSE );
385 mediaPlayerState->setPlaying( TRUE ); 311 mediaPlayerState->setPlaying( TRUE );
386 } 312 }
@@ -504,13 +430,13 @@ void PlayListWidget::setPlaylist( bool shown ) {
504 d->playListFrame->hide(); 430 d->playListFrame->hide();
505 } 431 }
506} 432}
507 433
508 434
509void PlayListWidget::addSelected() { 435void PlayListWidget::addSelected() {
510 436 qDebug("addSelected");
511 switch (whichList()) { 437 switch (whichList()) {
512 case 0: //playlist 438 case 0: //playlist
513 break; 439 break;
514 case 1: { //audio 440 case 1: { //audio
515 QListViewItemIterator it( audioView ); 441 QListViewItemIterator it( audioView );
516 // iterate through all items of the listview 442 // iterate through all items of the listview
@@ -554,12 +480,13 @@ void PlayListWidget::addSelected() {
554 }; 480 };
555} 481}
556 482
557 483
558void PlayListWidget::removeSelected() { 484void PlayListWidget::removeSelected() {
559 d->selectedFiles->removeSelected( ); 485 d->selectedFiles->removeSelected( );
486 writeCurrentM3u();
560} 487}
561 488
562 489
563void PlayListWidget::playIt( QListViewItem *it) { 490void PlayListWidget::playIt( QListViewItem *it) {
564 if(!it) return; 491 if(!it) return;
565 mediaPlayerState->setPlaying(FALSE); 492 mediaPlayerState->setPlaying(FALSE);
@@ -567,42 +494,40 @@ void PlayListWidget::playIt( QListViewItem *it) {
567 d->selectedFiles->unSelect(); 494 d->selectedFiles->unSelect();
568} 495}
569 496
570 497
571void PlayListWidget::addToSelection( QListViewItem *it) { 498void PlayListWidget::addToSelection( QListViewItem *it) {
572 d->setDocumentUsed = FALSE; 499 d->setDocumentUsed = FALSE;
573 500 qDebug("addToSelection2");
574 if(it) { 501 if(it) {
575 switch ( whichList()) { 502 switch ( whichList()) {
576 case 1: { 503 case 1: {
577 QListIterator<DocLnk> dit( files.children() ); 504 QListIterator<DocLnk> dit( files.children() );
578 for ( ; dit.current(); ++dit ) { 505 for ( ; dit.current(); ++dit ) {
579 if( dit.current()->name() == it->text(0)) { 506 if( dit.current()->name() == it->text(0)) {
580 if(QFileInfo( dit.current()->file()).exists()) 507 if(QFileInfo( dit.current()->file()).exists())
581 d->selectedFiles->addToSelection( **dit ); 508 d->selectedFiles->addToSelection( **dit );
582 } 509 }
583 } 510 }
584 writeCurrentM3u(); 511 writeCurrentM3u();
585 512 }
586 } 513 break;
587 514 case 2: {
588 break; 515 QListIterator<DocLnk> dit( vFiles.children() );
589 case 2: { 516 for ( ; dit.current(); ++dit ) {
590 QListIterator<DocLnk> dit( vFiles.children() ); 517 if( dit.current()->name() == it->text(0)) {
591 for ( ; dit.current(); ++dit ) { 518 if( QFileInfo( dit.current()->file()).exists() )
592 if( dit.current()->name() == it->text(0)) { 519 d->selectedFiles->addToSelection( **dit );
593 if( QFileInfo( dit.current()->file()).exists() ) 520 }
594 d->selectedFiles->addToSelection( **dit ); 521 }
595 } 522 writeCurrentM3u();
596 }
597 writeCurrentM3u();
598 523
599 } 524 }
600 break; 525 break;
601 case 0: 526 case 0:
602 break; 527 break;
603 }; 528 };
604 tabWidget->setCurrentPage(0); 529 tabWidget->setCurrentPage(0);
605 } 530 }
606} 531}
607 532
608 533
@@ -777,102 +702,106 @@ void PlayListWidget::openFile() {
777 QString filename, name; 702 QString filename, name;
778 InputDialog *fileDlg; 703 InputDialog *fileDlg;
779 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 704 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
780 fileDlg->exec(); 705 fileDlg->exec();
781 if( fileDlg->result() == 1 ) { 706 if( fileDlg->result() == 1 ) {
782 filename = fileDlg->text(); 707 filename = fileDlg->text();
783
784 qDebug( "Selected filename is " + filename ); 708 qDebug( "Selected filename is " + filename );
785
786 if(filename.left(4) == "http") { //if http, lets write a new m3u
787 Om3u *m3uList; 709 Om3u *m3uList;
788 DocLnk lnk; 710 DocLnk lnk;
789 QString m3uFile, m3uFilePath; 711 Config cfg( "OpiePlayer" );
712 cfg.setGroup("PlayList");
790 713
714 if(filename.left(4) == "http") {
715 QString m3uFile, m3uFilePath;
791 if(filename.find(":",8,TRUE) != -1) { //found a port 716 if(filename.find(":",8,TRUE) != -1) { //found a port
792 m3uFile = filename.left( filename.find( ":",8,TRUE)); 717 m3uFile = filename.left( filename.find( ":",8,TRUE));
793 m3uFile = m3uFile.right( 7); 718 m3uFile = m3uFile.right( 7);
794 } else if(filename.left(4) == "http"){ 719 } else if(filename.left(4) == "http"){
795 m3uFile=filename; 720 m3uFile=filename;
796 m3uFile = m3uFile.right( m3uFile.length() - 7); 721 m3uFile = m3uFile.right( m3uFile.length() - 7);
797 } else{ 722 } else{
798 m3uFile=filename; 723 m3uFile=filename;
799 } 724 }
800// qDebug( m3uFile);
801 725
802//this is where this new m3u is going to live at 726 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
803 m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u"; 727 m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite );
804// m3uFile += ".m3u";
805 m3uList = new Om3u( m3uFile+".m3u", IO_ReadWrite );
806 m3uList->add( filename); 728 m3uList->add( filename);
807 m3uList->write(); 729 m3uList->write();
730 m3uList->close();
808 if(m3uList) delete m3uList; 731 if(m3uList) delete m3uList;
809// qDebug( m3uFile); 732 lnk.setName( filename ); //sets name
810 lnk.setName( filename ); //sets file name 733 lnk.setFile( filename ); //sets file name
811 lnk.setFile( m3uFilePath ); //sets File property 734 lnk.setIcon("opieplayer2/musicfile");
812 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
813
814 lnk.setExec( "opieplayer2" );
815 lnk.setIcon("opieplayer2/playlist2");
816
817 if( !lnk.writeLink() ) {
818 qDebug( "Writing doclink did not work" );
819 }
820 d->selectedFiles->addToSelection( lnk ); 735 d->selectedFiles->addToSelection( lnk );
821
822 } 736 }
823 else if( filename.right( 3 ) == "m3u" ) { 737 else if( filename.right( 3) == "m3u" ) {
824 readm3u( filename ); 738 readm3u( filename );
825 739
826 } else if( filename.right(3) == "pls" ) { 740 } else if( filename.right(3) == "pls" ) {
827 readPls( filename ); 741 readPls( filename );
828 } 742 }
743 else {
744 m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite );
745 m3uList->add( filename);
746 m3uList->write();
747 m3uList->close();
748 if(m3uList) delete m3uList;
749 d->selectedFiles->addToSelection( DocLnk(filename) );
750 }
829 } 751 }
752
830 if( fileDlg ) { 753 if( fileDlg ) {
831 delete fileDlg; 754 delete fileDlg;
832 } 755 }
833} 756}
834 757
835/* 758/*
836reads m3u and adds files/urls to playlist */ 759reads m3u and shows files/urls to playlist widget */
837void PlayListWidget::readm3u( const QString &filename ) { 760void PlayListWidget::readm3u( const QString &filename ) {
838 qDebug( "read m3u filename " + filename ); 761 qDebug( "read m3u filename " + filename );
839 762
840 Om3u *m3uList; 763 Om3u *m3uList;
841 QString s, name; 764 QString s, name;
842 m3uList = new Om3u( filename, IO_ReadOnly ); 765 m3uList = new Om3u( filename, IO_ReadOnly );
843 m3uList->readM3u(); 766 m3uList->readM3u();
844 DocLnk lnk; 767 DocLnk lnk;
845 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 768 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
846 s = *it; 769 s = *it;
847 s.replace( QRegExp( "%20" )," " ); 770// s.replace( QRegExp( "%20" )," " );
848// qDebug("reading "+ s); 771// qDebug("reading "+ s);
849 772 if(s.left(4)=="http") {
850 if( QFileInfo( s ).exists() ) { 773 lnk.setName( s ); //sets file name
774 lnk.setFile( s ); //sets file name
775 lnk.setIcon("opieplayer2/musicfile");
776 }
777 else {
778 if( QFileInfo( s ).exists() ) {
851 lnk.setName( QFileInfo(s).baseName()); 779 lnk.setName( QFileInfo(s).baseName());
852// qDebug("set link "+s); 780// qDebug("set link "+s);
853 if(s.at(s.length()-4) == '.') //if regular file 781 if(s.at(s.length()-4) == '.') //if regular file
854 lnk.setFile( s); 782 lnk.setFile( s);
855 else 783 else
856 lnk.setFile( s+"/"); //if url with no extension 784 lnk.setFile( s+"/"); //if url with no extension
857 785 }
858 d->selectedFiles->addToSelection( lnk );
859 } 786 }
787 d->selectedFiles->addToSelection( lnk );
860 } 788 }
861 Config config( "OpiePlayer" ); 789 Config config( "OpiePlayer" );
862 config.setGroup( "PlayList" ); 790 config.setGroup( "PlayList" );
863 791
864 config.writeEntry("CurrentPlaylist",filename); 792 config.writeEntry("CurrentPlaylist",filename);
865 config.write(); 793 config.write();
866 currentPlayList=filename; 794 currentPlayList=filename;
867 795
796// m3uList->write();
868 m3uList->close(); 797 m3uList->close();
869 if(m3uList) delete m3uList; 798 if(m3uList) delete m3uList;
870 799
871 d->selectedFiles->setSelectedItem( s); 800 d->selectedFiles->setSelectedItem( s);
872 setCaption(tr("OpiePlayer: ")+ filename); 801 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
873 802
874} 803}
875 804
876/* 805/*
877reads pls and adds files/urls to playlist */ 806reads pls and adds files/urls to playlist */
878void PlayListWidget::readPls( const QString &filename ) { 807void PlayListWidget::readPls( const QString &filename ) {
@@ -923,21 +852,23 @@ void PlayListWidget::writeCurrentM3u() {
923 qDebug("writting to current m3u"); 852 qDebug("writting to current m3u");
924 Config cfg( "OpiePlayer" ); 853 Config cfg( "OpiePlayer" );
925 cfg.setGroup("PlayList"); 854 cfg.setGroup("PlayList");
926 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 855 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
927 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 856 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
928 Om3u *m3uList; 857 Om3u *m3uList;
929 m3uList = new Om3u( currentPlaylist, IO_ReadWrite ); 858 m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate );
930 d->selectedFiles->first(); 859 d->selectedFiles->first();
931 860
932 do { 861 do {
933 m3uList->add( d->selectedFiles->current()->file()); 862 m3uList->add( d->selectedFiles->current()->file());
934 } 863 }
935 while ( d->selectedFiles->next() ); 864 while ( d->selectedFiles->next() );
936 // qDebug( list ); 865 // qDebug( list );
937 m3uList->write(); 866 m3uList->write();
867 m3uList->close();
868
938 if(m3uList) delete m3uList; 869 if(m3uList) delete m3uList;
939} 870}
940 871
941 /* 872 /*
942 writes current playlist to m3u file */ 873 writes current playlist to m3u file */
943void PlayListWidget::writem3u() { 874void PlayListWidget::writem3u() {
@@ -966,12 +897,14 @@ void PlayListWidget::writem3u() {
966 do { 897 do {
967 m3uList->add( d->selectedFiles->current()->file()); 898 m3uList->add( d->selectedFiles->current()->file());
968 } 899 }
969 while ( d->selectedFiles->next() ); 900 while ( d->selectedFiles->next() );
970// qDebug( list ); 901// qDebug( list );
971 m3uList->write(); 902 m3uList->write();
903 m3uList->close();
904
972 } 905 }
973 if(m3uList) delete m3uList; 906 if(m3uList) delete m3uList;
974 if(fileDlg) delete fileDlg; 907 if(fileDlg) delete fileDlg;
975 908
976 DocLnk lnk; 909 DocLnk lnk;
977 lnk.setFile( filename); 910 lnk.setFile( filename);
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 8a77619..53be7a7 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -70,24 +70,23 @@ public:
70 70
71public slots: 71public slots:
72 bool first(); 72 bool first();
73 bool last(); 73 bool last();
74 bool next(); 74 bool next();
75 bool prev(); 75 bool prev();
76 void writeConfig( Config& cfg ) const; 76 void writeDefaultPlaylist( );
77 QString currentFileListPathName(); 77 QString currentFileListPathName();
78protected: 78protected:
79 void keyReleaseEvent( QKeyEvent *e); 79 void keyReleaseEvent( QKeyEvent *e);
80 80
81private: 81private:
82 int defaultSkinIndex; 82 int defaultSkinIndex;
83 bool audioScan, videoScan; 83 bool audioScan, videoScan;
84 void readm3u(const QString &); 84 void readm3u(const QString &);
85 void readPls(const QString &); 85 void readPls(const QString &);
86 void initializeStates(); 86 void initializeStates();
87 void readConfig( Config& cfg );
88 void populateAudioView(); 87 void populateAudioView();
89 void populateVideoView(); 88 void populateVideoView();
90 89
91private slots: 90private slots:
92 void populateSkinsMenu(); 91 void populateSkinsMenu();
93 void skinsMenuActivated(int); 92 void skinsMenuActivated(int);