author | llornkcor <llornkcor> | 2002-12-10 11:58:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-10 11:58:11 (UTC) |
commit | 92da6d6ed82230c25d71379eaffbcd222464726b (patch) (side-by-side diff) | |
tree | 57a524c60e9a32b0195aa2fa08e484c533e4ddf7 | |
parent | f468c3bc69655aefa0ec5783405355dd3dde4afc (diff) | |
download | opie-92da6d6ed82230c25d71379eaffbcd222464726b.zip opie-92da6d6ed82230c25d71379eaffbcd222464726b.tar.gz opie-92da6d6ed82230c25d71379eaffbcd222464726b.tar.bz2 |
moving to playlistview after adding to it is annoying some people and me sometimes. try this for now
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 27a3286..cba7b6d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -112,192 +112,196 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), this,SLOT( playIt( QListViewItem *) ) ); connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), this,SLOT( playIt( QListViewItem *) ) ); connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); connect ( gammaSlider, SIGNAL( valueChanged( int ) ), &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); // see which skins are installed populateSkinsMenu(); initializeStates(); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); loadList(DocLnk( currentPlaylist ) ); } PlayListWidget::~PlayListWidget() { delete d; } void PlayListWidget::initializeStates() { d->tbPlay->setOn( mediaPlayerState.isPlaying() ); d->tbLoop->setOn( mediaPlayerState.isLooping() ); d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); d->playListFrame->show(); } void PlayListWidget::writeDefaultPlaylist() { Config config( "OpiePlayer" ); 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(); 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() { while ( first() ) { d->selectedFiles->removeSelected(); } + Config cfg( "OpiePlayer" ); + cfg.setGroup("PlayList"); + cfg.writeEntry("CurrentPlaylist","default"); + setCaption("OpiePlayer"); } void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { switch (mouse) { case LeftButton: break; case RightButton: { QPopupMenu m; m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); m.exec( QCursor::pos() ); } break; } } void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { switch (mouse) { case LeftButton: break; case RightButton: { QPopupMenu m; m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); m.exec( QCursor::pos() ); } break; } } void PlayListWidget::addAllToList() { // QTime t; // t.start(); audioView->populateView(); QListViewItemIterator audioIt( audioView ); DocLnk lnk; QString filename; // iterate through all items of the listview for ( ; audioIt.current(); ++audioIt ) { filename = audioIt.current()->text(3); lnk.setName( QFileInfo(filename).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); } videoView->populateView(); QListViewItemIterator videoIt( videoView ); for ( ; videoIt.current(); ++videoIt ) { filename = videoIt.current()->text(3); lnk.setName( QFileInfo(filename).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); } // d->selectedFiles->addToSelection( ); // if ( it.current()->isSelected() ) // lst->append( audioIt.current() ); // } // if(!audioScan) // scanForAudio(); // if(!videoScan) // scanForVideo(); // 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 ); // } // } // qDebug("elapsed time %d", t.elapsed() ); tabWidget->setCurrentPage(0); writeCurrentM3u(); d->selectedFiles->first(); } void PlayListWidget::addAllMusicToList() { audioView->populateView(); QListViewItemIterator audioIt( audioView ); @@ -399,228 +403,228 @@ const DocLnk *PlayListWidget::current() const { // this is fugly d->selectedFiles->first(); lnk = d->selectedFiles->current(); } assert( lnk ); return lnk; } bool PlayListWidget::prev() { if ( mediaPlayerState.isShuffled() ) { 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.isLooping() ) { return d->selectedFiles->last(); } else { return FALSE; } } return TRUE; } } bool PlayListWidget::next() { //qDebug("<<<<<<<<<<<<next()"); if ( mediaPlayerState.isShuffled() ) { return prev(); } else { if ( !d->selectedFiles->next() ) { if ( mediaPlayerState.isLooping() ) { return d->selectedFiles->first(); } else { return FALSE; } } return TRUE; } } bool PlayListWidget::first() { return d->selectedFiles->first(); } bool PlayListWidget::last() { return d->selectedFiles->last(); } void PlayListWidget::saveList() { writem3u(); } void PlayListWidget::loadList( const DocLnk & lnk) { QString name = lnk.name(); // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); if( name.length()>0) { setCaption("OpiePlayer: "+name); // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); clearList(); readm3u(lnk.file()); tabWidget->setCurrentPage(0); } } void PlayListWidget::addSelected() { assert( inFileListMode() ); QListViewItemIterator it( currentFileListView ); for ( ; it.current(); ++it ) if ( it.current()->isSelected() ) { QString filename = it.current()->text(3); DocLnk lnk; lnk.setName( QFileInfo( filename ).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk ); } currentFileListView->clearSelection(); - tabWidget->setCurrentPage( 0 ); +// tabWidget->setCurrentPage( 0 ); writeCurrentM3u(); } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); writeCurrentM3u(); } 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; if(it) { if ( currentTab() == CurrentPlayList ) return; // 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); +// tabWidget->setCurrentPage(0); } } void PlayListWidget::tabChanged(QWidget *) { d->tbPlay->setEnabled( true ); disconnect( audioView, SIGNAL( itemsSelected( bool ) ), d->tbPlay, SLOT( setEnabled( bool ) ) ); disconnect( videoView, SIGNAL( itemsSelected( bool ) ), d->tbPlay, SLOT( setEnabled( bool ) ) ); currentFileListView = 0; switch ( currentTab() ) { case CurrentPlayList: { if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(TRUE); d->tbAddToList->setEnabled(FALSE); d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); } break; case AudioFiles: { audioView->populateView(); if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); connect( audioView, SIGNAL( itemsSelected( bool ) ), d->tbPlay, SLOT( setEnabled( bool ) ) ); d->tbPlay->setEnabled( audioView->hasSelection() ); currentFileListView = audioView; } break; case VideoFiles: { videoView->populateView(); if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); connect( videoView, SIGNAL( itemsSelected( bool ) ), d->tbPlay, SLOT( setEnabled( bool ) ) ); d->tbPlay->setEnabled( videoView->hasSelection() ); currentFileListView = videoView; } break; case PlayLists: { if( tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->show(); } playLists->reread(); d->tbAddToList->setEnabled(FALSE); d->tbPlay->setEnabled( false ); } break; }; } void PlayListWidget::btnPlay(bool b) { // mediaPlayerState->setPlaying(false); mediaPlayerState.setPlaying(b); insanityBool=FALSE; } 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->selectedDocument().file()); QFile().remove(playLists->selectedDocument().linkFile()); playLists->reread(); break; case 1: // Cancel break; }; |