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.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index c947033..0be727b 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -60,36 +60,36 @@ Om3u::Om3u( const QString &filePath, int mode)
f.open(mode);
}
Om3u::~Om3u(){}
-void Om3u::readM3u() { //it's m3u
+void Om3u::readM3u() {
// qDebug("<<<<<<reading m3u "+f.name());
QTextStream t(&f);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
- // qDebug(s);
+ 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 = f.baseName();
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 {
+// if( name.left( 4 ) == "http" ) {
+// name = s.right( s.length() - 7 );
+// } else {
name = s;
- }
+// }
append(name);
// qDebug(name);
}
}
}
}
@@ -134,24 +134,35 @@ void Om3u::write() { //writes list to m3u file
QString list;
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
qDebug(*it);
list += *it+"\n";
}
f.writeBlock( list, list.length() );
- f.close();
+// 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;
+ 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();
+ f.remove();
}
void Om3u::close() { //closes m3u file
f.close();
}