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
@@ -54,48 +54,48 @@ Om3u::Om3u( const QString &filePath, int mode)
54//qDebug("<<<<<<<new m3u "+filePath); 54//qDebug("<<<<<<<new m3u "+filePath);
55 f.setName(filePath); 55 f.setName(filePath);
56// if(f.exists()) 56// if(f.exists())
57// f.open( IO_ReadWrite); 57// f.open( IO_ReadWrite);
58// else 58// else
59// f.open( IO_ReadWrite | IO_Truncate); 59// f.open( IO_ReadWrite | IO_Truncate);
60 f.open(mode); 60 f.open(mode);
61 61
62} 62}
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 );
76 QFileInfo f( s ); 76 QFileInfo f( s );
77 QString name = f.baseName(); 77 QString name = f.baseName();
78 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 78 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
79 s=s.replace( QRegExp( "\\" ), "/" ); 79 s=s.replace( QRegExp( "\\" ), "/" );
80 append(s); 80 append(s);
81// qDebug(s); 81// qDebug(s);
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 }
93 } 93 }
94 } 94 }
95} 95}
96 96
97void Om3u::readPls() { //it's a pls file 97void Om3u::readPls() { //it's a pls file
98 QTextStream t( &f ); 98 QTextStream t( &f );
99 QString s; 99 QString s;
100 while ( !t.atEnd() ) { 100 while ( !t.atEnd() ) {
101 s = t.readLine(); 101 s = t.readLine();
@@ -128,30 +128,41 @@ void Om3u::readPls() { //it's a pls file
128 } 128 }
129 } 129 }
130 } 130 }
131} 131}
132 132
133void Om3u::write() { //writes list to m3u file 133void Om3u::write() { //writes list to m3u file
134 QString list; 134 QString list;
135 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 135 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
136 qDebug(*it); 136 qDebug(*it);
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
144 append(filePath); 144 append(filePath);
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
155void Om3u::close() { //closes m3u file 166void Om3u::close() { //closes m3u file
156 f.close(); 167 f.close();
157} 168}