summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp133
1 files changed, 130 insertions, 3 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
@@ -29,33 +29,33 @@
#include <qpe/storage.h>
#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>
#include <qlistbox.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qtoolbutton.h>
#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"
#include "inputDialog.h"
@@ -244,16 +244,18 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
audioView->setSelectionMode( QListView::Extended);
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;
vTab = new QWidget( tabWidget, "vTab" );
videoView = new QListView( vTab, "Videoview" );
@@ -264,18 +266,21 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
videoView->addColumn(tr("Media"),-1);
videoView->setColumnAlignment(1, Qt::AlignRight);
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;
LTab = new QWidget( tabWidget, "LTab" );
playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
@@ -829,35 +834,39 @@ void PlayListWidget::btnPlay(bool b) {
switch ( tabWidget->currentPageIndex()) {
case 0:
{
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() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(tr("You really want to delete\nthis playlist?")),
@@ -878,17 +887,19 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint&
switch (mouse) {
case 1:
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;
};
}
void PlayListWidget::playSelected()
{
@@ -902,16 +913,17 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const
case 1:
break;
case 2:{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
// m.insertSeparator();
+// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::listDelete() {
@@ -980,16 +992,17 @@ 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();
Global::findDocuments(&vFiles, "video/*");
QListIterator<DocLnk> Vdit( vFiles.children() );
@@ -1015,17 +1028,17 @@ 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://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;
lnk.setName(filename); //sets file name
@@ -1063,20 +1076,69 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
case Key_F11: //menu
break;
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);
}
}
@@ -1091,17 +1153,82 @@ void PlayListWidget::doUnblank() {
close(fd);
}
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++;
+ }
}