author | kergoth <kergoth> | 2003-08-09 16:24:58 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 16:24:58 (UTC) |
commit | e16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (unidiff) | |
tree | 9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/multimedia/opieplayer2/om3u.cpp | |
parent | 1c58d1407f9584fedcdae390a04e2b37e5853361 (diff) | |
download | opie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2 |
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/multimedia/opieplayer2/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 841d950..7183fb4 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -53,57 +53,51 @@ Om3u::Om3u( const QString &filePath, int mode) | |||
53 | qDebug("<<<<<<<new m3u "+filePath); | 53 | qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 54 | f.setName(filePath); |
55 | f.open(mode); | 55 | f.open(mode); |
56 | } | 56 | } |
57 | 57 | ||
58 | Om3u::~Om3u(){} | 58 | Om3u::~Om3u(){} |
59 | 59 | ||
60 | void Om3u::readM3u() { | 60 | void Om3u::readM3u() { |
61 | // qDebug("<<<<<<reading m3u "+f.name()); | 61 | // qDebug("<<<<<<reading m3u "+f.name()); |
62 | QTextStream t(&f); | 62 | QTextStream t(&f); |
63 | QString s; | 63 | QString s; |
64 | while ( !t.atEnd() ) { | 64 | while ( !t.atEnd() ) { |
65 | s=t.readLine(); | 65 | s=t.readLine(); |
66 | // qDebug(s); | 66 | // qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 67 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 69 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 70 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 71 | QString name = f.baseName(); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 73 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 74 | append(s); |
75 | // qDebug(s); | 75 | // qDebug(s); |
76 | } else { // is url | 76 | } else { // is url |
77 | s.replace( QRegExp( "%20" )," " ); | ||
78 | QString name; | 77 | QString name; |
79 | // if( name.left( 4 ) == "http" ) { | 78 | name = s; |
80 | // name = s.right( s.length() - 7 ); | ||
81 | // } else { | ||
82 | name = s; | ||
83 | // } | ||
84 | append(name); | 79 | append(name); |
85 | // qDebug(name); | ||
86 | } | 80 | } |
87 | } | 81 | } |
88 | } | 82 | } |
89 | } | 83 | } |
90 | 84 | ||
91 | void Om3u::readPls() { //it's a pls file | 85 | void Om3u::readPls() { //it's a pls file |
92 | QTextStream t( &f ); | 86 | QTextStream t( &f ); |
93 | QString s; | 87 | QString s; |
94 | while ( !t.atEnd() ) { | 88 | while ( !t.atEnd() ) { |
95 | s = t.readLine(); | 89 | s = t.readLine(); |
96 | if( s.left(4) == "File" ) { | 90 | if( s.left(4) == "File" ) { |
97 | s = s.right( s.length() - s.find("=",0,true)-1 ); | 91 | s = s.right( s.length() - s.find("=",0,true)-1 ); |
98 | s = s.stripWhiteSpace(); | 92 | s = s.stripWhiteSpace(); |
99 | s.replace( QRegExp( "%20" )," "); | 93 | s.replace( QRegExp( "%20" )," "); |
100 | // qDebug( "adding " + s + " to playlist" ); | 94 | // qDebug( "adding " + s + " to playlist" ); |
101 | // numberofentries=2 | 95 | // numberofentries=2 |
102 | // File1=http | 96 | // File1=http |
103 | // Title | 97 | // Title |
104 | // Length | 98 | // Length |
105 | // Version | 99 | // Version |
106 | // File2=http | 100 | // File2=http |
107 | s = s.replace( QRegExp( "\\" ), "/" ); | 101 | s = s.replace( QRegExp( "\\" ), "/" ); |
108 | QFileInfo f( s ); | 102 | QFileInfo f( s ); |
109 | QString name = f.baseName(); | 103 | QString name = f.baseName(); |
@@ -126,41 +120,41 @@ void Om3u::readPls() { //it's a pls file | |||
126 | } | 120 | } |
127 | 121 | ||
128 | void Om3u::write() { //writes list to m3u file | 122 | void Om3u::write() { //writes list to m3u file |
129 | QString list; | 123 | QString list; |
130 | if(count()>0) { | 124 | if(count()>0) { |
131 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 125 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
132 | // qDebug(*it); | 126 | // qDebug(*it); |
133 | list += *it+"\n"; | 127 | list += *it+"\n"; |
134 | } | 128 | } |
135 | f.writeBlock( list, list.length() ); | 129 | f.writeBlock( list, list.length() ); |
136 | } | 130 | } |
137 | // f.close(); | 131 | // f.close(); |
138 | } | 132 | } |
139 | 133 | ||
140 | void Om3u::add(const QString &filePath) { //adds to m3u file | 134 | void Om3u::add(const QString &filePath) { //adds to m3u file |
141 | append(filePath); | 135 | append(filePath); |
142 | } | 136 | } |
143 | 137 | ||
144 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 138 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
145 | QString list, currentFile; | 139 | QString list, currentFile; |
146 | if(count()>0) { | 140 | if(count()>0) { |
147 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 141 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
148 | currentFile=*it; | 142 | currentFile=*it; |
149 | // qDebug(*it); | 143 | // qDebug(*it); |
150 | 144 | ||
151 | if( filePath != currentFile) | 145 | if( filePath != currentFile) |
152 | list += currentFile+"\n"; | 146 | list += currentFile+"\n"; |
153 | } | 147 | } |
154 | f.writeBlock( list, list.length() ); | 148 | f.writeBlock( list, list.length() ); |
155 | } | 149 | } |
156 | } | 150 | } |
157 | 151 | ||
158 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file | 152 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file |
159 | f.close(); | 153 | f.close(); |
160 | f.remove(); | 154 | f.remove(); |
161 | 155 | ||
162 | } | 156 | } |
163 | 157 | ||
164 | void Om3u::close() { //closes m3u file | 158 | void Om3u::close() { //closes m3u file |
165 | f.close(); | 159 | f.close(); |
166 | } | 160 | } |