Diffstat (limited to 'noncore/multimedia/opieplayer2/om3u.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 7183fb4..69e87e7 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -51,48 +51,50 @@ | |||
51 | Om3u::Om3u( const QString &filePath, int mode) | 51 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 52 | : QStringList (){ |
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 | t.setEncoding(QTextStream::UnicodeUTF8); | ||
63 | QString s; | 64 | QString s; |
64 | while ( !t.atEnd() ) { | 65 | while ( !t.atEnd() ) { |
65 | s=t.readLine(); | 66 | s=t.readLine(); |
66 | // qDebug(s); | 67 | // qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 68 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 69 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 70 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 71 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 72 | QString name = f.baseName(); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 73 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 74 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 75 | append(s); |
75 | // qDebug(s); | 76 | // qDebug(s); |
76 | } else { // is url | 77 | } else { // is url |
77 | QString name; | 78 | QString name; |
78 | name = s; | 79 | name = s; |
79 | append(name); | 80 | append(name); |
80 | } | 81 | } |
81 | } | 82 | } |
82 | } | 83 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | void Om3u::readPls() { //it's a pls file | 86 | void Om3u::readPls() { //it's a pls file |
86 | QTextStream t( &f ); | 87 | QTextStream t( &f ); |
88 | t.setEncoding(QTextStream::UnicodeUTF8); | ||
87 | QString s; | 89 | QString s; |
88 | while ( !t.atEnd() ) { | 90 | while ( !t.atEnd() ) { |
89 | s = t.readLine(); | 91 | s = t.readLine(); |
90 | if( s.left(4) == "File" ) { | 92 | if( s.left(4) == "File" ) { |
91 | s = s.right( s.length() - s.find("=",0,true)-1 ); | 93 | s = s.right( s.length() - s.find("=",0,true)-1 ); |
92 | s = s.stripWhiteSpace(); | 94 | s = s.stripWhiteSpace(); |
93 | s.replace( QRegExp( "%20" )," "); | 95 | s.replace( QRegExp( "%20" )," "); |
94 | // qDebug( "adding " + s + " to playlist" ); | 96 | // qDebug( "adding " + s + " to playlist" ); |
95 | // numberofentries=2 | 97 | // numberofentries=2 |
96 | // File1=http | 98 | // File1=http |
97 | // Title | 99 | // Title |
98 | // Length | 100 | // Length |
@@ -112,30 +114,31 @@ void Om3u::readPls() { //it's a pls file | |||
112 | else { //if its a url | 114 | else { //if its a url |
113 | // if( name.right( 1 ).find( '/' ) == -1) { | 115 | // if( name.right( 1 ).find( '/' ) == -1) { |
114 | // s += "/"; | 116 | // s += "/"; |
115 | // } | 117 | // } |
116 | append(s); | 118 | append(s); |
117 | } | 119 | } |
118 | } | 120 | } |
119 | } | 121 | } |
120 | } | 122 | } |
121 | 123 | ||
122 | void Om3u::write() { //writes list to m3u file | 124 | void Om3u::write() { //writes list to m3u file |
123 | QString list; | 125 | QString list; |
126 | QTextStream t(&f); | ||
127 | t.setEncoding(QTextStream::UnicodeUTF8); | ||
124 | if(count()>0) { | 128 | if(count()>0) { |
125 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 129 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
126 | // qDebug(*it); | 130 | // qDebug(*it); |
127 | list += *it+"\n"; | 131 | t << *it << "\n"; |
128 | } | 132 | } |
129 | f.writeBlock( list, list.length() ); | ||
130 | } | 133 | } |
131 | // f.close(); | 134 | // f.close(); |
132 | } | 135 | } |
133 | 136 | ||
134 | void Om3u::add(const QString &filePath) { //adds to m3u file | 137 | void Om3u::add(const QString &filePath) { //adds to m3u file |
135 | append(filePath); | 138 | append(filePath); |
136 | } | 139 | } |
137 | 140 | ||
138 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 141 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
139 | QString list, currentFile; | 142 | QString list, currentFile; |
140 | if(count()>0) { | 143 | if(count()>0) { |
141 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 144 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |