summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-08 21:32:13 (UTC)
committer llornkcor <llornkcor>2002-10-08 21:32:13 (UTC)
commitca0c224318a50c6618691fb30f39aa1d9b0b8a4f (patch) (side-by-side diff)
tree961917745cbb5bccf220735b9b62705d4651ffe7
parent9fdf7460f752f979497ee743ba67ddba52c1a7d7 (diff)
downloadopie-ca0c224318a50c6618691fb30f39aa1d9b0b8a4f.zip
opie-ca0c224318a50c6618691fb30f39aa1d9b0b8a4f.tar.gz
opie-ca0c224318a50c6618691fb30f39aa1d9b0b8a4f.tar.bz2
fix addAll* from menu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index c0d3108..d53c423 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -48,24 +48,26 @@
#include "mediaplayerstate.h"
#include "inputDialog.h"
#include "om3u.h"
//only needed for the random play
#include <stdlib.h>
#include "audiowidget.h"
#include "videowidget.h"
extern MediaPlayerState *mediaPlayerState;
+QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
+// no m3u's here please
PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
: PlayListWidgetGui( parent, name, fl ) {
d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
"opieplayer2/add_to_playlist",
this , SLOT(addSelected() ) );
d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
"opieplayer2/remove_from_playlist",
this , SLOT(removeSelected() ) );
d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
this , SLOT( btnPlay( bool) ), TRUE );
@@ -196,25 +198,25 @@ void PlayListWidget::writeDefaultPlaylist() {
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
}
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = FALSE;
if ( mediaPlayerState->playlist() ) {
if( QFileInfo( lnk.file() ).exists() ||
lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
- writeCurrentM3u();
+// writeCurrentM3u();
}
else
mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::clearList() {
while ( first() ) {
d->selectedFiles->removeSelected();
}
}
@@ -243,47 +245,51 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
- Global::findDocuments(&filesAll, "video/*;audio/*");
+ Global::findDocuments(&filesAll, "video/*;"+audioMimes);
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit ) {
if( QFileInfo( Adit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **Adit );
}
}
writeCurrentM3u();
}
void PlayListWidget::addAllMusicToList() {
+ if(!audioScan)
+ scanForAudio();
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo(dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
writeCurrentM3u();
}
void PlayListWidget::addAllVideoToList() {
+ if(!videoScan)
+ scanForVideo();
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo( dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
writeCurrentM3u();
}
void PlayListWidget::setDocument( const QString& fileref ) {
qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
@@ -297,24 +303,26 @@ void PlayListWidget::setDocument( const QString& fileref ) {
clearList();
if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
readm3u( fileref );
} else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
readm3u( DocLnk( fileref).file() );
} else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
readPls( fileref );
} else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
readPls( DocLnk( fileref).file() );
} else {
clearList();
addToSelection( DocLnk( fileref ) );
+ writeCurrentM3u();
+
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
mediaPlayerState->setPlaying( TRUE );
}
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
@@ -603,25 +611,25 @@ void PlayListWidget::playSelected() {
btnPlay( TRUE);
}
void PlayListWidget::scanForAudio() {
// qDebug("scan for audio");
files.detachChildren();
QListIterator<DocLnk> sdit( files.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
// Global::findDocuments( &files, "audio/*");
- Global::findDocuments( &files, "audio/mpeg;audio/x-wav;audio/x-ogg");
+ Global::findDocuments( &files, audioMimes);
audioScan = TRUE;
}
void PlayListWidget::scanForVideo() {
// qDebug("scan for video");
vFiles.detachChildren();
QListIterator<DocLnk> sdit( vFiles.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments(&vFiles, "video/*");
videoScan = TRUE;
@@ -835,34 +843,35 @@ void PlayListWidget::readPls( const QString &filename ) {
m3uList->close();
if(m3uList) delete m3uList;
}
/*
writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
qDebug("writing to current m3u");
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
- // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
+
Om3u *m3uList;
- m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate );
+ m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
d->selectedFiles->first();
-
+ qDebug( d->selectedFiles->current()->file());
do {
- m3uList->add( d->selectedFiles->current()->file());
+ qDebug( d->selectedFiles->current()->file());
+ m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
-// qDebug( list );
+ qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
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();