summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/om3u.h2
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp180
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h1
4 files changed, 76 insertions, 123 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index d378145..c947033 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -45,34 +45,35 @@
45#include <qtextstream.h> 45#include <qtextstream.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qcstring.h> 47#include <qcstring.h>
48 48
49//extern PlayListWidget *playList; 49//extern PlayListWidget *playList;
50 50
51Om3u::Om3u( const QString &filePath) 51Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 52 : QStringList (){
53//filePath is path name to m3u 53//filePath is path name to m3u
54//qDebug("<<<<<<<new m3u "+filePath); 54//qDebug("<<<<<<<new m3u "+filePath);
55 f.setName(filePath); 55 f.setName(filePath);
56 if(f.exists()) 56// if(f.exists())
57 f.open( IO_ReadWrite ); 57// f.open( IO_ReadWrite);
58 else 58// else
59 f.open( IO_ReadWrite | IO_Truncate); 59// f.open( IO_ReadWrite | IO_Truncate);
60 f.open(mode);
61
60} 62}
61 63
62Om3u::~Om3u(){} 64Om3u::~Om3u(){}
63 65
64void Om3u::readM3u() { //it's m3u 66void Om3u::readM3u() { //it's m3u
65// qDebug("<<<<<<reading m3u "+f.name()); 67// qDebug("<<<<<<reading m3u "+f.name());
66 QTextStream t(&f); 68 QTextStream t(&f);
67 QString s; 69 QString s;
68 while ( !t.atEnd() ) { 70 while ( !t.atEnd() ) {
69 s=t.readLine(); 71 s=t.readLine();
70 72 // qDebug(s);
71 if( s.find( "#", 0, TRUE) == -1 ) { 73 if( s.find( "#", 0, TRUE) == -1 ) {
72 if( s.find( " ", 0, TRUE) == -1 ) {
73 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 74 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
74 s = s.right( s.length() -2 ); 75 s = s.right( s.length() -2 );
75 QFileInfo f( s ); 76 QFileInfo f( s );
76 QString name = f.baseName(); 77 QString name = f.baseName();
77 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 78 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
78 s=s.replace( QRegExp( "\\" ), "/" ); 79 s=s.replace( QRegExp( "\\" ), "/" );
@@ -86,13 +87,12 @@ void Om3u::readM3u() { //it's m3u
86 } else { 87 } else {
87 name = s; 88 name = s;
88 } 89 }
89 append(name); 90 append(name);
90// qDebug(name); 91// qDebug(name);
91 } 92 }
92 }
93 } 93 }
94 } 94 }
95} 95}
96 96
97void Om3u::readPls() { //it's a pls file 97void Om3u::readPls() { //it's a pls file
98 QTextStream t( &f ); 98 QTextStream t( &f );
diff --git a/noncore/multimedia/opieplayer2/om3u.h b/noncore/multimedia/opieplayer2/om3u.h
index 392980e..9c7cf9a 100644
--- a/noncore/multimedia/opieplayer2/om3u.h
+++ b/noncore/multimedia/opieplayer2/om3u.h
@@ -50,13 +50,13 @@
50#include <qfile.h> 50#include <qfile.h>
51 51
52 52
53class Om3u : public QStringList { 53class Om3u : public QStringList {
54// Q_OBJECT 54// Q_OBJECT
55public: 55public:
56 Om3u( const QString &filePath); 56 Om3u( const QString &filePath, int mode);
57 ~Om3u(); 57 ~Om3u();
58 void readM3u(); 58 void readM3u();
59 void readPls(); 59 void readPls();
60 void write(); 60 void write();
61 void add(const QString &); 61 void add(const QString &);
62 void remove(const QString &); 62 void remove(const QString &);
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 26c2896..b6525e1 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -145,32 +145,25 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
145 this, SLOT( setPlaylist( bool ) ) ); 145 this, SLOT( setPlaylist( bool ) ) );
146 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 146 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
147 this, SLOT( playIt( QListViewItem *) ) ); 147 this, SLOT( playIt( QListViewItem *) ) );
148 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 148 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
149 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 149 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
150 150
151// cfg.setGroup( "PlayList" );
152// if( cfg.readBoolEntry("newPlaylist") ){
153 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
154 loadList(DocLnk( currentPlaylist ) );
155 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
156// } else {
157// readConfig( cfg );
158
159// }
160 // see which skins are installed 151 // see which skins are installed
161 videoScan=FALSE; 152 videoScan=FALSE;
162 audioScan=FALSE; 153 audioScan=FALSE;
163 populateSkinsMenu(); 154 populateSkinsMenu();
164 initializeStates(); 155 initializeStates();
156
157 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
158 loadList(DocLnk( currentPlaylist ) );
159 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
165} 160}
166 161
167 162
168PlayListWidget::~PlayListWidget() { 163PlayListWidget::~PlayListWidget() {
169 // WTF?!@?!
170
171 if ( d->current ) { 164 if ( d->current ) {
172 delete d->current; 165 delete d->current;
173 } 166 }
174 delete d; 167 delete d;
175} 168}
176 169
@@ -203,18 +196,16 @@ void PlayListWidget::readConfig( Config& cfg ) {
203 196
204 if ( QFileInfo( lnk.file() ).exists() || 197 if ( QFileInfo( lnk.file() ).exists() ||
205 198
206 linkFile.find( "http" , 0, TRUE) != -1) { 199 linkFile.find( "http" , 0, TRUE) != -1) {
207 200
208 d->selectedFiles->addToSelection( lnk ); 201 d->selectedFiles->addToSelection( lnk );
209
210 } 202 }
211 } 203 }
212 } 204 }
213 d->selectedFiles->setSelectedItem( currentString ); 205 d->selectedFiles->setSelectedItem( currentString );
214
215} 206}
216 207
217 208
218void PlayListWidget::writeConfig( Config& cfg ) const { 209void PlayListWidget::writeConfig( Config& cfg ) const {
219 210
220 Config config( "OpiePlayer" ); 211 Config config( "OpiePlayer" );
@@ -224,41 +215,37 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
224// new for testing 215// new for testing
225 QString name, filename, list; 216 QString name, filename, list;
226 Om3u *m3uList; 217 Om3u *m3uList;
227 name = "default"; 218 name = "default";
228 219
229 filename=QPEApplication::documentDir() + "/" + name+".m3u"; 220 filename=QPEApplication::documentDir() + "/" + name+".m3u";
230 221 m3uList = new Om3u(filename, IO_ReadWrite);
231 m3uList = new Om3u(filename);
232
233 d->selectedFiles->first(); 222 d->selectedFiles->first();
234 do { 223 do {
235 m3uList->add( d->selectedFiles->current()->file()); 224 qDebug(d->selectedFiles->current()->file());
225 m3uList->add( d->selectedFiles->current()->file() );
236 } 226 }
237 while ( d->selectedFiles->next() ); 227 while ( d->selectedFiles->next() );
228 // qDebug( list );
238 229
239 qDebug( list ); 230 // m3uList->write();
240
241 m3uList->write();
242 m3uList->close(); 231 m3uList->close();
243 if(m3uList) delete m3uList; 232 if(m3uList) delete m3uList;
244 233
245 DocLnk lnk; 234 DocLnk lnk;
246 lnk.setFile( filename); 235 lnk.setFile( filename);
247 lnk.setIcon("opieplayer2/playlist2"); 236 lnk.setIcon("opieplayer2/playlist2");
248 lnk.setName( name); //sets file name 237 lnk.setName( name); //sets file name
249 238
250 qDebug("writing default playlist "+filename); 239 qDebug("writing default playlist "+filename);
251 240
252 config.writeEntry("CurrentPlaylist", filename); 241 config.writeEntry("CurrentPlaylist", filename);
253// currentPlayList=filename; 242// currentPlayList=filename;
254
255 if(!lnk.writeLink()) { 243 if(!lnk.writeLink()) {
256 qDebug("Writing doclink did not work"); 244 qDebug("Writing doclink did not work");
257 } 245 }
258
259// } else { 246// } else {
260 247
261// d->selectedFiles->writeCurrent( cfg ); 248// d->selectedFiles->writeCurrent( cfg );
262// int noOfFiles = 0; 249// int noOfFiles = 0;
263// d->selectedFiles->first(); 250// d->selectedFiles->first();
264 251
@@ -282,32 +269,31 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
282// } 269// }
283// while ( d->selectedFiles->next() ); 270// while ( d->selectedFiles->next() );
284// cfg.writeEntry("NumberOfFiles", noOfFiles ); 271// cfg.writeEntry("NumberOfFiles", noOfFiles );
285// } 272// }
286} 273}
287 274
288
289void PlayListWidget::addToSelection( const DocLnk& lnk ) { 275void PlayListWidget::addToSelection( const DocLnk& lnk ) {
290 d->setDocumentUsed = FALSE; 276 d->setDocumentUsed = FALSE;
291 if ( mediaPlayerState->playlist() ) { 277 if ( mediaPlayerState->playlist() ) {
292 if( QFileInfo( lnk.file() ).exists() || 278 if( QFileInfo( lnk.file() ).exists() ||
293 lnk.file().left(4) == "http" ) 279 lnk.file().left(4) == "http" )
294 d->selectedFiles->addToSelection( lnk ); 280 d->selectedFiles->addToSelection( lnk );
281 writeCurrentM3u();
295 } 282 }
296 else 283 else
297 mediaPlayerState->setPlaying( TRUE ); 284 mediaPlayerState->setPlaying( TRUE );
298} 285}
299 286
300 287
301void PlayListWidget::clearList() { 288void PlayListWidget::clearList() {
302 while ( first() ) { 289 while ( first() ) {
303 d->selectedFiles->removeSelected(); 290 d->selectedFiles->removeSelected();
304 } 291 }
305} 292}
306 293
307
308void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 294void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
309 switch (mouse) { 295 switch (mouse) {
310 case 1: 296 case 1:
311 break; 297 break;
312 case 2: 298 case 2:
313 { 299 {
@@ -343,32 +329,35 @@ void PlayListWidget::addAllToList() {
343 QListIterator<DocLnk> Adit( filesAll.children() ); 329 QListIterator<DocLnk> Adit( filesAll.children() );
344 for ( ; Adit.current(); ++Adit ) { 330 for ( ; Adit.current(); ++Adit ) {
345 if( QFileInfo( Adit.current()->file() ).exists() ) { 331 if( QFileInfo( Adit.current()->file() ).exists() ) {
346 d->selectedFiles->addToSelection( **Adit ); 332 d->selectedFiles->addToSelection( **Adit );
347 } 333 }
348 } 334 }
335 writeCurrentM3u();
349} 336}
350 337
351 338
352void PlayListWidget::addAllMusicToList() { 339void PlayListWidget::addAllMusicToList() {
353 QListIterator<DocLnk> dit( files.children() ); 340 QListIterator<DocLnk> dit( files.children() );
354 for ( ; dit.current(); ++dit ) { 341 for ( ; dit.current(); ++dit ) {
355 if( QFileInfo(dit.current()->file() ).exists() ) { 342 if( QFileInfo(dit.current()->file() ).exists() ) {
356 d->selectedFiles->addToSelection( **dit ); 343 d->selectedFiles->addToSelection( **dit );
357 } 344 }
358 } 345 }
346 writeCurrentM3u();
359} 347}
360 348
361 349
362void PlayListWidget::addAllVideoToList() { 350void PlayListWidget::addAllVideoToList() {
363 QListIterator<DocLnk> dit( vFiles.children() ); 351 QListIterator<DocLnk> dit( vFiles.children() );
364 for ( ; dit.current(); ++dit ) { 352 for ( ; dit.current(); ++dit ) {
365 if( QFileInfo( dit.current()->file() ).exists() ) { 353 if( QFileInfo( dit.current()->file() ).exists() ) {
366 d->selectedFiles->addToSelection( **dit ); 354 d->selectedFiles->addToSelection( **dit );
367 } 355 }
368 } 356 }
357 writeCurrentM3u();
369} 358}
370 359
371 360
372void PlayListWidget::setDocument( const QString& fileref ) { 361void PlayListWidget::setDocument( const QString& fileref ) {
373 //qDebug( fileref ); 362 //qDebug( fileref );
374 fromSetDocument = TRUE; 363 fromSetDocument = TRUE;
@@ -379,25 +368,23 @@ void PlayListWidget::setDocument( const QString& fileref ) {
379 } 368 }
380 369
381 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 370 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
382 readm3u( fileref ); 371 readm3u( fileref );
383 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 372 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
384 readPls( fileref ); 373 readPls( fileref );
385 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist 374 }// else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
386 clearList(); 375// clearList();
387 loadList( DocLnk( fileref ) ); 376// loadList( DocLnk( fileref ) );
388 d->selectedFiles->first(); 377// d->selectedFiles->first();
389 } else { 378// }
379 else {
390 clearList(); 380 clearList();
391 addToSelection( DocLnk( fileref ) ); 381 addToSelection( DocLnk( fileref ) );
392 d->setDocumentUsed = TRUE; 382 d->setDocumentUsed = TRUE;
393 mediaPlayerState->setPlaying( FALSE ); 383 mediaPlayerState->setPlaying( FALSE );
394// qApp->processEvents();
395 mediaPlayerState->setPlaying( TRUE ); 384 mediaPlayerState->setPlaying( TRUE );
396// qApp->processEvents();
397 setCaption( tr("OpiePlayer") );
398 } 385 }
399} 386}
400 387
401 388
402void PlayListWidget::useSelectedDocument() { 389void PlayListWidget::useSelectedDocument() {
403 d->setDocumentUsed = FALSE; 390 d->setDocumentUsed = FALSE;
@@ -488,78 +475,26 @@ bool PlayListWidget::last() {
488 else 475 else
489 return mediaPlayerState->looping(); 476 return mediaPlayerState->looping();
490} 477}
491 478
492 479
493 void PlayListWidget::saveList() { 480 void PlayListWidget::saveList() {
494// Config config( "OpiePlayer" ); 481 writem3u();
495// config.setGroup( "PlayList" );
496
497// if(config.readBoolEntry("newPlaylist") ){
498 writem3u();
499
500// } else {
501
502// QString filename;
503// InputDialog *fileDlg = 0l;
504// fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
505// fileDlg->exec();
506// if( fileDlg->result() == 1 ) {
507// if ( d->current )
508// delete d->current;
509// filename = fileDlg->text();//+".playlist";
510// // qDebug("saving playlist "+filename+".playlist");
511
512// Config cfg( filename +".playlist");
513// writeConfig( cfg );
514
515// DocLnk lnk;
516// lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf");
517// //sets File property
518// lnk.setType("playlist/plain");
519// lnk.setIcon("opieplayer2/playlist2");
520// lnk.setName( filename); //sets file name
521// // qDebug(filename);
522// if(!lnk.writeLink()) {
523// qDebug("Writing doclink did not work");
524// }
525// }
526
527// config.writeEntry("CurrentPlaylist",filename);
528// setCaption(tr("OpiePlayer: ")+filename);
529// d->selectedFiles->first();
530// if(fileDlg) {
531// delete fileDlg;
532// }
533// }
534 } 482 }
535 483
536 484
537void PlayListWidget::loadList( const DocLnk & lnk) { 485void PlayListWidget::loadList( const DocLnk & lnk) {
538 QString name = lnk.name(); 486 QString name = lnk.name();
539 qDebug("currentList is "+name); 487 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
540 488
541 if( name.length()>0) { 489 if( name.length()>0) {
542 setCaption("OpiePlayer: "+name); 490 setCaption("OpiePlayer: "+name);
543 qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 491 qDebug("<<<<<<<<<<<<load list "+ lnk.file());
544 clearList(); 492 clearList();
545
546// if(name.right(3) == "m3u") {
547
548 readm3u(lnk.file()); 493 readm3u(lnk.file());
549// } else {
550// / Config cfg( name+".playlist");
551// readConfig(cfg);
552
553 tabWidget->setCurrentPage(0); 494 tabWidget->setCurrentPage(0);
554
555 Config config( "OpiePlayer" );
556 config.setGroup( "PlayList" );
557 config.writeEntry("CurrentPlaylist", lnk.file());
558// // d->selectedFiles->first();
559// }
560 } 495 }
561} 496}
562 497
563 498
564void PlayListWidget::setPlaylist( bool shown ) { 499void PlayListWidget::setPlaylist( bool shown ) {
565 if ( shown ) { 500 if ( shown ) {
@@ -569,54 +504,53 @@ void PlayListWidget::setPlaylist( bool shown ) {
569 } 504 }
570} 505}
571 506
572 507
573void PlayListWidget::addSelected() { 508void PlayListWidget::addSelected() {
574 509
575 Config cfg( "OpiePlayer" );
576 cfg.setGroup("PlayList");
577 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
578 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
579
580 switch (whichList()) { 510 switch (whichList()) {
581 case 0: //playlist 511 case 0: //playlist
582 break; 512 break;
583 case 1: { //audio 513 case 1: { //audio
584 QListViewItemIterator it( audioView ); 514 QListViewItemIterator it( audioView );
585 // iterate through all items of the listview 515 // iterate through all items of the listview
586 for ( ; it.current(); ++it ) { 516 for ( ; it.current(); ++it ) {
587 if ( it.current()->isSelected() ) { 517 if ( it.current()->isSelected() ) {
588 QListIterator<DocLnk> dit( files.children() ); 518 QListIterator<DocLnk> dit( files.children() );
589 for ( ; dit.current(); ++dit ) { 519 for ( ; dit.current(); ++dit ) {
590 if( dit.current()->name() == it.current()->text(0) ) { 520 if( dit.current()->name() == it.current()->text(0) ) {
591 if(QFileInfo( dit.current()->file()).exists()) 521 if( QFileInfo( dit.current()->file()).exists()) {
592 d->selectedFiles->addToSelection( **dit ); 522 d->selectedFiles->addToSelection( **dit );
523 audioView->setSelected( it.current(),FALSE);
524 }
593 } 525 }
594 } 526 }
595 audioView->setSelected( it.current(),FALSE);
596 } 527 }
597 } 528 }
598 tabWidget->setCurrentPage(0); 529 tabWidget->setCurrentPage(0);
530 writeCurrentM3u();
599 } 531 }
600 break; 532 break;
601 case 2: { // video 533 case 2: { // video
602 QListViewItemIterator it( videoView ); 534 QListViewItemIterator it( videoView );
603 // iterate through all items of the listview 535 // iterate through all items of the listview
604 for ( ; it.current(); ++it ) { 536 for ( ; it.current(); ++it ) {
605 if ( it.current()->isSelected() ) { 537 if ( it.current()->isSelected() ) {
606 QListIterator<DocLnk> dit( vFiles.children() ); 538 QListIterator<DocLnk> dit( vFiles.children() );
607 for ( ; dit.current(); ++dit ) { 539 for ( ; dit.current(); ++dit ) {
608 if( dit.current()->name() == it.current()->text(0) ) { 540 if( dit.current()->name() == it.current()->text(0) ) {
609 if(QFileInfo( dit.current()->file()).exists()) 541 if(QFileInfo( dit.current()->file()).exists()) {
610 d->selectedFiles->addToSelection( **dit ); 542 d->selectedFiles->addToSelection( **dit );
543 videoView->setSelected( it.current(),FALSE);
544 }
611 } 545 }
612 } 546 }
613 videoView->setSelected( it.current(),FALSE);
614 } 547 }
615 } 548 }
616 tabWidget->setCurrentPage(0); 549 tabWidget->setCurrentPage(0);
550 writeCurrentM3u();
617 } 551 }
618 break; 552 break;
619 }; 553 };
620} 554}
621 555
622 556
@@ -643,22 +577,27 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
643 for ( ; dit.current(); ++dit ) { 577 for ( ; dit.current(); ++dit ) {
644 if( dit.current()->name() == it->text(0)) { 578 if( dit.current()->name() == it->text(0)) {
645 if(QFileInfo( dit.current()->file()).exists()) 579 if(QFileInfo( dit.current()->file()).exists())
646 d->selectedFiles->addToSelection( **dit ); 580 d->selectedFiles->addToSelection( **dit );
647 } 581 }
648 } 582 }
583 writeCurrentM3u();
584
649 } 585 }
586
650 break; 587 break;
651 case 2: { 588 case 2: {
652 QListIterator<DocLnk> dit( vFiles.children() ); 589 QListIterator<DocLnk> dit( vFiles.children() );
653 for ( ; dit.current(); ++dit ) { 590 for ( ; dit.current(); ++dit ) {
654 if( dit.current()->name() == it->text(0)) { 591 if( dit.current()->name() == it->text(0)) {
655 if( QFileInfo( dit.current()->file()).exists() ) 592 if( QFileInfo( dit.current()->file()).exists() )
656 d->selectedFiles->addToSelection( **dit ); 593 d->selectedFiles->addToSelection( **dit );
657 } 594 }
658 } 595 }
596 writeCurrentM3u();
597
659 } 598 }
660 break; 599 break;
661 case 0: 600 case 0:
662 break; 601 break;
663 }; 602 };
664 tabWidget->setCurrentPage(0); 603 tabWidget->setCurrentPage(0);
@@ -847,35 +786,28 @@ void PlayListWidget::openFile() {
847 Om3u *m3uList; 786 Om3u *m3uList;
848 DocLnk lnk; 787 DocLnk lnk;
849 QString m3uFile, m3uFilePath; 788 QString m3uFile, m3uFilePath;
850 789
851 if(filename.find(":",8,TRUE) != -1) { //found a port 790 if(filename.find(":",8,TRUE) != -1) { //found a port
852 m3uFile = filename.left( filename.find( ":",8,TRUE)); 791 m3uFile = filename.left( filename.find( ":",8,TRUE));
853
854 m3uFile = m3uFile.right( 7); 792 m3uFile = m3uFile.right( 7);
855
856 } else if(filename.left(4) == "http"){ 793 } else if(filename.left(4) == "http"){
857
858 m3uFile=filename; 794 m3uFile=filename;
859 m3uFile = m3uFile.right( m3uFile.length() - 7); 795 m3uFile = m3uFile.right( m3uFile.length() - 7);
860
861 } else{ 796 } else{
862 m3uFile=filename; 797 m3uFile=filename;
863 } 798 }
864
865// qDebug( m3uFile); 799// qDebug( m3uFile);
866 800
867//this is where this new m3u is going to live at 801//this is where this new m3u is going to live at
868 m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u"; 802 m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u";
869// m3uFile += ".m3u"; 803// m3uFile += ".m3u";
870 m3uList = new Om3u( m3uFile+".m3u"); 804 m3uList = new Om3u( m3uFile+".m3u", IO_ReadWrite );
871
872 m3uList->add( filename); 805 m3uList->add( filename);
873 m3uList->write(); 806 m3uList->write();
874 if(m3uList) delete m3uList; 807 if(m3uList) delete m3uList;
875
876// qDebug( m3uFile); 808// qDebug( m3uFile);
877 lnk.setName( filename ); //sets file name 809 lnk.setName( filename ); //sets file name
878 lnk.setFile( m3uFilePath ); //sets File property 810 lnk.setFile( m3uFilePath ); //sets File property
879 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() ); 811 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
880 812
881 lnk.setExec( "opieplayer2" ); 813 lnk.setExec( "opieplayer2" );
@@ -903,58 +835,59 @@ void PlayListWidget::openFile() {
903reads m3u and adds files/urls to playlist */ 835reads m3u and adds files/urls to playlist */
904void PlayListWidget::readm3u( const QString &filename ) { 836void PlayListWidget::readm3u( const QString &filename ) {
905 qDebug( "read m3u filename " + filename ); 837 qDebug( "read m3u filename " + filename );
906 838
907 Om3u *m3uList; 839 Om3u *m3uList;
908 QString s, name; 840 QString s, name;
909 m3uList = new Om3u( filename); 841 m3uList = new Om3u( filename, IO_ReadOnly );
910 m3uList->readM3u(); 842 m3uList->readM3u();
911 DocLnk lnk; 843 DocLnk lnk;
912 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 844 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
913 s = *it; 845 s = *it;
914 s.replace( QRegExp( "%20" )," " ); 846 s.replace( QRegExp( "%20" )," " );
915 qDebug("reading "+ s); 847// qDebug("reading "+ s);
916 848
917 if( QFileInfo( s ).exists() ) { 849 if( QFileInfo( s ).exists() ) {
918 lnk.setName( QFileInfo(s).baseName()); 850 lnk.setName( QFileInfo(s).baseName());
919 qDebug("set link "+s); 851// qDebug("set link "+s);
920 if(s.at(s.length()-4) == '.') //if regular file 852 if(s.at(s.length()-4) == '.') //if regular file
921 lnk.setFile( s); 853 lnk.setFile( s);
922 else 854 else
923 lnk.setFile( s+"/"); //if url with no extension 855 lnk.setFile( s+"/"); //if url with no extension
924 856
925 d->selectedFiles->addToSelection( lnk ); 857 d->selectedFiles->addToSelection( lnk );
926 } 858 }
927 } 859 }
928 Config config( "OpiePlayer" ); 860 Config config( "OpiePlayer" );
929 config.setGroup( "PlayList" ); 861 config.setGroup( "PlayList" );
930 862
931 config.writeEntry("CurrentPlaylist",filename); 863 config.writeEntry("CurrentPlaylist",filename);
864 config.write();
932 currentPlayList=filename; 865 currentPlayList=filename;
933 866
934 m3uList->close(); 867 m3uList->close();
935 if(m3uList) delete m3uList; 868 if(m3uList) delete m3uList;
936 869
937 d->selectedFiles->setSelectedItem( s); 870 d->selectedFiles->setSelectedItem( s);
938 setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName()); 871 setCaption(tr("OpiePlayer: ")+ filename);
939 872
940} 873}
941 874
942/* 875/*
943reads pls and adds files/urls to playlist */ 876reads pls and adds files/urls to playlist */
944void PlayListWidget::readPls( const QString &filename ) { 877void PlayListWidget::readPls( const QString &filename ) {
945 878
946 qDebug( "pls filename is " + filename ); 879 qDebug( "pls filename is " + filename );
947 Om3u *m3uList; 880 Om3u *m3uList;
948 QString s, name; 881 QString s, name;
949 m3uList = new Om3u( filename); 882 m3uList = new Om3u( filename, IO_ReadOnly );
950 m3uList->readPls(); 883 m3uList->readPls();
951 884
952 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 885 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
953 s = *it; 886 s = *it;
954 s.replace( QRegExp( "%20" )," " ); 887 // s.replace( QRegExp( "%20" )," " );
955 DocLnk lnk( s ); 888 DocLnk lnk( s );
956 QFileInfo f( s ); 889 QFileInfo f( s );
957 QString name = f.baseName(); 890 QString name = f.baseName();
958 891
959 if( name.left( 4 ) == "http" ) { 892 if( name.left( 4 ) == "http" ) {
960 name = s.right( s.length() - 7); 893 name = s.right( s.length() - 7);
@@ -981,12 +914,33 @@ void PlayListWidget::readPls( const QString &filename ) {
981 914
982 m3uList->close(); 915 m3uList->close();
983 if(m3uList) delete m3uList; 916 if(m3uList) delete m3uList;
984} 917}
985 918
986/* 919/*
920 writes current playlist to current m3u file */
921void PlayListWidget::writeCurrentM3u() {
922 qDebug("writting to current m3u");
923 Config cfg( "OpiePlayer" );
924 cfg.setGroup("PlayList");
925 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
926 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
927 Om3u *m3uList;
928 m3uList = new Om3u( currentPlaylist, IO_ReadWrite );
929 d->selectedFiles->first();
930
931 do {
932 m3uList->add( d->selectedFiles->current()->file());
933 }
934 while ( d->selectedFiles->next() );
935 // qDebug( list );
936 m3uList->write();
937 if(m3uList) delete m3uList;
938}
939
940 /*
987 writes current playlist to m3u file */ 941 writes current playlist to m3u file */
988void PlayListWidget::writem3u() { 942void PlayListWidget::writem3u() {
989 InputDialog *fileDlg; 943 InputDialog *fileDlg;
990 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 944 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
991 fileDlg->exec(); 945 fileDlg->exec();
992 QString name, filename, list; 946 QString name, filename, list;
@@ -1001,24 +955,22 @@ void PlayListWidget::writem3u() {
1001 } 955 }
1002 956
1003 if( name.right( 3 ) != "m3u" ) { 957 if( name.right( 3 ) != "m3u" ) {
1004 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 958 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1005 } 959 }
1006 960
1007 m3uList = new Om3u(filename); 961 m3uList = new Om3u(filename, IO_ReadWrite);
1008 962
1009 d->selectedFiles->first(); 963 d->selectedFiles->first();
1010 964
1011 do { 965 do {
1012 m3uList->add( d->selectedFiles->current()->file()); 966 m3uList->add( d->selectedFiles->current()->file());
1013 } 967 }
1014 while ( d->selectedFiles->next() ); 968 while ( d->selectedFiles->next() );
1015// qDebug( list ); 969// qDebug( list );
1016
1017 m3uList->write(); 970 m3uList->write();
1018 m3uList->close();
1019 } 971 }
1020 if(m3uList) delete m3uList; 972 if(m3uList) delete m3uList;
1021 if(fileDlg) delete fileDlg; 973 if(fileDlg) delete fileDlg;
1022 974
1023 DocLnk lnk; 975 DocLnk lnk;
1024 lnk.setFile( filename); 976 lnk.setFile( filename);
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 428821a..8a77619 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -90,12 +90,13 @@ private:
90 90
91private slots: 91private slots:
92 void populateSkinsMenu(); 92 void populateSkinsMenu();
93 void skinsMenuActivated(int); 93 void skinsMenuActivated(int);
94 void pmViewActivated(int); 94 void pmViewActivated(int);
95 void writem3u(); 95 void writem3u();
96 void writeCurrentM3u();
96 void scanForAudio(); 97 void scanForAudio();
97 void scanForVideo(); 98 void scanForVideo();
98 void openFile(); 99 void openFile();
99 void setDocument( const QString& fileref ); 100 void setDocument( const QString& fileref );
100 void addToSelection( const DocLnk& ); // Add a media file to the playlist 101 void addToSelection( const DocLnk& ); // Add a media file to the playlist
101 void addToSelection( QListViewItem* ); // Add a media file to the playlist 102 void addToSelection( QListViewItem* ); // Add a media file to the playlist