-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 70 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 3 |
3 files changed, 53 insertions, 22 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h index cf9daea..8f9a0ee 100644 --- a/core/multimedia/opieplayer/mediaplayer.h +++ b/core/multimedia/opieplayer/mediaplayer.h @@ -43,15 +43,15 @@ private slots: void prev(); void startIncreasingVolume(); void startDecreasingVolume(); void stopChangingVolume(); + void cleanUp(); protected: void timerEvent( QTimerEvent *e ); void keyReleaseEvent( QKeyEvent *e); void doBlank(); void doUnblank(); - void cleanUp(); private: int volumeDirection; const DocLnk *currentFile; }; diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 7a79be1..78c2822 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -31,9 +31,8 @@ #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/resource.h> - #include <qaction.h> #include <qcursor.h> #include <qimage.h> #include <qfile.h> @@ -130,8 +129,10 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) d->setDocumentUsed = FALSE; d->current = NULL; fromSetDocument = FALSE; insanityBool=FALSE; + audioScan = FALSE; + videoScan = FALSE; // menuTimer = new QTimer( this ,"menu timer"), // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); setBackgroundMode( PaletteButton ); @@ -180,8 +181,11 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) // pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); + pmPlayList->insertSeparator(-1); + new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); + new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); QPopupMenu *pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); @@ -253,9 +257,9 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) connect( audioView, SIGNAL( returnPressed( QListViewItem *)), this,SLOT( playIt( QListViewItem *)) ); // audioView - populateAudioView(); +// populateAudioView(); // videowidget QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); @@ -278,21 +282,20 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) connect( videoView, SIGNAL( returnPressed( QListViewItem *)), this,SLOT( playIt( QListViewItem *)) ); tabWidget->insertTab( vTab,tr("Video")); -populateVideoView(); +// populateVideoView(); //playlists list QWidget *LTab; LTab = new QWidget( tabWidget, "LTab" ); playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy - playLists->setMinimumSize(233,260);; + playLists->setMinimumSize(233,260); tabWidget->insertTab(LTab,tr("Lists")); connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); - // add the library area // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), // this, SLOT( fauxPlay( QListViewItem *) ) ); @@ -432,10 +435,8 @@ void PlayListWidget::addAllToList() { } void PlayListWidget::addAllMusicToList() { -// DocLnkSet files; -// Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); } @@ -526,9 +527,8 @@ const DocLnk *PlayListWidget::current() { // this is fugly 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"); @@ -540,9 +540,8 @@ const DocLnk *PlayListWidget::current() { // this is fugly 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; @@ -802,16 +801,21 @@ void PlayListWidget::tabChanged(QWidget *widg) { } break; case 1: { + audioView->clear(); + populateAudioView(); + if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; case 2: { + videoView->clear(); + populateVideoView(); if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); @@ -826,10 +830,8 @@ void PlayListWidget::tabChanged(QWidget *widg) { break; }; } - - void PlayListWidget::btnPlay(bool b) { // mediaPlayerState->setPlaying(b); switch ( tabWidget->currentPageIndex()) { @@ -879,9 +881,8 @@ void PlayListWidget::deletePlaylist() { break; case 1: // Cancel break; }; - } void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { @@ -973,18 +974,39 @@ void PlayListWidget::listDelete() { break; }; } +void PlayListWidget::scanForAudio() { + qDebug("scan for audio"); + files.detachChildren(); + QListIterator<DocLnk> sdit( files.children() ); + for ( ; sdit.current(); ++sdit ) { + delete sdit.current(); + } + Global::findDocuments(&files, "audio/*"); + audioScan = TRUE; +} +void PlayListWidget::scanForVideo() { + qDebug("scan for video"); + vFiles.detachChildren(); + QListIterator<DocLnk> sdit( vFiles.children() ); + for ( ; sdit.current(); ++sdit ) { + delete sdit.current(); + } + Global::findDocuments(&vFiles, "video/*"); + videoScan = TRUE; +} + void PlayListWidget::populateAudioView() { -// if(files) -// files.~DocLnkSet(); + + audioView->clear(); StorageInfo storageInfo; const QList<FileSystem> &fs = storageInfo.fileSystems(); + if(!audioScan) scanForAudio(); - Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); QListIterator<FileSystem> it ( fs ); - audioView->clear(); + QString storage; for ( ; dit.current(); ++dit ) { for( ; it.current(); ++it ){ const QString name = (*it)->name(); @@ -992,21 +1014,25 @@ void PlayListWidget::populateAudioView() { if(dit.current()->file().find(path) != -1 ) storage=name; } QListViewItem * newItem; - if ( QFile( dit.current()->file()).exists() ) { - newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); + if ( QFile( dit.current()->file()).exists() ) { +// qDebug(dit.current()->name()); + newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), + QString::number( QFile( dit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); } } } void PlayListWidget::populateVideoView() { + videoView->clear(); StorageInfo storageInfo; const QList<FileSystem> &fs = storageInfo.fileSystems(); - Global::findDocuments(&vFiles, "video/*"); + if(!videoScan ) scanForVideo(); + QListIterator<DocLnk> Vdit( vFiles.children() ); QListIterator<FileSystem> it ( fs ); videoView->clear(); QString storage; @@ -1018,9 +1044,10 @@ void PlayListWidget::populateVideoView() { } QListViewItem * newItem; if ( QFile( Vdit.current()->file()).exists() ) { - newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); + newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), + QString::number( QFile( Vdit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); } } } @@ -1094,9 +1121,9 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) // playSelected(); // break; case Key_Space: qDebug("Play"); - playSelected(); +// playSelected(); puh break; case Key_1: tabWidget->setCurrentPage(0); break; @@ -1232,4 +1259,5 @@ void PlayListWidget::readPls(const QString &filename) { } i++; } } + diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 778e3ee..6569f35 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h @@ -70,8 +70,9 @@ protected: /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ void keyReleaseEvent( QKeyEvent *e); void keyPressEvent( QKeyEvent *e); private: + bool audioScan, videoScan; void doBlank(); void doUnblank(); void readm3u(const QString &); void writem3u(const QString &); @@ -84,8 +85,10 @@ private: PlayListWidgetPrivate *d; // Private implementation data void populateAudioView(); void populateVideoView(); private slots: + void scanForAudio(); + void scanForVideo(); void openFile(); void setDocument( const QString& fileref ); void addToSelection( const DocLnk& ); // Add a media file to the playlist void addToSelection( QListViewItem* ); // Add a media file to the playlist |