author | simon <simon> | 2002-12-04 11:20:48 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-04 11:20:48 (UTC) |
commit | 84d5ca934e9cb8950d1efdb90ac3b00ce6d44e95 (patch) (side-by-side diff) | |
tree | bb84499e28cfb1d518e3cebf504eb9279257ced9 | |
parent | 9b30090fddf1cc2e8ffbff70b164213118106167 (diff) | |
download | opie-84d5ca934e9cb8950d1efdb90ac3b00ce6d44e95.zip opie-84d5ca934e9cb8950d1efdb90ac3b00ce6d44e95.tar.gz opie-84d5ca934e9cb8950d1efdb90ac3b00ce6d44e95.tar.bz2 |
- merged popuplateAudioView and popuplateVideoView into one
PlayListFileView::popuplateView method
4 files changed, 40 insertions, 74 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index 1e2ef89..0ed1061 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp @@ -1,36 +1,66 @@ #include "playlistfileview.h" +#include <qfile.h> #include <qpe/global.h> +#include <qpe/resource.h> -PlayListFileView::PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name ) - : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_scannedFiles( false ) +PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) + : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ) { 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 ); } +void PlayListFileView::populateView() +{ + clear(); + + if( !m_scannedFiles ) { + scanFiles(); + m_scannedFiles = true; + } + + QString storage; + QListIterator<DocLnk> dit( m_files.children() ); + for ( ; dit.current(); ++dit ) { + + QListViewItem *newItem; + + if ( QFile::exists( dit.current()->file() ) || + dit.current()->file().left( 4 ) == "http" ) { + + unsigned long size = QFile( dit.current()->file() ).size(); + + newItem = new QListViewItem( this, dit.current()->name(), + QString::number( size ), "" /*storage*/, + dit.current()->file() ); + newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); + } + } +} + /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index 4e17966..a00349e 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h @@ -1,31 +1,33 @@ #ifndef PLAYLISTFILEVIEW_H #define PLAYLISTFILEVIEW_H #include "playlistview.h" #include <qpe/applnk.h> class PlayListFileView : public PlayListView { Q_OBJECT public: - PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name = 0 ); + PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); virtual ~PlayListFileView(); // both temporarily accessible that way until the caller code has // been migrated into this class DocLnkSet &files() { return m_files; } bool &scannedFiles() { return m_scannedFiles; } public slots: void scanFiles(); + void populateView(); private: QString m_mimeTypePattern; + QString m_itemPixmapName; DocLnkSet m_files; bool m_scannedFiles; }; #endif // PLAYLISTFILEVIEW_H /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 12b8a71..460a0bf 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -554,264 +554,198 @@ void PlayListWidget::addToSelection( QListViewItem *it) { } void PlayListWidget::tabChanged(QWidget *) { d->tbPlay->setEnabled( true ); 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->clear(); if(!audioPopulated) populateAudioView(); if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; case VideoFiles: { // videoView->clear(); if(!videoPopulated) populateVideoView(); if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } 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; }; } void PlayListWidget::playSelected() { btnPlay( TRUE); } void PlayListWidget::scanForAudio() { audioView->scanFiles(); audioView->scannedFiles() = true; populateAudioView(); } void PlayListWidget::scanForVideo() { videoView->scanFiles(); videoView->scannedFiles() = true; populateVideoView(); } void PlayListWidget::populateAudioView() { - audioView->clear(); - StorageInfo storageInfo; - // const QList<FileSystem> &fs = storageInfo.fileSystems(); - if(!audioView->scannedFiles()) { - scanForAudio(); - } - - 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; + audioView->populateView(); + audioPopulated = true; } - void PlayListWidget::populateVideoView() { - videoView->clear(); - StorageInfo storageInfo; - // const QList<FileSystem> &fs = storageInfo.fileSystems(); - - if(!videoView->scannedFiles()) { - scanForVideo(); - } - - 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" ) ); - } - } + videoView->populateView(); videoPopulated=true; } QListView *PlayListWidget::currentFileListView() const { switch ( currentTab() ) { case AudioFiles: return audioView; case VideoFiles: return videoView; default: assert( false ); } return 0; } bool PlayListWidget::inFileListMode() const { TabType tab = currentTab(); return tab == AudioFiles || tab == VideoFiles; } void PlayListWidget::openFile() { // http://66.28.164.33:2080 // http://somafm.com/star0242.m3u QString filename, name; InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { filename = fileDlg->text(); qDebug( "Selected filename is " + filename ); // Om3u *m3uList; DocLnk lnk; Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); if(filename.left(4) == "http") { QString m3uFile, m3uFilePath; if(filename.find(":",8,TRUE) != -1) { //found a port m3uFile = filename.left( filename.find( ":",8,TRUE)); m3uFile = m3uFile.right( 7); } else if(filename.left(4) == "http"){ m3uFile=filename; m3uFile = m3uFile.right( m3uFile.length() - 7); } else{ m3uFile=filename; } // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); lnk.setName( filename ); //sets name lnk.setFile( filename ); //sets file name // lnk.setIcon("opieplayer2/musicfile"); d->selectedFiles->addToSelection( lnk ); writeCurrentM3u(); d->selectedFiles->setSelectedItem( lnk.name()); } else if( filename.right( 3) == "m3u" ) { readm3u( filename ); } else if( filename.right(3) == "pls" ) { readPls( filename ); } else { lnk.setName( QFileInfo(filename).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); writeCurrentM3u(); d->selectedFiles->setSelectedItem( lnk.name()); } } if( fileDlg ) { delete fileDlg; } } /* reads m3u and shows files/urls to playlist widget */ void PlayListWidget::readm3u( const QString &filename ) { qDebug( "read m3u filename " + filename ); Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); m3uList->readM3u(); DocLnk lnk; for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { s = *it; // qDebug("reading "+ s); if(s.left(4)=="http") { lnk.setName( s ); //sets file name lnk.setIcon("opieplayer2/musicfile"); lnk.setFile( s ); //sets file name } else { // if( QFileInfo( s ).exists() ) { lnk.setName( QFileInfo(s).baseName()); diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index a219cfd..7f851bd 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp @@ -58,151 +58,151 @@ #include "audiowidget.h" #include "videowidget.h" #include "mediaplayerstate.h" PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { d = new PlayListWidgetPrivate; d->setDocumentUsed = FALSE; setBackgroundMode( PaletteButton ); setToolBarsMovable( FALSE ); // Create Toolbar QPEToolBar *toolbar = new QPEToolBar( this ); toolbar->setHorizontalStretchable( TRUE ); // Create Menubar QPEMenuBar *menu = new QPEMenuBar( toolbar ); menu->setMargin( 0 ); bar = new QPEToolBar( this ); bar->setLabel( tr( "Play Operations" ) ); tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); tbDeletePlaylist->setFlat( TRUE ); tbDeletePlaylist->setFixedSize( 20, 20 ); tbDeletePlaylist->hide(); pmPlayList = new QPopupMenu( this ); menu->insertItem( tr( "File" ), pmPlayList ); pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); pmView->isCheckable(); skinsMenu = new QPopupMenu( this ); pmView->insertItem( tr( "Skins" ), skinsMenu ); skinsMenu->isCheckable(); gammaMenu = new QPopupMenu( this ); pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); gammaSlider->setRange( -40, 40 ); gammaSlider->setTickmarks( QSlider::Left ); gammaSlider->setTickInterval( 20 ); gammaSlider->setFocusPolicy( QWidget::StrongFocus ); gammaSlider->setValue( 0 ); gammaSlider->setMinimumHeight( 50 ); gammaLCD = new QLCDNumber( 3, gammaMenu ); gammaLCD-> setFrameShape ( QFrame::NoFrame ); gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); gammaMenu->insertItem( gammaSlider ); gammaMenu->insertItem( gammaLCD ); connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); vbox5 = new QVBox( this ); QVBox *vbox4 = new QVBox( vbox5 ); QHBox *hbox6 = new QHBox( vbox4 ); tabWidget = new QTabWidget( hbox6, "tabWidget" ); QWidget *pTab; pTab = new QWidget( tabWidget, "pTab" ); tabWidget->insertTab( pTab, "Playlist"); 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 ); // no m3u's here please - audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", aTab, "Audioview" ); + audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", 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( "video/*", vTab, "Videoview" ); + videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", 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() { } void PlayListWidgetGui::setView( char view ) { if ( view == 'l' ) showMaximized(); else hide(); } void PlayListWidgetGui::setActiveWindow() { // qDebug("SETTING active window"); // When we get raised we need to ensure that it switches views MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate mediaPlayerState.setDisplayType( origDisplayType ); // now switch back } |