summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
2 files changed, 5 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 12fb16e..4617c59 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -42,49 +42,49 @@
42#include <qdir.h> 42#include <qdir.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qstring.h> 44#include <qstring.h>
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, int mode) 51Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 52 : QStringList (){
53qDebug("<<<<<<<new m3u "+filePath); 53qDebug("<<<<<<<new m3u "+filePath);
54 f.setName(filePath); 54 f.setName(filePath);
55 f.open(mode); 55 f.open(mode);
56} 56}
57 57
58Om3u::~Om3u(){} 58Om3u::~Om3u(){}
59 59
60void Om3u::readM3u() { 60void Om3u::readM3u() {
61// qDebug("<<<<<<reading m3u "+f.name()); 61// qDebug("<<<<<<reading m3u "+f.name());
62 QTextStream t(&f); 62 QTextStream t(&f);
63 QString s; 63 QString s;
64 while ( !t.atEnd() ) { 64 while ( !t.atEnd() ) {
65 s=t.readLine(); 65 s=t.readLine();
66 qDebug(s); 66// qDebug(s);
67 if( s.find( "#", 0, TRUE) == -1 ) { 67 if( s.find( "#", 0, TRUE) == -1 ) {
68 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 68 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
69 s = s.right( s.length() -2 ); 69 s = s.right( s.length() -2 );
70 QFileInfo f( s ); 70 QFileInfo f( s );
71 QString name = f.baseName(); 71 QString name = f.baseName();
72 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 72 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
73 s=s.replace( QRegExp( "\\" ), "/" ); 73 s=s.replace( QRegExp( "\\" ), "/" );
74 append(s); 74 append(s);
75// qDebug(s); 75// qDebug(s);
76 } else { // is url 76 } else { // is url
77 s.replace( QRegExp( "%20" )," " ); 77 s.replace( QRegExp( "%20" )," " );
78 QString name; 78 QString name;
79// if( name.left( 4 ) == "http" ) { 79// if( name.left( 4 ) == "http" ) {
80// name = s.right( s.length() - 7 ); 80// name = s.right( s.length() - 7 );
81// } else { 81// } else {
82 name = s; 82 name = s;
83// } 83// }
84 append(name); 84 append(name);
85// qDebug(name); 85// qDebug(name);
86 } 86 }
87 } 87 }
88 } 88 }
89} 89}
90 90
@@ -107,49 +107,49 @@ void Om3u::readPls() { //it's a pls file
107 QFileInfo f( s ); 107 QFileInfo f( s );
108 QString name = f.baseName(); 108 QString name = f.baseName();
109 if( name.left( 4 ) == "http" ) { 109 if( name.left( 4 ) == "http" ) {
110 name = s.right( s.length() - 7); 110 name = s.right( s.length() - 7);
111 } else { 111 } else {
112 name = s; 112 name = s;
113 } 113 }
114 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 114 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
115 if( s.at( s.length() - 4) == '.') // if this is probably a file 115 if( s.at( s.length() - 4) == '.') // if this is probably a file
116 append(s); 116 append(s);
117 else { //if its a url 117 else { //if its a url
118// if( name.right( 1 ).find( '/' ) == -1) { 118// if( name.right( 1 ).find( '/' ) == -1) {
119// s += "/"; 119// s += "/";
120// } 120// }
121 append(s); 121 append(s);
122 } 122 }
123 } 123 }
124 } 124 }
125} 125}
126 126
127void Om3u::write() { //writes list to m3u file 127void Om3u::write() { //writes list to m3u file
128 QString list; 128 QString list;
129 if(count()>0) { 129 if(count()>0) {
130 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 130 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
131 qDebug(*it); 131// qDebug(*it);
132 list += *it+"\n"; 132 list += *it+"\n";
133 } 133 }
134 f.writeBlock( list, list.length() ); 134 f.writeBlock( list, list.length() );
135 } 135 }
136// f.close(); 136// f.close();
137} 137}
138 138
139void Om3u::add(const QString &filePath) { //adds to m3u file 139void Om3u::add(const QString &filePath) { //adds to m3u file
140 append(filePath); 140 append(filePath);
141} 141}
142 142
143void Om3u::remove(const QString &filePath) { //removes from m3u list 143void Om3u::remove(const QString &filePath) { //removes from m3u list
144 QString list, currentFile; 144 QString list, currentFile;
145 if(count()>0) { 145 if(count()>0) {
146 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 146 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
147 currentFile=*it; 147 currentFile=*it;
148 // qDebug(*it); 148 // qDebug(*it);
149 149
150 if( filePath != currentFile) 150 if( filePath != currentFile)
151 list += currentFile+"\n"; 151 list += currentFile+"\n";
152 } 152 }
153 f.writeBlock( list, list.length() ); 153 f.writeBlock( list, list.length() );
154 } 154 }
155} 155}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 1138dc2..53cd00e 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -368,49 +368,49 @@ void PlayListWidget::addAllVideoToList() {
368 for ( ; videoIt.current(); ++videoIt ) { 368 for ( ; videoIt.current(); ++videoIt ) {
369 filename = videoIt.current()->text(3); 369 filename = videoIt.current()->text(3);
370 lnk.setName( QFileInfo(filename).baseName() ); //sets name 370 lnk.setName( QFileInfo(filename).baseName() ); //sets name
371 lnk.setFile( filename ); //sets file name 371 lnk.setFile( filename ); //sets file name
372 d->selectedFiles->addToSelection( lnk); 372 d->selectedFiles->addToSelection( lnk);
373 } 373 }
374 374
375 375
376 /* if(!videoScan) 376 /* if(!videoScan)
377 scanForVideo(); 377 scanForVideo();
378 QListIterator<DocLnk> dit( vFiles.children() ); 378 QListIterator<DocLnk> dit( vFiles.children() );
379 for ( ; dit.current(); ++dit ) { 379 for ( ; dit.current(); ++dit ) {
380 if( QFileInfo( dit.current()->file() ).exists() ) { 380 if( QFileInfo( dit.current()->file() ).exists() ) {
381 d->selectedFiles->addToSelection( **dit ); 381 d->selectedFiles->addToSelection( **dit );
382 } 382 }
383 } 383 }
384*/ 384*/
385 tabWidget->setCurrentPage(0); 385 tabWidget->setCurrentPage(0);
386 writeCurrentM3u(); 386 writeCurrentM3u();
387 d->selectedFiles->first(); 387 d->selectedFiles->first();
388} 388}
389 389
390 390
391void PlayListWidget::setDocument( const QString& fileref ) { 391void PlayListWidget::setDocument( const QString& fileref ) {
392 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 392 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
393 fromSetDocument = TRUE; 393 fromSetDocument = TRUE;
394 if ( fileref.isNull() ) { 394 if ( fileref.isNull() ) {
395 QMessageBox::warning( this, tr( "Invalid File" ), 395 QMessageBox::warning( this, tr( "Invalid File" ),
396 tr( "There was a problem in getting the file." ) ); 396 tr( "There was a problem in getting the file." ) );
397 return; 397 return;
398 } 398 }
399 399
400 clearList(); 400 clearList();
401 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 401 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
402 readm3u( fileref ); 402 readm3u( fileref );
403 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 403 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
404 readm3u( DocLnk( fileref).file() ); 404 readm3u( DocLnk( fileref).file() );
405 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 405 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
406 readPls( fileref ); 406 readPls( fileref );
407 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 407 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
408 readPls( DocLnk( fileref).file() ); 408 readPls( DocLnk( fileref).file() );
409 } else { 409 } else {
410 clearList(); 410 clearList();
411 addToSelection( DocLnk( fileref ) ); 411 addToSelection( DocLnk( fileref ) );
412 writeCurrentM3u(); 412 writeCurrentM3u();
413 413
414 d->setDocumentUsed = TRUE; 414 d->setDocumentUsed = TRUE;
415 mediaPlayerState->setPlaying( FALSE ); 415 mediaPlayerState->setPlaying( FALSE );
416 mediaPlayerState->setPlaying( TRUE ); 416 mediaPlayerState->setPlaying( TRUE );
@@ -938,53 +938,53 @@ void PlayListWidget::readPls( const QString &filename ) {
938 } 938 }
939 lnk.setType( "audio/x-mpegurl" ); 939 lnk.setType( "audio/x-mpegurl" );
940 940
941 lnk.writeLink(); 941 lnk.writeLink();
942 d->selectedFiles->addToSelection( lnk ); 942 d->selectedFiles->addToSelection( lnk );
943 } 943 }
944 944
945 m3uList->close(); 945 m3uList->close();
946 if(m3uList) delete m3uList; 946 if(m3uList) delete m3uList;
947} 947}
948 948
949/* 949/*
950 writes current playlist to current m3u file */ 950 writes current playlist to current m3u file */
951void PlayListWidget::writeCurrentM3u() { 951void PlayListWidget::writeCurrentM3u() {
952 qDebug("writing to current m3u"); 952 qDebug("writing to current m3u");
953 Config cfg( "OpiePlayer" ); 953 Config cfg( "OpiePlayer" );
954 cfg.setGroup("PlayList"); 954 cfg.setGroup("PlayList");
955 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 955 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
956 956
957 Om3u *m3uList; 957 Om3u *m3uList;
958 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 958 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
959 if( d->selectedFiles->first()) { 959 if( d->selectedFiles->first()) {
960 960
961 do { 961 do {
962 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 962 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
963 m3uList->add( d->selectedFiles->current()->file() ); 963 m3uList->add( d->selectedFiles->current()->file() );
964 } 964 }
965 while ( d->selectedFiles->next() ); 965 while ( d->selectedFiles->next() );
966 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 966 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
967 m3uList->write(); 967 m3uList->write();
968 m3uList->close(); 968 m3uList->close();
969 969
970 if(m3uList) delete m3uList; 970 if(m3uList) delete m3uList;
971 } 971 }
972 972
973} 973}
974 974
975 /* 975 /*
976 writes current playlist to m3u file */ 976 writes current playlist to m3u file */
977void PlayListWidget::writem3u() { 977void PlayListWidget::writem3u() {
978 InputDialog *fileDlg; 978 InputDialog *fileDlg;
979 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 979 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
980 fileDlg->exec(); 980 fileDlg->exec();
981 QString name, filename, list; 981 QString name, filename, list;
982 Om3u *m3uList; 982 Om3u *m3uList;
983 983
984 if( fileDlg->result() == 1 ) { 984 if( fileDlg->result() == 1 ) {
985 name = fileDlg->text(); 985 name = fileDlg->text();
986// qDebug( filename ); 986// qDebug( filename );
987 987
988 if( name.left( 1) != "/" ) { 988 if( name.left( 1) != "/" ) {
989 filename = QPEApplication::documentDir() + "/" + name; 989 filename = QPEApplication::documentDir() + "/" + name;
990 } 990 }