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 @@ -41,33 +41,27 @@ #include <qdir.h> #include <qregexp.h> #include <qstring.h> #include <qtextstream.h> #include <qstringlist.h> #include <qcstring.h> //extern PlayListWidget *playList; Om3u::Om3u( const QString &filePath, int mode) : QStringList (){ -//filePath is path name to m3u //qDebug("<<<<<<<new m3u "+filePath); - f.setName(filePath); -// if(f.exists()) -// f.open( IO_ReadWrite); -// else -// f.open( IO_ReadWrite | IO_Truncate); - f.open(mode); - + f.setName(filePath); + f.open(mode); } Om3u::~Om3u(){} void Om3u::readM3u() { // qDebug("<<<<<<reading m3u "+f.name()); QTextStream t(&f); QString s; while ( !t.atEnd() ) { s=t.readLine(); qDebug(s); if( s.find( "#", 0, TRUE) == -1 ) { @@ -122,47 +116,50 @@ void Om3u::readPls() { //it's a pls file append(s); else { //if its a url if( name.right( 1 ).find( '/' ) == -1) { s += "/"; } append(s); } } } } void Om3u::write() { //writes list to m3u file - QString list; + QString list; + if(count()>0) { for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { - qDebug(*it); - list += *it+"\n"; + qDebug(*it); + list += *it+"\n"; } f.writeBlock( list, list.length() ); + } // f.close(); } void Om3u::add(const QString &filePath) { //adds to m3u file append(filePath); } void Om3u::remove(const QString &filePath) { //removes from m3u list - QString list, currentFile; + QString list, currentFile; + if(count()>0) { for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { - currentFile=*it; -// qDebug(*it); + currentFile=*it; + // qDebug(*it); - if( filePath != currentFile) + if( filePath != currentFile) list += currentFile+"\n"; } f.writeBlock( list, list.length() ); - + } } void Om3u::deleteFile(const QString &filePath) {//deletes m3u file f.close(); f.remove(); } void Om3u::close() { //closes m3u file f.close(); } |