-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 147 |
1 files changed, 58 insertions, 89 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 8e88e9b..a6a9eca 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -204,18 +204,19 @@ void PlayListWidget::writeDefaultPlaylist() { } } } void PlayListWidget::addToSelection( const DocLnk& lnk ) { d->setDocumentUsed = FALSE; if ( mediaPlayerState->playlist() ) { if( QFileInfo( lnk.file() ).exists() || - lnk.file().left(4) == "http" ) + lnk.file().left(4) == "http" ) { d->selectedFiles->addToSelection( lnk ); + } // writeCurrentM3u(); } else mediaPlayerState->setPlaying( TRUE ); } void PlayListWidget::clearList() { @@ -260,43 +261,50 @@ void PlayListWidget::addAllToList() { DocLnkSet filesAll; Global::findDocuments(&filesAll, "video/*;"+audioMimes); QListIterator<DocLnk> Adit( filesAll.children() ); for ( ; Adit.current(); ++Adit ) { if( QFileInfo( Adit.current()->file() ).exists() ) { d->selectedFiles->addToSelection( **Adit ); } } - writeCurrentM3u(); + tabWidget->setCurrentPage(0); + + writeCurrentM3u(); + d->selectedFiles->first(); } void PlayListWidget::addAllMusicToList() { if(!audioScan) scanForAudio(); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { if( QFileInfo(dit.current()->file() ).exists() ) { d->selectedFiles->addToSelection( **dit ); } } - writeCurrentM3u(); + tabWidget->setCurrentPage(0); + writeCurrentM3u(); + d->selectedFiles->first(); } void PlayListWidget::addAllVideoToList() { if(!videoScan) scanForVideo(); QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) { if( QFileInfo( dit.current()->file() ).exists() ) { d->selectedFiles->addToSelection( **dit ); } } + tabWidget->setCurrentPage(0); writeCurrentM3u(); + d->selectedFiles->first(); } void PlayListWidget::setDocument( const QString& fileref ) { qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); fromSetDocument = TRUE; if ( fileref.isNull() ) { QMessageBox::warning( this, tr( "Invalid File" ), @@ -418,21 +426,21 @@ bool PlayListWidget::last() { void PlayListWidget::saveList() { writem3u(); } void PlayListWidget::loadList( const DocLnk & lnk) { QString name = lnk.name(); - qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); + // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); if( name.length()>0) { setCaption("OpiePlayer: "+name); - qDebug("<<<<<<<<<<<<load list "+ lnk.file()); +// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); clearList(); readm3u(lnk.file()); tabWidget->setCurrentPage(0); } } void PlayListWidget::setPlaylist( bool shown ) { @@ -440,63 +448,42 @@ void PlayListWidget::setPlaylist( bool shown ) { d->playListFrame->show(); } else { d->playListFrame->hide(); } } void PlayListWidget::addSelected() { - qDebug("addSelected"); - switch (whichList()) { - case 0: //playlist - break; - case 1: { //audio - QListViewItemIterator it( audioView ); - // iterate through all items of the listview - for ( ; it.current(); ++it ) { - if ( it.current()->isSelected() ) { - QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) { - if( dit.current()->name() == it.current()->text(0) ) { - if( QFileInfo( dit.current()->file()).exists()) { - d->selectedFiles->addToSelection( **dit ); - audioView->setSelected( it.current(),FALSE); - } - } - } - } - } -// tabWidget->setCurrentPage(0); - writeCurrentM3u(); - d->selectedFiles->next(); - } - break; - case 2: { // video - QListViewItemIterator it( videoView ); - // iterate through all items of the listview - for ( ; it.current(); ++it ) { - if ( it.current()->isSelected() ) { - QListIterator<DocLnk> dit( vFiles.children() ); - for ( ; dit.current(); ++dit ) { - if( dit.current()->name() == it.current()->text(0) ) { - if(QFileInfo( dit.current()->file()).exists()) { - d->selectedFiles->addToSelection( **dit ); - videoView->setSelected( it.current(),FALSE); - } - } - } - } - } -// tabWidget->setCurrentPage(0); - writeCurrentM3u(); + qDebug("addSelected"); + DocLnk lnk; + QString filename; + switch (whichList()) { + + case 0: //playlist + return; + break; + case 1: { //audio + filename=audioView->currentItem()->text(3); + // d->selectedFiles->next(); + } + break; - } - break; - }; + case 2: { // video + filename=videoView->currentItem()->text(3); + // tabWidget->setCurrentPage(0); + + } + break; + }; + lnk.setName( QFileInfo(filename).baseName() ); //sets name + lnk.setFile( filename ); //sets file name + d->selectedFiles->addToSelection( lnk); + tabWidget->setCurrentPage(0); + writeCurrentM3u(); } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); writeCurrentM3u(); } @@ -505,55 +492,37 @@ void PlayListWidget::playIt( QListViewItem *it) { if(!it) return; mediaPlayerState->setPlaying(FALSE); mediaPlayerState->setPlaying(TRUE); d->selectedFiles->unSelect(); } void PlayListWidget::addToSelection( QListViewItem *it) { - d->setDocumentUsed = FALSE; + d->setDocumentUsed = FALSE; - if(it) { - switch ( whichList()) { - case 1: { - QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) { - if( dit.current()->name() == it->text(0)) { - if(QFileInfo( dit.current()->file()).exists()) { - d->selectedFiles->addToSelection( **dit ); -// qDebug("blah "+ dit.current()->name()); -// d->selectedFiles->setSelectedItem( dit.current()->name()); - } - } - } - writeCurrentM3u(); - } - break; - case 2: { - QListIterator<DocLnk> dit( vFiles.children() ); - for ( ; dit.current(); ++dit ) { - if( dit.current()->name() == it->text(0)) { - if( QFileInfo( dit.current()->file()).exists() ) { - d->selectedFiles->addToSelection( **dit ); -// qDebug("blah "+ dit.current()->name()); -// d->selectedFiles->setSelectedItem( dit.current()->name()); - } - } - } - writeCurrentM3u(); - - } - break; - case 0: - break; - }; - tabWidget->setCurrentPage(0); + if(it) { + switch ( whichList()) { + case 0: //playlist + return; + break; + }; + // case 1: { + DocLnk lnk; + QString filename; + + filename=it->text(3); + lnk.setName( QFileInfo(filename).baseName() ); //sets name + lnk.setFile( filename ); //sets file name + d->selectedFiles->addToSelection( lnk); + + writeCurrentM3u(); + tabWidget->setCurrentPage(0); - } + } } void PlayListWidget::tabChanged(QWidget *) { switch ( whichList()) { case 0: { @@ -914,17 +883,17 @@ void PlayListWidget::writem3u() { filename = QPEApplication::documentDir() + "/" + name; } if( name.right( 3 ) != "m3u" ) { filename = QPEApplication::documentDir() + "/" +name+".m3u"; } if( d->selectedFiles->first()) { - m3uList = new Om3u(filename, IO_ReadWrite); + m3uList = new Om3u(filename, IO_ReadWrite); do { m3uList->add( d->selectedFiles->current()->file()); } while ( d->selectedFiles->next() ); // qDebug( list ); m3uList->write(); m3uList->close(); |