Diffstat (limited to 'noncore/multimedia/opieplayer2/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 25 |
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) | |||
60 | f.open(mode); | 60 | f.open(mode); |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | Om3u::~Om3u(){} | 64 | Om3u::~Om3u(){} |
65 | 65 | ||
66 | void Om3u::readM3u() { //it's m3u | 66 | void 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 | } |
@@ -134,24 +134,35 @@ void 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 | ||
143 | void Om3u::add(const QString &filePath) { //adds to m3u file | 143 | void Om3u::add(const QString &filePath) { //adds to m3u file |
144 | append(filePath); | 144 | append(filePath); |
145 | } | 145 | } |
146 | 146 | ||
147 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 147 | void 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 | ||
151 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 160 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file |
161 | f.close(); | ||
162 | f.remove(); | ||
152 | 163 | ||
153 | } | 164 | } |
154 | 165 | ||
155 | void Om3u::close() { //closes m3u file | 166 | void Om3u::close() { //closes m3u file |
156 | f.close(); | 167 | f.close(); |
157 | } | 168 | } |