-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 6 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.h | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 8 |
3 files changed, 11 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 756e3b4..6259b3f 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -84,100 +84,104 @@ void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { if ( event->state() == QMouseEvent::LeftButton ) { QListViewItem *currentItem = selectedItem(); QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); if ( currentItem && currentItem->itemAbove() == itemUnder ) moveSelectedUp(); else if ( currentItem && currentItem->itemBelow() == itemUnder ) moveSelectedDown(); } } const DocLnk *PlayListSelection::current() { PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); if ( item ) return item->file(); 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; 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() ) item->moveItem( item->itemBelow() ); ensureItemVisible( selectedItem() ); } bool PlayListSelection::prev() { QListViewItem *item = selectedItem(); if ( item && item->itemAbove() ) setSelected( item->itemAbove(), TRUE ); else return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } - bool PlayListSelection::next() { QListViewItem *item = selectedItem(); if ( item && item->itemBelow() ) setSelected( item->itemBelow(), TRUE ); else return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::first() { QListViewItem *item = firstChild(); if ( item ) setSelected( item, TRUE ); else return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::last() { QListViewItem *prevItem = NULL; QListViewItem *item = firstChild(); while ( ( item = item->nextSibling() ) ) prevItem = item; if ( prevItem ) setSelected( prevItem, TRUE ); else return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } +void PlayListSelection::unSelect() +{ + QListViewItem *item = selectedItem(); + setSelected( currentItem(), FALSE); +}
\ No newline at end of file diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index b0d249c..ba37271 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h @@ -1,60 +1,61 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef PLAY_LIST_SELECTION_H #define PLAY_LIST_SELECTION_H #include <qlist.h> #include <qlistview.h> #include <qpe/applnk.h> class PlayListSelection : public QListView { Q_OBJECT public: PlayListSelection( QWidget *parent, const char *name=0 ); ~PlayListSelection(); const DocLnk *current(); // retrieve the current playlist entry (media file link) public slots: void addToSelection( const DocLnk & ); // Add a media file to the playlist void removeSelected(); // Remove a media file from the playlist void moveSelectedUp(); // Move the media file up the playlist so it is played earlier void moveSelectedDown(); // Move the media file down the playlist so it is played later + void unSelect(); bool prev(); bool next(); bool first(); bool last(); protected: virtual void contentsMouseMoveEvent(QMouseEvent *); /* #ifdef USE_PLAYLIST_BACKGROUND */ virtual void drawBackground( QPainter *p, const QRect &r ); virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; /* #endif */ private: QList<DocLnk> selectedList; const DocLnk *lnk; }; #endif // PLAY_LIST_SELECTION_H diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index cf665c8..db6533a 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -110,129 +110,129 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) // menuTimer = new QTimer( this ,"menu timer"), // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); setBackgroundMode( PaletteButton ); setCaption( tr("OpiePlayer") ); setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); setToolBarsMovable( FALSE ); // Create Toolbar QPEToolBar *toolbar = new QPEToolBar( this ); toolbar->setHorizontalStretchable( TRUE ); // Create Menubar QPEMenuBar *menu = new QPEMenuBar( toolbar ); menu->setMargin( 0 ); QPEToolBar *bar = new QPEToolBar( this ); bar->setLabel( tr( "Play Operations" ) ); // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", // this , SLOT( addSelected()) ); tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); tbDeletePlaylist->setFlat(TRUE); tbDeletePlaylist->setFixedSize(20,20); connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", this , SLOT(addSelected()) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", this , SLOT( btnPlay(bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); tbDeletePlaylist->hide(); QPopupMenu *pmPlayList = new QPopupMenu( this ); menu->insertItem( tr( "File" ), pmPlayList ); new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); QPopupMenu *pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); fullScreenButton->addTo(pmView); scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); scaleButton->addTo(pmView); QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); - tabWidget = new QTabWidget( hbox6, "tabWidget" ); + tabWidget = new QTabWidget( hbox6, "tabWidget" ); tabWidget->setTabShape(QTabWidget::Triangular); QWidget *pTab; pTab = new QWidget( tabWidget, "pTab" ); // playlistView = new QListView( pTab, "playlistview" ); // playlistView->setMinimumSize(236,260); tabWidget->insertTab( pTab,"Playlist"); // Add the playlist area QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); d->playListFrame = vbox3; d->playListFrame ->setMinimumSize(235,260); QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); d->selectedFiles = new PlayListSelection( hbox2); QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); audioView = new QListView( aTab, "Audioview" ); audioView->setMinimumSize(233,260); audioView->addColumn( "Title",140); audioView->addColumn("Size", -1); audioView->addColumn("Media",-1); audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); tabWidget->insertTab(aTab,"Audio"); QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); // audioView Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); QString storage; for ( ; dit.current(); ++dit ) { QListViewItem * newItem; if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; else storage="RAM"; if ( QFile( dit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); } } // videowidget @@ -421,140 +421,140 @@ 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) { fromSetDocument = TRUE; if ( fileref.isNull() ) { QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); return; } // qDebug("setDocument "+fileref); if(fileref.find("playlist",0,TRUE) == -1) { clearList(); addToSelection( DocLnk( fileref ) ); d->setDocumentUsed = TRUE; mediaPlayerState->setPlaying( FALSE ); qApp->processEvents(); mediaPlayerState->setPlaying( TRUE ); qApp->processEvents(); setCaption("OpiePlayer"); } else { //is playlist clearList(); loadList(DocLnk(fileref)); d->selectedFiles->first(); } } 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() { // this is fugly // if( fromSetDocument) { // qDebug("from setDoc"); // DocLnkSet files; // Global::findDocuments(&files, "video/*;audio/*"); // QListIterator<DocLnk> dit( files.children() ); // for ( ; dit.current(); ++dit ) { // if(dit.current()->linkFile() == setDocFileRef) { -// qDebug(setDocFileRef); +// qDebug(setDocFileRef); // return dit; // } // } // } else // qDebug("current"); // switch (tabWidget->currentPageIndex()) { // case 0: //playlist // { qDebug("playlist"); if ( mediaPlayerState->playlist() ) { - return d->selectedFiles->current(); + return d->selectedFiles->current(); } else if ( d->setDocumentUsed && d->current ) { return d->current; } else { return d->files->selected(); } // } // break; // case 1://audio // { // qDebug("audioView"); // Global::findDocuments(&files, "audio/*"); // QListIterator<DocLnk> dit( files.children() ); // for ( ; dit.current(); ++dit ) { // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { // qDebug("here"); // insanityBool=TRUE; // return dit; // } // } // } // break; // case 2: // video // { // qDebug("videoView"); // Global::findDocuments(&vFiles, "video/*"); // QListIterator<DocLnk> Vdit( vFiles.children() ); // for ( ; Vdit.current(); ++Vdit ) { // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { // insanityBool=TRUE; // return Vdit; // } // } // } // break; // }; // return 0; } 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(); @@ -752,138 +752,140 @@ void PlayListWidget::addToSelection( QListViewItem *it) { 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; }; } /* play button is pressed*/ void PlayListWidget::btnPlay(bool b) { // mediaPlayerState->setPlaying(b); 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); + d->selectedFiles->unSelect(); // mediaPlayerState->setPlaying(FALSE); } break; case 2: { addToSelection( videoView->selectedItem() ); mediaPlayerState->setPlaying(b); qApp->processEvents(); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(2); + d->selectedFiles->unSelect(); // mediaPlayerState->setPlaying(FALSE); } 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; }; } void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { switch (mouse) { case 1: break; case 2:{ QPopupMenu m; m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); // m.insertSeparator(); // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); m.exec( QCursor::pos() ); } break; }; } void PlayListWidget::playSelected() { btnPlay( TRUE); } void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { switch (mouse) { case 1: break; case 2:{ QPopupMenu m; m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); // m.insertSeparator(); m.exec( QCursor::pos() ); } break; }; } |