summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/om3u.cpp
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/om3u.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/om3u.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 8b92a8c..778eb22 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -46,120 +46,123 @@
#include <qstringlist.h>
#include <qcstring.h>
static inline QString fullBaseName ( const QFileInfo &fi )
{
QString str = fi. fileName ( );
return str. left ( str. findRev ( '.' ));
}
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
//qDebug("<<<<<<<new m3u "+filePath);
f.setName(filePath);
f.open(mode);
}
Om3u::~Om3u(){}
void Om3u::readM3u() {
// qDebug("<<<<<<reading m3u "+f.name());
QTextStream t(&f);
+ t.setEncoding(QTextStream::UnicodeUTF8);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
// qDebug(s);
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 = fullBaseName ( f );
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
s=s.replace( QRegExp( "\\" ), "/" );
append(s);
// qDebug(s);
} else { // is url
s.replace( QRegExp( "%20" )," " );
QString name;
// if( name.left( 4 ) == "http" ) {
// name = s.right( s.length() - 7 );
// } else {
name = s;
// }
append(name);
// qDebug(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() - 6 );
s.replace( QRegExp( "%20" )," ");
// qDebug( "adding " + s + " to playlist" );
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
QFileInfo f( s );
QString name = fullBaseName ( f );
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
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 ) {
// qDebug(*it);
- list += *it+"\n";
+ t << *it << "\n";
}
- f.writeBlock( list, list.length() );
}
// f.close();
}
void Om3u::add(const QString &filePath) { //adds to m3u file
append(filePath);
}
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;
// qDebug(*it);
if( filePath != currentFile)
list += currentFile+"\n";
}
f.writeBlock( list, list.length() );
}
}
void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
f.close();