summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/playlistwidget.cpp
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp90
1 files changed, 46 insertions, 44 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 3609f5d..d85ce50 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -11,43 +11,45 @@
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
// code added by L. J. Potter Sat 03-02-2002 06:17:54
#define QTOPIA_INTERNAL_FSLP
-#include <qtoolbar.h>
+#include "playlistselection.h"
+#include "playlistwidget.h"
+#include "mediaplayerstate.h"
+#include "inputDialog.h"
+#include "audiowidget.h"
+#include "videowidget.h"
+
+/* OPIE */
#include <qpe/qpemenubar.h>
#include <qpe/lnkproperties.h>
+#include <opie2/odebug.h>
+/* QT */
+#include <qtoolbar.h>
#include <qaction.h>
#include <qlayout.h>
#include <qmessagebox.h>
-
//#include <qtimer.h>
-#include "playlistselection.h"
-#include "playlistwidget.h"
-#include "mediaplayerstate.h"
-
-#include "inputDialog.h"
-
+/* STD */
#include <stdlib.h>
-#include "audiowidget.h"
-#include "videowidget.h"
#include <unistd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
// for setBacklight()
#include <linux/fb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
@@ -380,25 +382,25 @@ void PlayListWidget::readConfig( Config& cfg ) {
void PlayListWidget::writeConfig( Config& cfg ) const {
d->selectedFiles->writeCurrent( cfg);
cfg.setGroup("PlayList");
int noOfFiles = 0;
d->selectedFiles->first();
do {
const DocLnk *lnk = d->selectedFiles->current();
if ( lnk ) {
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
-// qDebug(entryName);
+// odebug << entryName << oendl;
cfg.writeEntry( entryName, lnk->linkFile() );
// if this link does exist, add it so we have the file
// next time...
if ( !QFile::exists( lnk->linkFile() ) ) {
// the way writing lnks doesn't really check for out
// of disk space, but check it anyway.
// if ( !lnk->writeLink() ) {
// QMessageBox::critical( 0, tr("Out of space"),
// tr( "There was a problem saving "
// "the playlist.\n"
// "Your playlist "
// "may be missing some entries\n"
@@ -474,34 +476,34 @@ void PlayListWidget::addAllVideoToList() {
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::setDocument(const QString& fileref) {
fromSetDocument = true;
d->setDocumentUsed = TRUE;
setDocumentEx(fileref);
}
void PlayListWidget::setDocumentEx(const QString& fileref) {
- qDebug("opieplayer receive "+fileref);
+ odebug << "opieplayer receive "+fileref << oendl;
clearList();
DocLnk lnk;
QFileInfo fileInfo(fileref);
if ( !fileInfo.exists() ) {
QMessageBox::critical( 0, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
- // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref);
+ // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl;
QString extension = fileInfo.extension(false);
if( extension.find( "m3u", 0, false) != -1) { //is m3u
readm3u( fileref);
}
else if( extension.find( "pls", 0, false) != -1 ) { //is pls
readPls( fileref);
}
else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
clearList();
lnk.setName( fileInfo.baseName() ); //sets name
lnk.setFile( fileref ); //sets file name
lnk.setIcon("Sound");
@@ -525,55 +527,55 @@ void PlayListWidget::setDocumentEx(const QString& fileref) {
}
setCaption(tr("OpiePlayer"));
d->setDocumentUsed = TRUE;
d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
mediaPlayerState->setPlaying( FALSE );
qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::setActiveWindow() {
- // qDebug("SETTING active window");
+ // odebug << "SETTING active window" << oendl;
// When we get raised we need to ensure that it switches views
char origView = mediaPlayerState->view();
mediaPlayerState->setView( 'l' ); // invalidate
mediaPlayerState->setView( origView ); // now switch back
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() { // this is fugly
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
{
- // qDebug("playlist");
+ // odebug << "playlist" << oendl;
if ( mediaPlayerState->playlist() ) {
return d->selectedFiles->current();
}
else if ( d->setDocumentUsed && d->current ) {
return d->current;
} else {
return &(d->files->selectedDocument());
}
}
break;
case 1://audio
{
- // qDebug("audioView");
+ // odebug << "audioView" << oendl;
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
insanityBool=TRUE;
return dit;
}
}
}
break;
case 2: // video
{
QListIterator<DocLnk> Vdit( vFiles.children() );
@@ -651,29 +653,29 @@ bool PlayListWidget::last() {
return d->selectedFiles->last();
else
return mediaPlayerState->looping();
}
void PlayListWidget::saveList() {
writem3u();
}
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
- // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
+ // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl;
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
- // qDebug("<<<<<<<<<<<<load list "+ lnk.file());
+ // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl;
clearList();
readm3u(lnk.file());
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown )
d->playListFrame->show();
else
d->playListFrame->hide();
}
@@ -809,25 +811,25 @@ void PlayListWidget::tabChanged(QWidget *) {
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
// QMessageBox::message("Note","You are trying to play\na malformed url.");
// } else {
mediaPlayerState->setPlaying(b);
insanityBool=FALSE;
- qDebug("insanity");
+ odebug << "insanity" << oendl;
// }
}
break;
case 1:
{
// d->selectedFiles->unSelect();
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying( b);
d->selectedFiles->removeSelected( );
d->selectedFiles->unSelect();
tabWidget->setCurrentPage(1);
insanityBool=FALSE;
@@ -942,35 +944,35 @@ void PlayListWidget::listDelete() {
// LnkProperties prop( &lnk);
// // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*)));
// prop.showMaximized();
// prop.exec();
// }
// }
}
break;
};
}
void PlayListWidget::scanForAudio() {
- // qDebug("scan for audio");
+ // odebug << "scan for audio" << oendl;
files.detachChildren();
QListIterator<DocLnk> sdit( files.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments( &files, audioMimes);
audioScan = true;
}
void PlayListWidget::scanForVideo() {
- // qDebug("scan for video");
+ // odebug << "scan for video" << oendl;
vFiles.detachChildren();
QListIterator<DocLnk> sdit( vFiles.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments(&vFiles, "video/*");
videoScan = true;
}
void PlayListWidget::populateAudioView() {
audioView->clear();
@@ -987,25 +989,25 @@ void PlayListWidget::populateAudioView() {
const QString name = (*it)->name();
const QString path = (*it)->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();
- // qDebug(dit.current()->name());
+ // odebug << dit.current()->name() << oendl;
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
QString::number(size ), storage, dit.current()->file());
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
}
}
}
void PlayListWidget::populateVideoView() {
videoView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
@@ -1031,25 +1033,25 @@ void PlayListWidget::populateVideoView() {
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
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->text();
- // qDebug( "Selected filename is " + filename );
+ // odebug << "Selected filename is " + filename << oendl;
DocLnk lnk;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString m3uFile;
m3uFile = filename;
if(filename.left(4) == "http") {
if(filename.find(":",8,TRUE) != -1) { //found a port
m3uFile = filename;
if( m3uFile.right( 1 ).find( '/' ) == -1) {
m3uFile += "/";
@@ -1076,55 +1078,55 @@ void PlayListWidget::openFile() {
}
}
if( fileDlg ) {
delete fileDlg;
}
}
/*
reads m3u and shows files/urls to playlist widget */
void PlayListWidget::readm3u( const QString &filename ) {
- // qDebug( "read m3u filename " + filename );
+ // odebug << "read m3u filename " + filename << oendl;
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);
+ // odebug << "reading "+ s << oendl;
if(s.left(4)=="http") {
lnk.setName( s ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
// if(s.right(4) != '.' || s.right(5) != '.')
if(s.right(4) != '.' || s.right(5) != '.' )
if( s.right(1) != "/")
lnk.setFile( s+"/"); //if url with no extension
else
lnk.setFile( s ); //sets file name
} else {
// if( QFileInfo( s ).exists() ) {
lnk.setName( fullBaseName ( QFileInfo(s)));
// if(s.right(4) == '.') {//if regular file
if(s.left(1) != "/") {
- // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
+ // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl;
lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
lnk.setIcon("SoundPlayer");
} else {
- // qDebug("set link2 "+s);
+ // odebug << "set link2 "+s << oendl;
lnk.setFile( s);
lnk.setIcon("SoundPlayer");
}
}
d->selectedFiles->addToSelection( lnk );
}
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
config.write();
currentPlayList=filename;
@@ -1133,25 +1135,25 @@ void PlayListWidget::readm3u( const QString &filename ) {
m3uList->close();
if(m3uList) delete m3uList;
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
}
/*
reads pls and adds files/urls to playlist */
void PlayListWidget::readPls( const QString &filename ) {
- // qDebug( "pls filename is " + filename );
+ // odebug << "pls filename is " + filename << oendl;
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QFileInfo f( s );
QString name = fullBaseName ( f);
@@ -1176,95 +1178,95 @@ void PlayListWidget::readPls( const QString &filename ) {
lnk.writeLink();
d->selectedFiles->addToSelection( lnk );
}
m3uList->close();
if(m3uList) delete m3uList;
}
/*
writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
- // qDebug("writing to current m3u");
+ // odebug << "writing to current m3u" << oendl;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
currentPlayList = cfg.readEntry("CurrentPlaylist","");
Om3u *m3uList;
m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
if( d->selectedFiles->first()) {
do {
- // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
+ // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
- // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
+ // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
}
}
/*
writes current playlist to m3u file */
void PlayListWidget::writem3u() {
InputDialog *fileDlg;
fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
fileDlg->exec();
QString name, filename, list;
Om3u *m3uList;
if( fileDlg->result() == 1 ) {
name = fileDlg->text();
- // qDebug( filename );
+ // odebug << filename << oendl;
if( name.find("/",0,true) != -1) {// assume they specify a file path
filename = name;
name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
}
else //otherwise dump it somewhere noticable
filename = QPEApplication::documentDir() + "/" + name;
if( filename.right( 3 ) != "m3u" ) //needs filename extension
filename += ".m3u";
if( d->selectedFiles->first()) {
m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
do {
m3uList->add( d->selectedFiles->current()->file());
}
while ( d->selectedFiles->next() );
- // qDebug( list );
+ // odebug << list << oendl;
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
if(fileDlg) delete fileDlg;
DocLnk lnk;
lnk.setFile( filename);
lnk.setIcon("opieplayer2/playlist2");
lnk.setName( name); //sets file name
- // qDebug(filename);
+ // odebug << filename << oendl;
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
currentPlayList=filename;
if(!lnk.writeLink()) {
- // qDebug("Writing doclink did not work");
+ // odebug << "Writing doclink did not work" << oendl;
}
setCaption(tr("OpiePlayer: ") + name);
}
}
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
{
switch ( e->key() ) {
////////////////////////////// Zaurus keys
@@ -1282,25 +1284,25 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
// doBlank();
break;
case Key_F13: //mail
// doUnblank();
break;
case Key_Q: //add to playlist
addSelected();
break;
case Key_R: //remove from playlist
removeSelected();
break;
// case Key_P: //play
-// qDebug("Play");
+// odebug << "Play" << oendl;
// playSelected();
// break;
case Key_Space:
// playSelected(); puh
break;
case Key_1:
tabWidget->setCurrentPage(0);
break;
case Key_2:
tabWidget->setCurrentPage(1);
break;
case Key_3:
@@ -1316,88 +1318,88 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
break;
case Key_Up:
if ( !d->selectedFiles->prev() )
// d->selectedFiles->last();
break;
}
}
void PlayListWidget::keyPressEvent( QKeyEvent *)
{
-// qDebug("Key press");
+// odebug << "Key press" << oendl;
// switch ( e->key() ) {
// ////////////////////////////// Zaurus keys
// case Key_A: //add to playlist
-// qDebug("Add");
+// odebug << "Add" << oendl;
// addSelected();
// break;
// case Key_R: //remove from playlist
// removeSelected();
// break;
// case Key_P: //play
-// qDebug("Play");
+// odebug << "Play" << oendl;
// playSelected();
// break;
// case Key_Space:
-// qDebug("Play");
+// odebug << "Play" << oendl;
// playSelected();
// break;
// }
}
void PlayListWidget::doBlank() {
- // qDebug("do blanking");
+ // odebug << "do blanking" << oendl;
#ifdef QT_QWS_DEVFS
fd=open("/dev/fb/0",O_RDWR);
#else
fd=open("/dev/fb0",O_RDWR);
#endif
if (fd != -1) {
ioctl(fd,FBIOBLANK,1);
// close(fd);
}
}
void PlayListWidget::doUnblank() {
// this crashes opieplayer with a segfault
// int fd;
// fd=open("/dev/fb0",O_RDWR);
- // qDebug("do unblanking");
+ // odebug << "do unblanking" << oendl;
if (fd != -1) {
ioctl(fd,FBIOBLANK,0);
close(fd);
}
QCopEnvelope h("QPE/System", "setBacklight(int)");
h <<-3;// v[1]; // -3 Force on
}
void PlayListWidget::populateSkinsMenu() {
int item = 0;
defaultSkinIndex = 0;
QString skinName;
Config cfg( "OpiePlayer" );
cfg.setGroup("Options" );
QString skin = cfg.readEntry( "Skin", "default" );
QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
skinsDir.setFilter( QDir::Dirs );
skinsDir.setSorting(QDir::Name );
const QFileInfoList *skinslist = skinsDir.entryInfoList();
QFileInfoListIterator it( *skinslist );
QFileInfo *fi;
while ( ( fi = it.current() ) ) {
skinName = fi->fileName();
- // qDebug( fi->fileName() );
+ // odebug << fi->fileName() << oendl;
if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
item = skinsMenu->insertItem( fi->fileName() ) ;
}
if( skinName == "default" ) {
defaultSkinIndex = item;
}
if( skinName == skin ) {
skinsMenu->setItemChecked( item, TRUE );
}
++it;
}
}
@@ -1405,25 +1407,25 @@ void PlayListWidget::populateSkinsMenu() {
void PlayListWidget::skinsMenuActivated( int item ) {
for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
skinsMenu->setItemChecked( i, FALSE );
}
skinsMenu->setItemChecked( item, TRUE );
Config cfg( "OpiePlayer" );
cfg.setGroup("Options");
cfg.writeEntry("Skin", skinsMenu->text( item ) );
}
void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
- // qDebug("qcop message "+msg );
+ // odebug << "qcop message "+msg << oendl;
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "play()" ) { //plays current selection
btnPlay( true);
} else if ( msg == "stop()" ) {
mediaPlayerState->setPlaying( false);
} else if ( msg == "togglePause()" ) {
mediaPlayerState->togglePaused();
} else if ( msg == "next()" ) { //select next in lis
mediaPlayerState->setNext();
} else if ( msg == "prev()" ) { //select previous in list
mediaPlayerState->setPrev();
} else if ( msg == "toggleLooping()" ) { //loop or not loop