-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 139 |
1 files changed, 133 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 038b371..ec5500f 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -33,9 +33,8 @@ #include <qpe/global.h> #include <qpe/resource.h> #include <qaction.h> -#include <qcursor.h> #include <qimage.h> #include <qfile.h> #include <qdir.h> #include <qlayout.h> @@ -50,8 +49,9 @@ #include <qpoint.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qregexp.h> +#include <qtextstream.h> //#include <qtimer.h> #include "playlistselection.h" @@ -248,8 +248,10 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); + connect( audioView, SIGNAL( returnPressed( QListViewItem *)), + this,SLOT( playIt( QListViewItem *)) ); // audioView populateAudioView(); // videowidget @@ -268,10 +270,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) videoView->setMultiSelection( TRUE ); videoView->setSelectionMode( QListView::Extended); QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); + connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); + connect( videoView, SIGNAL( returnPressed( QListViewItem *)), + this,SLOT( playIt( QListViewItem *)) ); tabWidget->insertTab( vTab,tr("Video")); populateVideoView(); @@ -833,27 +838,31 @@ void PlayListWidget::btnPlay(bool b) { } break; case 1: { +// if(audioView->selectedItem()) { addToSelection( audioView->selectedItem() ); mediaPlayerState->setPlaying(b); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(1); d->selectedFiles->unSelect(); insanityBool=FALSE; // audioView->clearSelection(); +// } } break; case 2: { +// if(videoView->selectedItem() ) { addToSelection( videoView->selectedItem() ); mediaPlayerState->setPlaying(b); qApp->processEvents(); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(2); d->selectedFiles->unSelect(); insanityBool=FALSE; // videoView->clearSelection(); +// } } break; }; } @@ -882,9 +891,11 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& QPopupMenu m; m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); m.insertSeparator(); + if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); + m.exec( QCursor::pos() ); } break; }; @@ -905,9 +916,10 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const case 2:{ QPopupMenu m; m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); -// m.insertSeparator(); +// m.insertSeparator(); +// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); m.exec( QCursor::pos() ); } break; }; @@ -920,9 +932,9 @@ void PlayListWidget::listDelete() { QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); QString file; int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); switch ( tabWidget->currentPageIndex()) { - case 0: + case 0: break; case 1: { file = audioView->selectedItem()->text(0); @@ -984,8 +996,9 @@ void PlayListWidget::populateAudioView() { 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() { StorageInfo storageInfo; @@ -1017,11 +1030,11 @@ void PlayListWidget::openFile() { fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { filename = fileDlg->LineEdit1->text(); -//http://205.188.234.129:8030 +// http://205.188.234.129:8030 // http://66.28.68.70:8000 - qDebug(filename); + qDebug("Selected filename is "+filename); if(filename.right(3) == "m3u") readm3u( filename); else if(filename.right(3) == "pls") readPls( filename); @@ -1067,12 +1080,61 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) break; case Key_F13: //mail // doUnblank(); break; - + case Key_Q: //add to playlist + qDebug("Add"); + addSelected(); + break; + case Key_R: //remove from playlist + removeSelected(); + break; +// case Key_P: //play +// qDebug("Play"); +// playSelected(); +// break; + case Key_Space: + qDebug("Play"); + playSelected(); + break; + case Key_1: + tabWidget->setCurrentPage(0); + break; + case Key_2: + tabWidget->setCurrentPage(1); + break; + case Key_3: + tabWidget->setCurrentPage(2); + break; + case Key_4: + tabWidget->setCurrentPage(3); + break; } } +void PlayListWidget::keyPressEvent( QKeyEvent *e) +{ +// qDebug("Key press"); +// switch ( e->key() ) { +// ////////////////////////////// Zaurus keys +// case Key_A: //add to playlist +// qDebug("Add"); +// addSelected(); +// break; +// case Key_R: //remove from playlist +// removeSelected(); +// break; +// case Key_P: //play +// qDebug("Play"); +// playSelected(); +// break; +// case Key_Space: +// qDebug("Play"); +// playSelected(); +// break; +// } +} + void PlayListWidget::doBlank() { qDebug("do blanking"); fd=open("/dev/fb0",O_RDWR); if (fd != -1) { @@ -1095,13 +1157,78 @@ void PlayListWidget::doUnblank() { } void PlayListWidget::readm3u(const QString &filename) { + qDebug("playlist filename is "+filename); + QFile f(filename); + + if(f.open(IO_ReadOnly)) { + QTextStream t(&f); + QString s;//, first, second; + int i=0; + while ( !t.atEnd()) { +// Lview->insertLine(t.readLine(),-1); + s=t.readLine(); + if(s.find("#",0,TRUE) == -1) { + if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat + if(s.left(2) == "E:" || s.left(2) == "P:") { + s=s.right(s.length()-2); + DocLnk lnk( s ); + QFileInfo f(s); + QString name = f.baseName(); + name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); + lnk.setName( name); + s=s.replace( QRegExp("\\"),"/"); + lnk.setFile( s); +// lnk.setIcon(opieplayer/MPEGPlayer); + qDebug("add "+name); + d->selectedFiles->addToSelection( lnk); + } else { // is url + DocLnk lnk( s); + QString name = s.right( s.length() - 7); +// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); + lnk.setName(name); + lnk.setFile( s+"/"); +// lnk.setFile( filename); +// lnk.setComment( s+"/"); + lnk.setType("audio/x-mpegurl"); +// lnk.setIcon( "opieplayer/MPEGPlayer"); +// qDebug("add "+s); + d->selectedFiles->addToSelection( lnk); + } + i++; + } + } + } + } } void PlayListWidget::writem3u(const QString &filename) { } void PlayListWidget::readPls(const QString &filename) { + qDebug("playlist filename is "+filename); + QFile f(filename); + + if(f.open(IO_ReadOnly)) { + QTextStream t(&f); + QString s;//, first, second; + int i=0; + while ( !t.atEnd()) { +// Lview->insertLine(t.readLine(),-1); +// s=t.readLine(); +// s=s.right(s.length()-2); +// DocLnk lnk( s ); +// QFileInfo f(s); +// QString name = f.baseName(); +// // name = name.left(name.length()-4); +// name = name.right(name.findRev("/",0,TRUE)); +// lnk.setName( name); +// lnk.setFile( s); +// qDebug("add "+name); +// d->selectedFiles->addToSelection( lnk); + } + i++; + } } |