summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/om3u.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp141
1 files changed, 67 insertions, 74 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 790fa09..f2a01d3 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -38,89 +38,82 @@ using namespace Opie::Core;
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
- : QStringList (){
-odebug << "<<<<<<<new m3u "+filePath << oendl;
- f.setName(filePath);
- f.open(mode);
+ : QStringList ()
+{
+ odebug << "<<<<<<<new m3u "+filePath << oendl;
+ f.setName(filePath);
+ if (!f.open(mode)) {
+ owarn << "Unable to open file " << f.name() << oendl;
+ }
}
Om3u::~Om3u(){}
void Om3u::readM3u() {
-// odebug << "<<<<<<reading m3u "+f.name() << oendl;
+// odebug << "<<<<<<reading m3u "+f.name() << oendl;
QTextStream t(&f);
- t.setEncoding(QTextStream::UnicodeUTF8);
- QString s;
+ t.setEncoding(QTextStream::UnicodeUTF8);
+ QString s;
while ( !t.atEnd() ) {
s=t.readLine();
-// odebug << s << oendl;
+ // odebug << s << oendl;
if( s.find( "#", 0, TRUE) == -1 ) {
- if( s.left(2) == "E:" || s.left(2) == "P:" ) {
- s = s.right( s.length() -2 );
- QFileInfo f( s );
- QString name = f.baseName();
- name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
- s=s.replace( QRegExp( "\\" ), "/" );
- append(s);
-// odebug << s << oendl;
- } else { // is url
- QString name;
- name = s;
- append(name);
- }
+ if( s.left(2) == "E:" || s.left(2) == "P:" ) {
+ s = s.right( s.length() -2 );
+ QFileInfo f( s );
+ QString name = f.baseName();
+ name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
+ s=s.replace( QRegExp( "\\" ), "/" );
+ append(s);
+// odebug << s << oendl;
+ } else { // is url
+ QString name;
+ name = s;
+ append(name);
+ }
}
}
}
void Om3u::readPls() { //it's a pls file
- QTextStream t( &f );
- t.setEncoding(QTextStream::UnicodeUTF8);
- QString s;
- while ( !t.atEnd() ) {
- s = t.readLine();
- if( s.left(4) == "File" ) {
- s = s.right( s.length() - s.find("=",0,true)-1 );
- s = s.stripWhiteSpace();
- s.replace( QRegExp( "%20" )," ");
-// odebug << "adding " + s + " to playlist" << oendl;
- // numberofentries=2
- // File1=http
- // Title
- // Length
- // Version
- // File2=http
- s = s.replace( QRegExp( "\\" ), "/" );
- 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 );
- if( s.at( s.length() - 4) == '.') // if this is probably a file
+ QTextStream t( &f );
+ t.setEncoding(QTextStream::UnicodeUTF8);
+ QString s;
+ while ( !t.atEnd() ) {
+ s = t.readLine();
+ if( s.left(4) == "File" ) {
+ s = s.right( s.length() - s.find("=",0,true)-1 );
+ s = s.stripWhiteSpace();
+ s.replace( QRegExp( "%20" )," ");
+ // odebug << "adding " + s + " to playlist" << oendl;
+ s = s.replace( QRegExp( "\\" ), "/" );
+ 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 );
+ if( s.at( s.length() - 4) == '.') // if this is probably a file
+ append(s);
+ else { //if its a url
append(s);
- else { //if its a url
-// if( name.right( 1 ).find( '/' ) == -1) {
-// s += "/";
-// }
- append(s);
- }
}
}
+ }
}
void Om3u::write() { //writes list to m3u file
- QString list;
- QTextStream t(&f);
- t.setEncoding(QTextStream::UnicodeUTF8);
- if(count()>0) {
- for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
-// odebug << *it << oendl;
- t << *it << "\n";
+ QString list;
+ QTextStream t(&f);
+ t.setEncoding(QTextStream::UnicodeUTF8);
+ if(count()>0) {
+ for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
+ // odebug << *it << oendl;
+ t << *it << "\n";
+ }
}
- }
-// f.close();
}
void Om3u::add(const QString &filePath) { //adds to m3u file
@@ -128,22 +121,22 @@ void Om3u::add(const QString &filePath) { //adds to m3u file
}
void Om3u::remove(const QString &filePath) { //removes from m3u list
- QString list, currentFile;
- if(count()>0) {
- for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
- currentFile=*it;
- // odebug << *it << oendl;
-
- if( filePath != currentFile)
- list += currentFile+"\n";
+ QString list, currentFile;
+ if(count()>0) {
+ for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
+ currentFile=*it;
+ // odebug << *it << oendl;
+
+ if( filePath != currentFile)
+ list += currentFile+"\n";
+ }
+ f.writeBlock( list, list.length() );
}
- f.writeBlock( list, list.length() );
- }
}
void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file
- f.close();
- f.remove();
+ f.close();
+ f.remove();
}