summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/om3u.cpp
Unidiff
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
@@ -63,13 +63,13 @@ Om3u::Om3u( const QString &filePath, int mode)
63 63
64Om3u::~Om3u(){} 64Om3u::~Om3u(){}
65 65
66void Om3u::readM3u() { //it's m3u 66void Om3u::readM3u() {
67// qDebug("<<<<<<reading m3u "+f.name()); 67// qDebug("<<<<<<reading m3u "+f.name());
68 QTextStream t(&f); 68 QTextStream t(&f);
69 QString s; 69 QString s;
70 while ( !t.atEnd() ) { 70 while ( !t.atEnd() ) {
71 s=t.readLine(); 71 s=t.readLine();
72 // qDebug(s); 72 qDebug(s);
73 if( s.find( "#", 0, TRUE) == -1 ) { 73 if( s.find( "#", 0, TRUE) == -1 ) {
74 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 74 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
75 s = s.right( s.length() -2 ); 75 s = s.right( s.length() -2 );
@@ -82,11 +82,11 @@ void Om3u::readM3u() { //it's m3u
82 } else { // is url 82 } else { // is url
83 s.replace( QRegExp( "%20" )," " ); 83 s.replace( QRegExp( "%20" )," " );
84 QString name; 84 QString name;
85 if( name.left( 4 ) == "http" ) { 85// if( name.left( 4 ) == "http" ) {
86 name = s.right( s.length() - 7 ); 86// name = s.right( s.length() - 7 );
87 } else { 87// } else {
88 name = s; 88 name = s;
89 } 89// }
90 append(name); 90 append(name);
91// qDebug(name); 91// qDebug(name);
92 } 92 }
@@ -137,7 +137,7 @@ void Om3u::write() { //writes list to m3u file
137 list += *it+"\n"; 137 list += *it+"\n";
138 } 138 }
139 f.writeBlock( list, list.length() ); 139 f.writeBlock( list, list.length() );
140 f.close(); 140// f.close();
141} 141}
142 142
143void Om3u::add(const QString &filePath) { //adds to m3u file 143void Om3u::add(const QString &filePath) { //adds to m3u file
@@ -145,10 +145,21 @@ void Om3u::add(const QString &filePath) { //adds to m3u file
145} 145}
146 146
147void Om3u::remove(const QString &filePath) { //removes from m3u list 147void Om3u::remove(const QString &filePath) { //removes from m3u list
148 QString list, currentFile;
149 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
150 currentFile=*it;
151// qDebug(*it);
152
153 if( filePath != currentFile)
154 list += currentFile+"\n";
155 }
156 f.writeBlock( list, list.length() );
148 157
149} 158}
150 159
151void Om3u::deleteFile(const QString &filePath) {//deletes m3u file 160void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
161 f.close();
162 f.remove();
152 163
153} 164}
154 165