Diffstat (limited to 'noncore/multimedia/opieplayer2/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 0be727b..039f3b1 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -47,21 +47,15 @@ | |||
47 | #include <qcstring.h> | 47 | #include <qcstring.h> |
48 | 48 | ||
49 | //extern PlayListWidget *playList; | 49 | //extern PlayListWidget *playList; |
50 | 50 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 51 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 52 | : QStringList (){ |
53 | //filePath is path name to m3u | ||
54 | //qDebug("<<<<<<<new m3u "+filePath); | 53 | //qDebug("<<<<<<<new m3u "+filePath); |
55 | f.setName(filePath); | 54 | f.setName(filePath); |
56 | // if(f.exists()) | 55 | f.open(mode); |
57 | // f.open( IO_ReadWrite); | ||
58 | // else | ||
59 | // f.open( IO_ReadWrite | IO_Truncate); | ||
60 | f.open(mode); | ||
61 | |||
62 | } | 56 | } |
63 | 57 | ||
64 | Om3u::~Om3u(){} | 58 | Om3u::~Om3u(){} |
65 | 59 | ||
66 | void Om3u::readM3u() { | 60 | void Om3u::readM3u() { |
67 | // qDebug("<<<<<<reading m3u "+f.name()); | 61 | // qDebug("<<<<<<reading m3u "+f.name()); |
@@ -128,36 +122,39 @@ void Om3u::readPls() { //it's a pls file | |||
128 | } | 122 | } |
129 | } | 123 | } |
130 | } | 124 | } |
131 | } | 125 | } |
132 | 126 | ||
133 | void Om3u::write() { //writes list to m3u file | 127 | void Om3u::write() { //writes list to m3u file |
134 | QString list; | 128 | QString list; |
129 | if(count()>0) { | ||
135 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
136 | qDebug(*it); | 131 | qDebug(*it); |
137 | list += *it+"\n"; | 132 | list += *it+"\n"; |
138 | } | 133 | } |
139 | f.writeBlock( list, list.length() ); | 134 | f.writeBlock( list, list.length() ); |
135 | } | ||
140 | // f.close(); | 136 | // f.close(); |
141 | } | 137 | } |
142 | 138 | ||
143 | void Om3u::add(const QString &filePath) { //adds to m3u file | 139 | void Om3u::add(const QString &filePath) { //adds to m3u file |
144 | append(filePath); | 140 | append(filePath); |
145 | } | 141 | } |
146 | 142 | ||
147 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 143 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
148 | QString list, currentFile; | 144 | QString list, currentFile; |
145 | if(count()>0) { | ||
149 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 146 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
150 | currentFile=*it; | 147 | currentFile=*it; |
151 | // qDebug(*it); | 148 | // qDebug(*it); |
152 | 149 | ||
153 | if( filePath != currentFile) | 150 | if( filePath != currentFile) |
154 | list += currentFile+"\n"; | 151 | list += currentFile+"\n"; |
155 | } | 152 | } |
156 | f.writeBlock( list, list.length() ); | 153 | f.writeBlock( list, list.length() ); |
157 | 154 | } | |
158 | } | 155 | } |
159 | 156 | ||
160 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 157 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file |
161 | f.close(); | 158 | f.close(); |
162 | f.remove(); | 159 | f.remove(); |
163 | 160 | ||