-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 16 |
2 files changed, 8 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 975dec3..2019b3a 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp @@ -101,34 +101,33 @@ const DocLnk *PlayListSelection::current() { return NULL; } void PlayListSelection::addToSelection( const DocLnk &lnk ) { PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); QListViewItem *current = selectedItem(); if ( current ) item->moveItem( current ); setSelected( item, TRUE ); ensureItemVisible( selectedItem() ); } void PlayListSelection::removeSelected() { QListViewItem *item = selectedItem(); - if ( item ) - delete item; + delete item; setSelected( currentItem(), TRUE ); ensureItemVisible( selectedItem() ); } void PlayListSelection::moveSelectedUp() { QListViewItem *item = selectedItem(); if ( item && item->itemAbove() ) item->itemAbove()->moveItem( item ); ensureItemVisible( selectedItem() ); } void PlayListSelection::moveSelectedDown() { QListViewItem *item = selectedItem(); if ( item && item->itemBelow() ) diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 86b3424..ac52b07 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -178,33 +178,33 @@ void PlayListWidget::writeDefaultPlaylist() { config.setGroup( "PlayList" ); QString filename=QPEApplication::documentDir() + "/default.m3u"; QString currentString = config.readEntry( "CurrentPlaylist", filename); if( currentString == filename) { Om3u *m3uList; // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); if( d->selectedFiles->first() ) { m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); do { // qDebug(d->selectedFiles->current()->file()); m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); m3uList->write(); m3uList->close(); - if(m3uList) delete m3uList; + delete m3uList; } } } void PlayListWidget::addToSelection( const DocLnk& lnk ) { d->setDocumentUsed = FALSE; if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) { d->selectedFiles->addToSelection( lnk ); } // writeCurrentM3u(); } void PlayListWidget::clearList() { @@ -671,35 +671,33 @@ void PlayListWidget::openFile() { d->selectedFiles->setSelectedItem( lnk.name()); } else if( filename.right( 3) == "m3u" ) { readm3u( filename ); } else if( filename.right(3) == "pls" ) { readPls( filename ); } else { lnk.setName( QFileInfo(filename).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); writeCurrentM3u(); d->selectedFiles->setSelectedItem( lnk.name()); } } - if( fileDlg ) { - delete fileDlg; - } + delete fileDlg; } /* reads m3u and shows files/urls to playlist widget */ void PlayListWidget::readm3u( const QString &filename ) { qDebug( "read m3u filename " + filename ); Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); m3uList->readM3u(); DocLnk lnk; for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { s = *it; // qDebug("reading "+ s); if(s.left(4)=="http") { @@ -721,33 +719,33 @@ void PlayListWidget::readm3u( const QString &filename ) { lnk.setFile( s); // lnk.setIcon(MimeType(s).pixmap() ); // lnk.setIcon("SoundPlayer"); } } d->selectedFiles->addToSelection( lnk ); } Config config( "OpiePlayer" ); config.setGroup( "PlayList" ); config.writeEntry("CurrentPlaylist",filename); config.write(); currentPlayList=filename; // m3uList->write(); m3uList->close(); - if(m3uList) delete m3uList; + delete m3uList; d->selectedFiles->setSelectedItem( s); setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); } /* reads pls and adds files/urls to playlist */ void PlayListWidget::readPls( const QString &filename ) { qDebug( "pls filename is " + filename ); Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); m3uList->readPls(); @@ -769,57 +767,57 @@ void PlayListWidget::readPls( const QString &filename ) { lnk.setName( name ); if( s.at( s.length() - 4) == '.') {// if this is probably a file lnk.setFile( s ); } else { //if its a url // if( name.right( 1 ).find( '/' ) == -1) { // s += "/"; // } lnk.setFile( s ); } lnk.setType( "audio/x-mpegurl" ); lnk.writeLink(); d->selectedFiles->addToSelection( lnk ); } m3uList->close(); - if(m3uList) delete m3uList; + delete m3uList; } /* writes current playlist to current m3u file */ void PlayListWidget::writeCurrentM3u() { qDebug("writing to current m3u"); Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); Om3u *m3uList; m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); if( d->selectedFiles->first()) { do { // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); m3uList->write(); m3uList->close(); - if(m3uList) delete m3uList; + delete m3uList; } } /* writes current playlist to m3u file */ void PlayListWidget::writem3u() { InputDialog *fileDlg; fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); fileDlg->exec(); QString name, filename, list; Om3u *m3uList; if( fileDlg->result() == 1 ) { name = fileDlg->text(); // qDebug( filename ); @@ -829,35 +827,35 @@ void PlayListWidget::writem3u() { } if( name.right( 3 ) != "m3u" ) { filename = QPEApplication::documentDir() + "/" +name+".m3u"; } if( d->selectedFiles->first()) { m3uList = new Om3u(filename, IO_ReadWrite); do { m3uList->add( d->selectedFiles->current()->file()); } while ( d->selectedFiles->next() ); // qDebug( list ); m3uList->write(); m3uList->close(); - if(m3uList) delete m3uList; + delete m3uList; - if(fileDlg) delete fileDlg; + delete fileDlg; DocLnk lnk; lnk.setFile( filename); lnk.setIcon("opieplayer2/playlist2"); lnk.setName( name); //sets file name // qDebug(filename); Config config( "OpiePlayer" ); config.setGroup( "PlayList" ); config.writeEntry("CurrentPlaylist",filename); currentPlayList=filename; if(!lnk.writeLink()) { qDebug("Writing doclink did not work"); } |