-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index ae03ec8..de36551 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -348,414 +348,416 @@ void PlayListWidget::writeConfig( Config& cfg ) const { // if this link does exist, add it so we have the file // next time... if ( !QFile::exists( lnk->linkFile() ) ) { // the way writing lnks doesn't really check for out // of disk space, but check it anyway. if ( !lnk->writeLink() ) { QMessageBox::critical( 0, tr("Out of space"), tr( "There was a problem saving " "the playlist.\n" "Your playlist " "may be missing some entries\n" "the next time you start it." ) ); } } noOfFiles++; } } while ( d->selectedFiles->next() ); cfg.writeEntry("NumberOfFiles", noOfFiles ); } void PlayListWidget::addToSelection( const DocLnk& lnk ) { qDebug("add"); d->setDocumentUsed = FALSE; if ( mediaPlayerState->playlist() ) d->selectedFiles->addToSelection( lnk ); else mediaPlayerState->setPlaying( TRUE ); } void PlayListWidget::clearList() { while ( first() ) d->selectedFiles->removeSelected(); } void PlayListWidget::addAllToList() { DocLnkSet files; Global::findDocuments(&files, "video/*;audio/*"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); } void PlayListWidget::addAllMusicToList() { DocLnkSet files; Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); } void PlayListWidget::addAllVideoToList() { DocLnkSet files; Global::findDocuments(&files, "video/*"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); } void PlayListWidget::setDocument(const QString& fileref) { if ( fileref.isNull() ) { QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); return; } if ( mediaPlayerState->playlist() ) addToSelection( DocLnk( fileref ) ); else { d->setDocumentUsed = TRUE; if ( d->current ) delete d->current; d->current = new DocLnk( fileref ); } mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } void PlayListWidget::setActiveWindow() { // When we get raised we need to ensure that it switches views char origView = mediaPlayerState->view(); mediaPlayerState->setView( 'l' ); // invalidate mediaPlayerState->setView( origView ); // now switch back } void PlayListWidget::useSelectedDocument() { d->setDocumentUsed = FALSE; } const DocLnk *PlayListWidget::current() { // qDebug("in Playlist widget ::current"); if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); } else if ( d->setDocumentUsed && d->current ) { return d->current; } else { return d->files->selected(); } } bool PlayListWidget::prev() { if ( mediaPlayerState->playlist() ) { if ( mediaPlayerState->shuffled() ) { const DocLnk *cur = current(); int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); for ( int i = 0; i < j; i++ ) { if ( !d->selectedFiles->next() ) d->selectedFiles->first(); } if ( cur == current() ) if ( !d->selectedFiles->next() ) d->selectedFiles->first(); return TRUE; } else { if ( !d->selectedFiles->prev() ) { if ( mediaPlayerState->looping() ) { return d->selectedFiles->last(); } else { return FALSE; } } return TRUE; } } else { return mediaPlayerState->looping(); } } bool PlayListWidget::next() { if ( mediaPlayerState->playlist() ) { if ( mediaPlayerState->shuffled() ) { return prev(); } else { if ( !d->selectedFiles->next() ) { if ( mediaPlayerState->looping() ) { return d->selectedFiles->first(); } else { return FALSE; } } return TRUE; } } else { return mediaPlayerState->looping(); } } bool PlayListWidget::first() { if ( mediaPlayerState->playlist() ) return d->selectedFiles->first(); else return mediaPlayerState->looping(); } bool PlayListWidget::last() { if ( mediaPlayerState->playlist() ) return d->selectedFiles->last(); else return mediaPlayerState->looping(); } void PlayListWidget::saveList() { QString filename; InputDialog *fileDlg; fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { filename = fileDlg->LineEdit1->text();//+".playlist"; qDebug("saving playlist "+filename+".playlist"); // DocLnk *lnk; // lnk.setName( filename); //sets file name // // lnk.setComment(title); // lnk.setFile( filename+".playlist"); //sets File property // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D // lnk.setIcon("MPEGPlayer"); // if(!lnk.writeLink()) // qDebug("Writing doclink did not work"); Config cfg( filename +".playlist"); writeConfig( cfg ); } DocLnk lnk; lnk.setName( filename); //sets file name // lnk.setComment(title); lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D lnk.setIcon("MPEGPlayer"); if(!lnk.writeLink()) qDebug("Writing doclink did not work"); if(fileDlg) delete fileDlg; } void PlayListWidget::loadList( const DocLnk & lnk) { qDebug("load list "+ lnk.name()+".playlist"); clearList(); Config cfg( lnk.name()+".playlist"); readConfig(cfg); tabWidget->setCurrentPage(0); setCaption("OpiePlayer: "+lnk.name()); } void PlayListWidget::setPlaylist( bool shown ) { if ( shown ) d->playListFrame->show(); else d->playListFrame->hide(); } void PlayListWidget::setView( char view ) { if ( view == 'l' ) showMaximized(); else hide(); } void PlayListWidget::addSelected() { switch (tabWidget->currentPageIndex()) { case 0: //playlist break; case 1: { //audio addToSelection( audioView->selectedItem() ); } break; case 2: { // video addToSelection( videoView->selectedItem() ); } break; }; } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } void PlayListWidget::playIt( QListViewItem *it) { // d->setDocumentUsed = FALSE; mediaPlayerState->setPlaying(TRUE); } void PlayListWidget::addToSelection( QListViewItem *it) { d->setDocumentUsed = FALSE; if(it) { // qDebug("add to selection"); switch (tabWidget->currentPageIndex()) { case 1: { // qDebug("case 1"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { // qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; case 2: { // qDebug("case 2"); QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) { // qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; case 0: break; }; tabWidget->setCurrentPage(0); // mediaPlayerState->setPlaying( TRUE ); } } void PlayListWidget::tabChanged(QWidget *widg) { switch ( tabWidget->currentPageIndex()) { case 0: { if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(TRUE); d->tbAddToList->setEnabled(FALSE); } break; case 1: { if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; case 2: { if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; case 3: { if( tbDeletePlaylist->isHidden()) tbDeletePlaylist->show(); playLists->reread(); } break; }; } /* list is right clicked*/ void PlayListWidget::fauxPlay(QListViewItem *it) { switch (tabWidget->currentPageIndex()) { case 0: //playlist break; case 1: { //audio QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { // qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; case 2: { // video QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) { // qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; }; mediaPlayerState->setPlaying( TRUE ); // tabWidget->setCurrentPage(0); d->selectedFiles->removeSelected(); } /* play button is pressed*/ void PlayListWidget::btnPlay(bool b) { // this is fugly switch ( tabWidget->currentPageIndex()) { case 0: { mediaPlayerState->setPlaying(b); } break; case 1: { addToSelection( audioView->selectedItem() ); mediaPlayerState->setPlaying(b); + qApp->processEvents(); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(1); } break; case 2: { addToSelection( videoView->selectedItem() ); mediaPlayerState->setPlaying(b); + qApp->processEvents(); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(2); } break; }; } void PlayListWidget::deletePlaylist() { switch( QMessageBox::information( this, (tr("Remove Playlist?")), (tr("You really want to delete\nthis playlist?")), (tr("Yes")), (tr("No")), 0 )){ case 0: // Yes clicked, QFile().remove(playLists->selected()->file()); QFile().remove(playLists->selected()->linkFile()); playLists->reread(); break; case 1: // Cancel break; }; } |