-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 @@ -31,13 +31,12 @@ #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> #include <qdir.h> #include <qlayout.h> #include <qlabel.h> #include <qlist.h> @@ -48,12 +47,13 @@ #include <qtabwidget.h> #include <qlistview.h> #include <qpoint.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qregexp.h> +#include <qtextstream.h> //#include <qtimer.h> #include "playlistselection.h" #include "playlistwidget.h" #include "mediaplayerstate.h" @@ -246,12 +246,14 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) tabWidget->insertTab(aTab,tr("Audio")); 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 QWidget *vTab; @@ -266,14 +268,17 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) videoView->setColumnAlignment(2, Qt::AlignRight); videoView->setAllColumnsShowFocus(TRUE); 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(); //playlists list QWidget *LTab; @@ -831,31 +836,35 @@ void PlayListWidget::btnPlay(bool b) { { mediaPlayerState->setPlaying(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; }; } void PlayListWidget::deletePlaylist() { @@ -880,13 +889,15 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& break; case 2:{ 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; }; } @@ -903,13 +914,14 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const break; 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; }; } @@ -918,13 +930,13 @@ void PlayListWidget::listDelete() { Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); 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); // Global::findDocuments(&files, "audio/*"); // AppLnkSet appFiles; @@ -982,12 +994,13 @@ void PlayListWidget::populateAudioView() { QListViewItem * newItem; if ( QFile( dit.current()->file()).exists() ) { 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; const QList<FileSystem> &fs = storageInfo.fileSystems(); @@ -1015,15 +1028,15 @@ void PlayListWidget::openFile() { QString filename, name; InputDialog *fileDlg; 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); else { DocLnk lnk; @@ -1065,16 +1078,65 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) case Key_F12: //home // doBlank(); 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) { ioctl(fd,FBIOBLANK,1); // close(fd); @@ -1093,15 +1155,80 @@ void PlayListWidget::doUnblank() { QCopEnvelope h("QPE/System", "setBacklight(int)"); h <<-3;// v[1]; // -3 Force on } 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++; + } } |