summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp195
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h5
3 files changed, 101 insertions, 102 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 235d973..841d950 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -96,3 +96,4 @@ void Om3u::readPls() { //it's a pls file
if( s.left(4) == "File" ) {
- s = s.right( s.length() - 6 );
+ s = s.right( s.length() - s.find("=",0,true)-1 );
+ s = s.stripWhiteSpace();
s.replace( QRegExp( "%20" )," ");
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index a65495e..6e2457f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -109,3 +109,3 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
d->selectedFiles, SLOT(moveSelectedDown() ) );
- QVBox *stretch2 = new QVBox( vbox1 );
+ // QVBox *stretch2 = new QVBox( vbox1 );
@@ -367,3 +367,5 @@ void PlayListWidget::setDocument( const QString& fileref ) {
fromSetDocument = TRUE;
- if ( fileref.isNull() ) {
+ QFileInfo fileInfo(fileref);
+
+ if ( !fileInfo.exists() ) {
QMessageBox::warning( this, tr( "Invalid File" ),
@@ -374,13 +376,13 @@ void PlayListWidget::setDocument( const QString& fileref ) {
clearList();
- if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
- readm3u( fileref );
- } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
- readm3u( DocLnk( fileref).file() );
- } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
- readPls( fileref );
- } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
- readPls( DocLnk( fileref).file() );
+ QString extension = fileInfo.extension(false);
+
+ if( extension.find( "m3u", 0, false) != -1
+ || extension.find( "pls", 0, false) != -1 ) {
+ readListFromFile( fileref );
} else {
clearList();
- addToSelection( DocLnk( fileref ) );
+ DocLnk lnk;
+ lnk.setName( fileInfo.baseName() ); //sets name
+ lnk.setFile( fileref ); //sets file name
+ addToSelection( lnk );
writeCurrentM3u();
@@ -478,3 +480,4 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
clearList();
- readm3u(lnk.file());
+// readm3u(lnk.file());
+ readListFromFile(lnk.file());
tabWidget->setCurrentPage(0);
@@ -682,7 +685,5 @@ void PlayListWidget::openFile() {
}
- else if( filename.right( 3) == "m3u" ) {
- readm3u( filename );
-
- } else if( filename.right(3) == "pls" ) {
- readPls( filename );
+ else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
+ readListFromFile( filename );
+// readPls( filename );
} else {
@@ -696,2 +697,3 @@ void PlayListWidget::openFile() {
+
delete fileDlg;
@@ -699,7 +701,5 @@ void PlayListWidget::openFile() {
-/*
-reads m3u and shows files/urls to playlist widget */
-void PlayListWidget::readm3u( const QString &filename ) {
- qDebug( "read m3u filename " + filename );
-
+void PlayListWidget::readListFromFile( const QString &filename ) {
+ qDebug( "read list filename " + filename );
+ QFileInfo fi(filename);
Om3u *m3uList;
@@ -707,3 +707,7 @@ void PlayListWidget::readm3u( const QString &filename ) {
m3uList = new Om3u( filename, IO_ReadOnly );
- m3uList->readM3u();
+ if(fi.extension(false).find("m3u",0,false) != -1 )
+ m3uList->readM3u();
+ else if(fi.extension(false).find("pls",0,false) != -1 )
+ m3uList->readPls();
+
DocLnk lnk;
@@ -711,3 +715,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
s = *it;
-// qDebug("reading "+ s);
+ // qDebug(s);
if(s.left(4)=="http") {
@@ -717,16 +721,9 @@ void PlayListWidget::readm3u( const QString &filename ) {
- } else {
- // if( QFileInfo( s ).exists() ) {
+ } else { //is file
lnk.setName( QFileInfo(s).baseName());
- // if(s.right(4) == '.') {//if regular file
if(s.left(1) != "/") {
- // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
+
lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
-// lnk.setIcon(MimeType(s).pixmap() );
-// lnk.setIcon("SoundPlayer");
} else {
- // qDebug("set link2 "+s);
lnk.setFile( s);
-// lnk.setIcon(MimeType(s).pixmap() );
-// lnk.setIcon("SoundPlayer");
}
@@ -751,70 +748,70 @@ void PlayListWidget::readm3u( const QString &filename ) {
-/*
-reads pls and adds files/urls to playlist */
-void PlayListWidget::readPls( const QString &filename ) {
-
- qDebug( "pls filename is " + filename );
- Om3u *m3uList;
- QString s, name;
- m3uList = new Om3u( filename, IO_ReadOnly );
- m3uList->readPls();
-
- for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
- s = *it;
- // s.replace( QRegExp( "%20" )," " );
- DocLnk lnk( s );
- QFileInfo f( s );
- QString name = f.baseName();
-
- if( name.left( 4 ) == "http" ) {
- name = s.right( s.length() - 7);
- } else {
- name = s;
- }
-
- name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
-
- lnk.setName( name );
- if( s.at( s.length() - 4) == '.') {// if this is probably a file
- lnk.setFile( s );
- } else { //if its a url
-// if( name.right( 1 ).find( '/' ) == -1) {
-// s += "/";
-// }
- lnk.setFile( s );
- }
- lnk.setType( "audio/x-mpegurl" );
-
- lnk.writeLink();
- d->selectedFiles->addToSelection( lnk );
- }
-
- m3uList->close();
- delete m3uList;
-}
-
-/*
- writes current playlist to current m3u file */
-void PlayListWidget::writeCurrentM3u() {
- qDebug("writing to current m3u");
- Config cfg( "OpiePlayer" );
- cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
-
- Om3u *m3uList;
- m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
- if( d->selectedFiles->first()) {
-
- do {
- // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
- m3uList->add( d->selectedFiles->current()->file() );
- }
- while ( d->selectedFiles->next() );
- // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
- m3uList->write();
+// /*
+// reads pls and adds files/urls to playlist */
+// void PlayListWidget::readPls( const QString &filename ) {
+
+// qDebug( "pls filename is " + filename );
+// Om3u *m3uList;
+// QString s, name;
+// m3uList = new Om3u( filename, IO_ReadOnly );
+// m3uList->readPls();
+
+// for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
+// s = *it;
+// // s.replace( QRegExp( "%20" )," " );
+// DocLnk lnk( s );
+// QFileInfo f( s );
+// QString name = f.baseName();
+
+// if( name.left( 4 ) == "http" ) {
+// name = s.right( s.length() - 7);
+// } else {
+// name = s;
+// }
+
+// name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
+
+// lnk.setName( name );
+// if( s.at( s.length() - 4) == '.') {// if this is probably a file
+// lnk.setFile( s );
+// } else { //if its a url
+// // if( name.right( 1 ).find( '/' ) == -1) {
+// // s += "/";
+// // }
+// lnk.setFile( s );
+// }
+// lnk.setType( "audio/x-mpegurl" );
+
+// lnk.writeLink();
+// d->selectedFiles->addToSelection( lnk );
+// }
+
+// m3uList->close();
+// delete m3uList;
+// }
+
+// /*
+// writes current playlist to current m3u file */
+ void PlayListWidget::writeCurrentM3u() {
+ qDebug("writing to current m3u");
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("PlayList");
+ QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
+
+ Om3u *m3uList;
+ m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
+ if( d->selectedFiles->first()) {
+
+ do {
+ // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
+ m3uList->add( d->selectedFiles->current()->file() );
+ }
+ while ( d->selectedFiles->next() );
+ // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
+ m3uList->write();
m3uList->close();
- }
- delete m3uList;
+ }
+ delete m3uList;
-}
+ }
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index e8bf211..cb65d5c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -96,4 +96,5 @@ private:
int defaultSkinIndex;
- void readm3u(const QString &);
- void readPls(const QString &);
+/* void readm3u(const QString &); */
+/* void readPls(const QString &); */
+ void readListFromFile(const QString &);
void initializeStates();