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,13 +1,15 @@ #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 ); @@ -15,10 +17,20 @@ PlayListFileView::PlayListFileView( QWidget *parent, const char *name ) 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 @@ -44,31 +44,29 @@ #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", @@ -634,49 +632,36 @@ void PlayListWidget::deletePlaylist() { 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(); @@ -709,17 +694,17 @@ 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 ) { 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 @@ -129,18 +129,16 @@ private slots: 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 @@ -145,29 +145,30 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg 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; 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 @@ -45,16 +45,17 @@ #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; @@ -96,17 +97,18 @@ public: 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; |