-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 103 |
1 files changed, 36 insertions, 67 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 @@ -208,10 +208,11 @@ 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 ); @@ -264,9 +265,12 @@ void PlayListWidget::addAllToList() { if( QFileInfo( Adit.current()->file() ).exists() ) { d->selectedFiles->addToSelection( **Adit ); } } + tabWidget->setCurrentPage(0); + writeCurrentM3u(); + d->selectedFiles->first(); } void PlayListWidget::addAllMusicToList() { @@ -277,9 +281,11 @@ void PlayListWidget::addAllMusicToList() { if( QFileInfo(dit.current()->file() ).exists() ) { d->selectedFiles->addToSelection( **dit ); } } + tabWidget->setCurrentPage(0); writeCurrentM3u(); + d->selectedFiles->first(); } void PlayListWidget::addAllVideoToList() { @@ -290,9 +296,11 @@ void PlayListWidget::addAllVideoToList() { if( QFileInfo( dit.current()->file() ).exists() ) { d->selectedFiles->addToSelection( **dit ); } } + tabWidget->setCurrentPage(0); writeCurrentM3u(); + d->selectedFiles->first(); } void PlayListWidget::setDocument( const QString& fileref ) { @@ -422,13 +430,13 @@ bool PlayListWidget::last() { 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); } @@ -445,54 +453,33 @@ void PlayListWidget::setPlaylist( bool shown ) { void PlayListWidget::addSelected() { qDebug("addSelected"); + DocLnk lnk; + QString filename; switch (whichList()) { + case 0: //playlist + return; 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(); + filename=audioView->currentItem()->text(3); + // 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); - } - } - } - } - } + filename=videoView->currentItem()->text(3); // tabWidget->setCurrentPage(0); - writeCurrentM3u(); } 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() { @@ -513,40 +500,22 @@ void PlayListWidget::addToSelection( QListViewItem *it) { 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: + 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); } } |