author | simon <simon> | 2002-12-04 10:52:00 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-04 10:52:00 (UTC) |
commit | 63541c46776721ef5ae63903e5b40838c1c49a43 (patch) (side-by-side diff) | |
tree | e9beaf0d1340b32a7fffdce8e6dad7b0cbc54866 | |
parent | d000538b68b3411a409e829c4e68f42f9646b940 (diff) | |
download | opie-63541c46776721ef5ae63903e5b40838c1c49a43.zip opie-63541c46776721ef5ae63903e5b40838c1c49a43.tar.gz opie-63541c46776721ef5ae63903e5b40838c1c49a43.tar.bz2 |
- merged scanForVideo and scanForAudio into a common scanFiles method in
the PlayListFileView. less duplicated code :)
6 files changed, 37 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index c4f93e7..2726296 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp @@ -1,24 +1,36 @@ #include "playlistfileview.h" -PlayListFileView::PlayListFileView( QWidget *parent, const char *name ) - : PlayListView( parent, name ) +#include <qpe/global.h> + +PlayListFileView::PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name ) + : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ) { addColumn( tr( "Title" ), 140); addColumn( tr( "Size" ), -1 ); addColumn(tr( "Media" ), 0 ); addColumn(tr( "Path" ), -1 ); setColumnAlignment( 1, Qt::AlignRight ); setColumnAlignment( 2, Qt::AlignRight ); setAllColumnsShowFocus( TRUE ); setSorting( 3, TRUE ); setMultiSelection( TRUE ); setSelectionMode( QListView::Extended ); } PlayListFileView::~PlayListFileView() { } +void PlayListFileView::scanFiles() +{ + m_files.detachChildren(); + QListIterator<DocLnk> sdit( m_files.children() ); + for ( ; sdit.current(); ++sdit ) + delete sdit.current(); + + Global::findDocuments( &m_files, m_mimeTypePattern ); +} + /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index eef4bd1..08db929 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h @@ -1,16 +1,27 @@ #ifndef PLAYLISTFILEVIEW_H #define PLAYLISTFILEVIEW_H #include "playlistview.h" +#include <qpe/applnk.h> + class PlayListFileView : public PlayListView { Q_OBJECT public: - PlayListFileView( QWidget *parent, const char *name = 0 ); + PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name = 0 ); virtual ~PlayListFileView(); + + DocLnkSet &files() { return m_files; } + +public slots: + void scanFiles(); + +private: + QString m_mimeTypePattern; + DocLnkSet m_files; }; #endif // PLAYLISTFILEVIEW_H /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6bda71e..93e7919 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -28,63 +28,61 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #include <qpe/storage.h> #include <qpe/mimetype.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qdatetime.h> #include <qdir.h> #include <qmessagebox.h> #include <qregexp.h> #include <qtextstream.h> #include "playlistselection.h" #include "playlistwidget.h" #include "mediaplayerstate.h" #include "inputDialog.h" #include "om3u.h" +#include "playlistfileview.h" //only needed for the random play #include <stdlib.h> #include <assert.h> #include "audiowidget.h" #include "videowidget.h" extern MediaPlayerState *mediaPlayerState; // extern AudioWidget *audioUI; // extern VideoWidget *videoUI; -QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; -// no m3u's here please - PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) : PlayListWidgetGui( mediaPlayerState, parent, name ) { d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", this , SLOT(addSelected() ) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", this , SLOT(removeSelected() ) ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", this , SLOT( btnPlay( bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); pmPlayList->insertSeparator(-1); @@ -618,124 +616,111 @@ void PlayListWidget::btnPlay(bool 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; }; } void PlayListWidget::playSelected() { btnPlay( TRUE); } 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/*"); - Global::findDocuments( &files, audioMimes); + audioView->scanFiles(); audioScan = true; populateAudioView(); } 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/*"); + videoView->scanFiles(); videoScan = true; populateVideoView(); } void PlayListWidget::populateAudioView() { audioView->clear(); StorageInfo storageInfo; // const QList<FileSystem> &fs = storageInfo.fileSystems(); if(!audioScan) { scanForAudio(); } - QListIterator<DocLnk> dit( files.children() ); + QListIterator<DocLnk> dit( audioView->files().children() ); // QListIterator<FileSystem> it ( fs ); audioView->clear(); QString storage; for ( ; dit.current(); ++dit ) { // // for( ; it.current(); ++it ){ // const QString name = (*dit)->name(); // const QString path = (*dit)->path(); // if(dit.current()->file().find(path) != -1 ) { // storage = name; // // } // } QListViewItem * newItem; if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { long size; if( dit.current()->file().left(4) == "http" ) size=0; else size = QFile( dit.current()->file() ).size(); newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), "" /*storage*/, dit.current()->file() ); newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); // qDebug("<<<< "+dit.current()->file()); } } audioPopulated=true; } void PlayListWidget::populateVideoView() { videoView->clear(); StorageInfo storageInfo; // const QList<FileSystem> &fs = storageInfo.fileSystems(); if(!videoScan ) { scanForVideo(); } - QListIterator<DocLnk> Vdit( vFiles.children() ); + QListIterator<DocLnk> Vdit( videoView->files().children() ); // QListIterator<FileSystem> it ( fs ); videoView->clear(); QString storage, pathName; for ( ; Vdit.current(); ++Vdit ) { // // for( ; it.current(); ++it ) { // const QString name = (*Vdit)->name(); // const QString path = (*Vdit)->path(); // if( Vdit.current()->file().find(path) != -1 ) { // storage=name; // pathName=path; // // } // } QListViewItem * newItem; if ( QFile( Vdit.current()->file() ).exists() ) { newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file() ).size() ), ""/*storage*/, Vdit.current()->file()); newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); } } videoPopulated=true; } diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 62d78a2..e81ef3c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h @@ -113,34 +113,32 @@ private slots: void writeCurrentM3u(); 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 void clearList(); void addAllToList(); void addAllMusicToList(); void addAllVideoToList(); void saveList(); // Save the playlist void loadList( const DocLnk &); // Load a playlist void playIt( QListViewItem *); void btnPlay(bool); void deletePlaylist(); void addSelected(); void removeSelected(); void tabChanged(QWidget*); void viewPressed( int, QListViewItem *, const QPoint&, int); void playlistViewPressed( int, QListViewItem *, const QPoint&, int); void playSelected(); private: - DocLnkSet files; - DocLnkSet vFiles; bool fromSetDocument; bool insanityBool; QString setDocFileRef, currentPlayList; int selected; }; #endif // PLAY_LIST_WIDGET_H diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index cfca5e3..a219cfd 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp @@ -129,61 +129,62 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg QGridLayout *Playout = new QGridLayout( pTab ); Playout->setSpacing( 2); Playout->setMargin( 2); // Add the playlist area QVBox *vbox3 = new QVBox( pTab ); d->playListFrame = vbox3; QHBox *hbox2 = new QHBox( vbox3 ); d->selectedFiles = new PlayListSelection( hbox2 ); vbox1 = new QVBox( hbox2 ); QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); QVBox *stretch1 = new QVBox( vbox1 ); // add stretch Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); QGridLayout *Alayout = new QGridLayout( aTab ); Alayout->setSpacing( 2 ); Alayout->setMargin( 2 ); - audioView = new PlayListFileView( aTab, "Audioview" ); + // no m3u's here please + audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", aTab, "Audioview" ); Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); tabWidget->insertTab( aTab, tr( "Audio" ) ); QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); QGridLayout *Vlayout = new QGridLayout( vTab ); Vlayout->setSpacing( 2 ); Vlayout->setMargin( 2 ); - videoView = new PlayListFileView( vTab, "Videoview" ); + videoView = new PlayListFileView( "video/*", vTab, "Videoview" ); Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); tabWidget->insertTab( vTab, tr( "Video" ) ); //playlists list QWidget *LTab; LTab = new QWidget( tabWidget, "LTab" ); QGridLayout *Llayout = new QGridLayout( LTab ); Llayout->setSpacing( 2 ); Llayout->setMargin( 2 ); playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); tabWidget->insertTab( LTab, tr( "Lists" ) ); setCentralWidget( vbox5 ); } PlayListWidgetGui::~PlayListWidgetGui() { diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 9b5252a..0d8af43 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h @@ -29,48 +29,49 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PLAY_LIST_WIDGET_GUI_H #define PLAY_LIST_WIDGET_GUI_H #include <qmainwindow.h> #include <qpe/applnk.h> #include <qpe/resource.h> #include <qpe/qpemenubar.h> #include <qtabwidget.h> #include <qpe/fileselector.h> #include <qpushbutton.h> #include <qpopupmenu.h> #include <qaction.h> #include <qslider.h> #include <qlcdnumber.h> class PlayListWidgetPrivate; class PlayListSelection; class MediaPlayerState; +class PlayListFileView; class Config; class QPEToolBar; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; class PlayListWidgetPrivate { public: QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; QFrame *playListFrame; PlayListSelection *selectedFiles; bool setDocumentUsed; }; class ToolButton : public QToolButton { public: ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) : QToolButton( parent, name ) { setTextLabel( name ); setPixmap( Resource::loadPixmap( icon ) ); @@ -80,49 +81,50 @@ public: connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); QPEMenuToolFocusManager::manager()->addWidget( this ); } }; class MenuItem : public QAction { public: MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) : QAction( text, QString::null, 0, 0 ) { connect( this, SIGNAL( activated() ), handler, slot ); addTo( parent ); } }; class PlayListWidgetGui : public QMainWindow { Q_OBJECT public: PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~PlayListWidgetGui(); protected: QTabWidget * tabWidget; - QListView *audioView, *videoView, *playlistView; + PlayListFileView *audioView, *videoView; + QListView *playlistView; QLabel *libString; QPopupMenu *pmView ; QPopupMenu *gammaMenu; QSlider *gammaSlider; QLCDNumber *gammaLCD; bool fromSetDocument; bool insanityBool; QString setDocFileRef; // retrieve the current playlist entry (media file link) QPushButton *tbDeletePlaylist; int selected; QPopupMenu *pmPlayList; FileSelector* playLists; QPopupMenu *skinsMenu; PlayListWidgetPrivate *d; // Private implementation data QVBox *vbox1; QVBox *vbox5; QPEToolBar *bar; void setActiveWindow(); // need to handle this to show the right view void setView( char ); MediaPlayerState &mediaPlayerState; }; |