summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2002-10-08 02:01:16 (UTC)
committer llornkcor <llornkcor>2002-10-08 02:01:16 (UTC)
commit40e9c78666e74221e06329bb07dfd66648b2727b (patch) (unidiff)
treeafccf992024cc56a64d8495d80ce10478f946478 /noncore
parentc43b5d600a7d1dcaadcba2cb047a60313b37f2f2 (diff)
downloadopie-40e9c78666e74221e06329bb07dfd66648b2727b.zip
opie-40e9c78666e74221e06329bb07dfd66648b2727b.tar.gz
opie-40e9c78666e74221e06329bb07dfd66648b2727b.tar.bz2
fixed m3u handling
Diffstat (limited to 'noncore') (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
@@ -50,3 +50,3 @@
50 50
51Om3u::Om3u( const QString &filePath) 51Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 52 : QStringList (){
@@ -55,6 +55,8 @@ Om3u::Om3u( const QString &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}
@@ -69,5 +71,4 @@ void Om3u::readM3u() { //it's m3u
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:" ) {
@@ -91,3 +92,2 @@ void Om3u::readM3u() { //it's m3u
91 } 92 }
92 }
93 } 93 }
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
@@ -55,3 +55,3 @@ class Om3u : public QStringList {
55public: 55public:
56 Om3u( const QString &filePath); 56 Om3u( const QString &filePath, int mode);
57 ~Om3u(); 57 ~Om3u();
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
@@ -150,11 +150,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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
@@ -164,2 +155,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
164 initializeStates(); 155 initializeStates();
156
157 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
158 loadList(DocLnk( currentPlaylist ) );
159 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
165} 160}
@@ -168,4 +163,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
168PlayListWidget::~PlayListWidget() { 163PlayListWidget::~PlayListWidget() {
169 // WTF?!@?!
170
171 if ( d->current ) { 164 if ( d->current ) {
@@ -208,3 +201,2 @@ void PlayListWidget::readConfig( Config& cfg ) {
208 d->selectedFiles->addToSelection( lnk ); 201 d->selectedFiles->addToSelection( lnk );
209
210 } 202 }
@@ -213,3 +205,2 @@ void PlayListWidget::readConfig( Config& cfg ) {
213 d->selectedFiles->setSelectedItem( currentString ); 205 d->selectedFiles->setSelectedItem( currentString );
214
215} 206}
@@ -229,14 +220,12 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
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();
@@ -251,5 +240,4 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
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()) {
@@ -257,3 +245,2 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
257 } 245 }
258
259// } else { 246// } else {
@@ -287,3 +274,2 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
287 274
288
289void PlayListWidget::addToSelection( const DocLnk& lnk ) { 275void PlayListWidget::addToSelection( const DocLnk& lnk ) {
@@ -294,2 +280,3 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
294 d->selectedFiles->addToSelection( lnk ); 280 d->selectedFiles->addToSelection( lnk );
281 writeCurrentM3u();
295 } 282 }
@@ -306,3 +293,2 @@ void PlayListWidget::clearList() {
306 293
307
308void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 294void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
@@ -348,2 +334,3 @@ void PlayListWidget::addAllToList() {
348 } 334 }
335 writeCurrentM3u();
349} 336}
@@ -358,2 +345,3 @@ void PlayListWidget::addAllMusicToList() {
358 } 345 }
346 writeCurrentM3u();
359} 347}
@@ -368,2 +356,3 @@ void PlayListWidget::addAllVideoToList() {
368 } 356 }
357 writeCurrentM3u();
369} 358}
@@ -384,7 +373,8 @@ void PlayListWidget::setDocument( const QString& fileref ) {
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();
@@ -393,6 +383,3 @@ void PlayListWidget::setDocument( const QString& fileref ) {
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 }
@@ -493,42 +480,3 @@ bool PlayListWidget::last() {
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 }
@@ -538,3 +486,3 @@ void 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
@@ -542,19 +490,6 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
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 }
@@ -574,7 +509,2 @@ void 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()) {
@@ -590,7 +520,8 @@ void PlayListWidget::addSelected() {
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 }
@@ -598,2 +529,3 @@ void PlayListWidget::addSelected() {
598 tabWidget->setCurrentPage(0); 529 tabWidget->setCurrentPage(0);
530 writeCurrentM3u();
599 } 531 }
@@ -608,7 +540,8 @@ void PlayListWidget::addSelected() {
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 }
@@ -616,2 +549,3 @@ void PlayListWidget::addSelected() {
616 tabWidget->setCurrentPage(0); 549 tabWidget->setCurrentPage(0);
550 writeCurrentM3u();
617 } 551 }
@@ -648,3 +582,6 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
648 } 582 }
583 writeCurrentM3u();
584
649 } 585 }
586
650 break; 587 break;
@@ -658,2 +595,4 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
658 } 595 }
596 writeCurrentM3u();
597
659 } 598 }
@@ -852,10 +791,6 @@ void PlayListWidget::openFile() {
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{
@@ -863,3 +798,2 @@ void PlayListWidget::openFile() {
863 } 798 }
864
865// qDebug( m3uFile); 799// qDebug( m3uFile);
@@ -869,4 +803,3 @@ void PlayListWidget::openFile() {
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);
@@ -874,3 +807,2 @@ void PlayListWidget::openFile() {
874 if(m3uList) delete m3uList; 807 if(m3uList) delete m3uList;
875
876// qDebug( m3uFile); 808// qDebug( m3uFile);
@@ -908,3 +840,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
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();
@@ -914,3 +846,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
914 s.replace( QRegExp( "%20" )," " ); 846 s.replace( QRegExp( "%20" )," " );
915 qDebug("reading "+ s); 847// qDebug("reading "+ s);
916 848
@@ -918,3 +850,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
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
@@ -931,2 +863,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
931 config.writeEntry("CurrentPlaylist",filename); 863 config.writeEntry("CurrentPlaylist",filename);
864 config.write();
932 currentPlayList=filename; 865 currentPlayList=filename;
@@ -937,3 +870,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
937 d->selectedFiles->setSelectedItem( s); 870 d->selectedFiles->setSelectedItem( s);
938 setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName()); 871 setCaption(tr("OpiePlayer: ")+ filename);
939 872
@@ -948,3 +881,3 @@ void PlayListWidget::readPls( const QString &filename ) {
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();
@@ -953,3 +886,3 @@ void PlayListWidget::readPls( const QString &filename ) {
953 s = *it; 886 s = *it;
954 s.replace( QRegExp( "%20" )," " ); 887 // s.replace( QRegExp( "%20" )," " );
955 DocLnk lnk( s ); 888 DocLnk lnk( s );
@@ -986,2 +919,23 @@ void PlayListWidget::readPls( const QString &filename ) {
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 */
@@ -1006,3 +960,3 @@ void PlayListWidget::writem3u() {
1006 960
1007 m3uList = new Om3u(filename); 961 m3uList = new Om3u(filename, IO_ReadWrite);
1008 962
@@ -1015,5 +969,3 @@ void PlayListWidget::writem3u() {
1015// qDebug( list ); 969// qDebug( list );
1016
1017 m3uList->write(); 970 m3uList->write();
1018 m3uList->close();
1019 } 971 }
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
@@ -95,2 +95,3 @@ private slots:
95 void writem3u(); 95 void writem3u();
96 void writeCurrentM3u();
96 void scanForAudio(); 97 void scanForAudio();