summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-08 18:31:28 (UTC)
committer llornkcor <llornkcor>2002-10-08 18:31:28 (UTC)
commit7599e0a20572d44ca805e6effb878601c707fd05 (patch) (side-by-side diff)
tree2bc2342b16338ca395528456705e38ede850d653
parent9475b63d025c1ca386764784b7dad460935f45b0 (diff)
downloadopie-7599e0a20572d44ca805e6effb878601c707fd05.zip
opie-7599e0a20572d44ca805e6effb878601c707fd05.tar.gz
opie-7599e0a20572d44ca805e6effb878601c707fd05.tar.bz2
more fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp235
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
4 files changed, 104 insertions, 161 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 8da7f73..5069a49 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -318,29 +318,29 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
break;
case Key_F12: //home
qDebug("Blank here");
// mediaPlayerState->toggleBlank();
break;
case Key_F13: //mail
qDebug("Blank here");
// mediaPlayerState->toggleBlank();
break;
}
}
void MediaPlayer::cleanUp() {// this happens on closing
Config cfg( "OpiePlayer" );
mediaPlayerState->writeConfig( cfg );
- playList->writeConfig( cfg );
+ playList->writeDefaultPlaylist( );
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
}
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index c947033..0be727b 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -42,72 +42,72 @@
#include <qdir.h>
#include <qregexp.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qcstring.h>
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
//filePath is path name to m3u
//qDebug("<<<<<<<new m3u "+filePath);
f.setName(filePath);
// if(f.exists())
// f.open( IO_ReadWrite);
// else
// f.open( IO_ReadWrite | IO_Truncate);
f.open(mode);
}
Om3u::~Om3u(){}
-void Om3u::readM3u() { //it's m3u
+void Om3u::readM3u() {
// qDebug("<<<<<<reading m3u "+f.name());
QTextStream t(&f);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
- // qDebug(s);
+ qDebug(s);
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
QFileInfo f( s );
QString name = f.baseName();
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
s=s.replace( QRegExp( "\\" ), "/" );
append(s);
// qDebug(s);
} else { // is url
s.replace( QRegExp( "%20" )," " );
QString name;
- if( name.left( 4 ) == "http" ) {
- name = s.right( s.length() - 7 );
- } else {
+// if( name.left( 4 ) == "http" ) {
+// name = s.right( s.length() - 7 );
+// } else {
name = s;
- }
+// }
append(name);
// qDebug(name);
}
}
}
}
void Om3u::readPls() { //it's a pls file
QTextStream t( &f );
QString s;
while ( !t.atEnd() ) {
s = t.readLine();
if( s.left(4) == "File" ) {
s = s.right( s.length() - 6 );
s.replace( QRegExp( "%20" )," ");
// qDebug( "adding " + s + " to playlist" );
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
QFileInfo f( s );
@@ -116,42 +116,53 @@ void Om3u::readPls() { //it's a pls file
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
if( s.at( s.length() - 4) == '.') // if this is probably a file
append(s);
else { //if its a url
if( name.right( 1 ).find( '/' ) == -1) {
s += "/";
}
append(s);
}
}
}
}
void Om3u::write() { //writes list to m3u file
QString list;
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
qDebug(*it);
list += *it+"\n";
}
f.writeBlock( list, list.length() );
- f.close();
+// f.close();
}
void Om3u::add(const QString &filePath) { //adds to m3u file
append(filePath);
}
void Om3u::remove(const QString &filePath) { //removes from m3u list
+ QString list, currentFile;
+ for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
+ currentFile=*it;
+// qDebug(*it);
+
+ if( filePath != currentFile)
+ list += currentFile+"\n";
+ }
+ f.writeBlock( list, list.length() );
}
void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
+ f.close();
+ f.remove();
}
void Om3u::close() { //closes m3u file
f.close();
}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 897c458..cc4be23 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -155,143 +155,69 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
initializeStates();
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
loadList(DocLnk( currentPlaylist ) );
setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
}
PlayListWidget::~PlayListWidget() {
if ( d->current ) {
delete d->current;
}
delete d;
}
void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->playing() );
d->tbLoop->setOn( mediaPlayerState->looping() );
d->tbShuffle->setOn( mediaPlayerState->shuffled() );
setPlaylist( true );
}
+void PlayListWidget::writeDefaultPlaylist() {
-void PlayListWidget::readConfig( Config& cfg ) {
-
- cfg.setGroup( "PlayList" );
- QString currentString = cfg.readEntry( "current", "" );
- int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
-
- for ( int i = 0; i < noOfFiles; i++ ) {
- QString entryName;
- entryName.sprintf( "File%i", i + 1 );
-
- QString linkFile = cfg.readEntry( entryName );
-
- qDebug("reading "+linkFile);
-
- if( QFileInfo( linkFile ).exists() ) {
-
- DocLnk lnk( linkFile );
-
- if ( QFileInfo( lnk.file() ).exists() ||
-
- linkFile.find( "http" , 0, TRUE) != -1) {
-
- d->selectedFiles->addToSelection( lnk );
- }
- }
- }
- d->selectedFiles->setSelectedItem( currentString );
-}
-
-
-void PlayListWidget::writeConfig( Config& cfg ) const {
-
- Config config( "OpiePlayer" );
- config.setGroup( "PlayList" );
-
-// if(config.readBoolEntry("newPlaylist")) {
-// new for testing
- QString name, filename, list;
+ Config config( "OpiePlayer" );
+ config.setGroup( "PlayList" );
+ QString filename=QPEApplication::documentDir() + "/default.m3u";
+ QString currentString = config.readEntry( "CurrentPlaylist", filename);
+ if( currentString == filename) {
Om3u *m3uList;
- name = "default";
-
- filename=QPEApplication::documentDir() + "/" + name+".m3u";
- m3uList = new Om3u(filename, IO_ReadWrite);
+// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
+ m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
d->selectedFiles->first();
do {
- qDebug(d->selectedFiles->current()->file());
+// qDebug(d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
- // qDebug( list );
- // m3uList->write();
+ m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
-
- DocLnk lnk;
- lnk.setFile( filename);
- lnk.setIcon("opieplayer2/playlist2");
- lnk.setName( name); //sets file name
-
- qDebug("writing default playlist "+filename);
-
- config.writeEntry("CurrentPlaylist", filename);
-// currentPlayList=filename;
- if(!lnk.writeLink()) {
- qDebug("Writing doclink did not work");
- }
-// } else {
-
-// d->selectedFiles->writeCurrent( cfg );
-// int noOfFiles = 0;
-// d->selectedFiles->first();
-
-// do {
-// const DocLnk *lnk = d->selectedFiles->current();
-
-// if ( lnk ) {
-
-// QString entryName;
-// entryName.sprintf( "File%i", noOfFiles + 1 );
-
-// cfg.writeEntry( entryName, lnk->linkFile() );
-// // if this link does exist, add it so we have the file
-// // next time...
-
-// if ( !QFile::exists( lnk->linkFile() ) ) {
-// lnk->writeLink();
-// }
-// }
-// noOfFiles++;
-// }
-// while ( d->selectedFiles->next() );
-// cfg.writeEntry("NumberOfFiles", noOfFiles );
-// }
+ }
}
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();
}
else
mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::clearList() {
while ( first() ) {
d->selectedFiles->removeSelected();
}
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
case 1:
@@ -339,66 +265,66 @@ void PlayListWidget::addAllToList() {
void PlayListWidget::addAllMusicToList() {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo(dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
writeCurrentM3u();
}
void PlayListWidget::addAllVideoToList() {
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( fileref );
+ qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
fromSetDocument = TRUE;
if ( fileref.isNull() ) {
QMessageBox::critical( 0, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
- if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
+ 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( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
-// clearList();
-// loadList( DocLnk( fileref ) );
-// d->selectedFiles->first();
-// }
- else {
+ } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
+ readPls( DocLnk( fileref).file() );
+ } else {
clearList();
addToSelection( DocLnk( fileref ) );
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
mediaPlayerState->setPlaying( TRUE );
}
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() { // this is fugly
switch ( whichList() ) {
case 0: //playlist
{
// qDebug("playlist");
if ( mediaPlayerState->playlist() ) {
return d->selectedFiles->current();
} else if ( d->setDocumentUsed && d->current ) {
return d->current;
} else {
@@ -486,49 +412,49 @@ bool PlayListWidget::last() {
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
readm3u(lnk.file());
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown ) {
d->playListFrame->show();
} else {
d->playListFrame->hide();
}
}
void PlayListWidget::addSelected() {
-
+ qDebug("addSelected");
switch (whichList()) {
case 0: //playlist
break;
case 1: { //audio
QListViewItemIterator it( audioView );
// iterate through all items of the listview
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it.current()->text(0) ) {
if( QFileInfo( dit.current()->file()).exists()) {
d->selectedFiles->addToSelection( **dit );
audioView->setSelected( it.current(),FALSE);
}
}
}
}
}
tabWidget->setCurrentPage(0);
writeCurrentM3u();
}
break;
case 2: { // video
@@ -536,91 +462,90 @@ void PlayListWidget::addSelected() {
// iterate through all items of the listview
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it.current()->text(0) ) {
if(QFileInfo( dit.current()->file()).exists()) {
d->selectedFiles->addToSelection( **dit );
videoView->setSelected( it.current(),FALSE);
}
}
}
}
}
tabWidget->setCurrentPage(0);
writeCurrentM3u();
}
break;
};
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
+ writeCurrentM3u();
}
void PlayListWidget::playIt( QListViewItem *it) {
if(!it) return;
mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
-
+ qDebug("addToSelection2");
if(it) {
switch ( whichList()) {
- case 1: {
- QListIterator<DocLnk> dit( files.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it->text(0)) {
- if(QFileInfo( dit.current()->file()).exists())
- d->selectedFiles->addToSelection( **dit );
- }
- }
- writeCurrentM3u();
-
- }
-
- break;
- case 2: {
- QListIterator<DocLnk> dit( vFiles.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it->text(0)) {
- if( QFileInfo( dit.current()->file()).exists() )
- d->selectedFiles->addToSelection( **dit );
- }
- }
- writeCurrentM3u();
+ case 1: {
+ QListIterator<DocLnk> dit( files.children() );
+ for ( ; dit.current(); ++dit ) {
+ if( dit.current()->name() == it->text(0)) {
+ if(QFileInfo( dit.current()->file()).exists())
+ d->selectedFiles->addToSelection( **dit );
+ }
+ }
+ writeCurrentM3u();
+ }
+ break;
+ case 2: {
+ QListIterator<DocLnk> dit( vFiles.children() );
+ for ( ; dit.current(); ++dit ) {
+ if( dit.current()->name() == it->text(0)) {
+ if( QFileInfo( dit.current()->file()).exists() )
+ d->selectedFiles->addToSelection( **dit );
+ }
+ }
+ writeCurrentM3u();
- }
- break;
- case 0:
- break;
+ }
+ break;
+ case 0:
+ break;
};
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::tabChanged(QWidget *) {
switch ( whichList()) {
case 0:
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
}
break;
case 1:
{
audioView->clear();
populateAudioView();
if( !tbDeletePlaylist->isHidden() ) {
@@ -759,138 +684,142 @@ void PlayListWidget::populateVideoView() {
if( Vdit.current()->file().find(path) != -1 ) {
storage=name;
pathName=path;
}
}
QListViewItem * newItem;
if ( QFile( Vdit.current()->file() ).exists() ) {
newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
QString::number( QFile( Vdit.current()->file() ).size() ),
storage, Vdit.current()->file());
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/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 );
-
- if(filename.left(4) == "http") { //if http, lets write a new m3u
Om3u *m3uList;
DocLnk lnk;
- QString m3uFile, m3uFilePath;
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("PlayList");
+ if(filename.left(4) == "http") {
+ QString m3uFile, m3uFilePath;
if(filename.find(":",8,TRUE) != -1) { //found a port
m3uFile = filename.left( filename.find( ":",8,TRUE));
m3uFile = m3uFile.right( 7);
} else if(filename.left(4) == "http"){
m3uFile=filename;
m3uFile = m3uFile.right( m3uFile.length() - 7);
} else{
m3uFile=filename;
}
-// qDebug( m3uFile);
-//this is where this new m3u is going to live at
- m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u";
-// m3uFile += ".m3u";
- m3uList = new Om3u( m3uFile+".m3u", IO_ReadWrite );
+ qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
+ m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite );
m3uList->add( filename);
m3uList->write();
+ m3uList->close();
if(m3uList) delete m3uList;
-// qDebug( m3uFile);
- lnk.setName( filename ); //sets file name
- lnk.setFile( m3uFilePath ); //sets File property
- lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
-
- lnk.setExec( "opieplayer2" );
- lnk.setIcon("opieplayer2/playlist2");
-
- if( !lnk.writeLink() ) {
- qDebug( "Writing doclink did not work" );
- }
+ lnk.setName( filename ); //sets name
+ lnk.setFile( filename ); //sets file name
+ lnk.setIcon("opieplayer2/musicfile");
d->selectedFiles->addToSelection( lnk );
-
}
- else if( filename.right( 3 ) == "m3u" ) {
+ else if( filename.right( 3) == "m3u" ) {
readm3u( filename );
} else if( filename.right(3) == "pls" ) {
readPls( filename );
}
+ else {
+ m3uList = new Om3u( cfg.readEntry("CurrentPlaylist",""), IO_Append | IO_ReadWrite );
+ m3uList->add( filename);
+ m3uList->write();
+ m3uList->close();
+ if(m3uList) delete m3uList;
+ d->selectedFiles->addToSelection( DocLnk(filename) );
+ }
}
+
if( fileDlg ) {
delete fileDlg;
}
}
/*
-reads m3u and adds files/urls to playlist */
+reads m3u and shows files/urls to playlist widget */
void PlayListWidget::readm3u( const QString &filename ) {
qDebug( "read m3u filename " + filename );
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;
- s.replace( QRegExp( "%20" )," " );
+// s.replace( QRegExp( "%20" )," " );
// qDebug("reading "+ s);
-
- if( QFileInfo( s ).exists() ) {
+ if(s.left(4)=="http") {
+ lnk.setName( s ); //sets file name
+ lnk.setFile( s ); //sets file name
+ lnk.setIcon("opieplayer2/musicfile");
+ }
+ else {
+ if( QFileInfo( s ).exists() ) {
lnk.setName( QFileInfo(s).baseName());
// qDebug("set link "+s);
if(s.at(s.length()-4) == '.') //if regular file
lnk.setFile( s);
else
lnk.setFile( s+"/"); //if url with no extension
-
- d->selectedFiles->addToSelection( lnk );
+ }
}
+ d->selectedFiles->addToSelection( lnk );
}
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
config.write();
currentPlayList=filename;
+// m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
d->selectedFiles->setSelectedItem( s);
- setCaption(tr("OpiePlayer: ")+ filename);
+ setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
}
/*
reads pls and adds files/urls to playlist */
void PlayListWidget::readPls( const QString &filename ) {
qDebug( "pls filename is " + filename );
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 = f.baseName();
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
@@ -905,91 +834,95 @@ void PlayListWidget::readPls( const QString &filename ) {
if( name.right( 1 ).find( '/' ) == -1) {
s += "/";
}
lnk.setFile( s );
}
lnk.setType( "audio/x-mpegurl" );
lnk.writeLink();
d->selectedFiles->addToSelection( lnk );
}
m3uList->close();
if(m3uList) delete m3uList;
}
/*
writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
qDebug("writting 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 );
+ m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate );
d->selectedFiles->first();
do {
m3uList->add( d->selectedFiles->current()->file());
}
while ( d->selectedFiles->next() );
// qDebug( list );
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 );
if( name.left( 1) != "/" ) {
filename = QPEApplication::documentDir() + "/" + name;
}
if( name.right( 3 ) != "m3u" ) {
filename = QPEApplication::documentDir() + "/" +name+".m3u";
}
m3uList = new Om3u(filename, IO_ReadWrite);
d->selectedFiles->first();
do {
m3uList->add( d->selectedFiles->current()->file());
}
while ( d->selectedFiles->next() );
// qDebug( list );
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);
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
currentPlayList=filename;
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
setCaption(tr("OpiePlayer: ") + name);
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 8a77619..53be7a7 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -52,60 +52,59 @@ class QPoint;
class QAction;
class QLabel;
class PlayListWidget : public PlayListWidgetGui {
Q_OBJECT
public:
PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
~PlayListWidget();
DocLnkSet files;
DocLnkSet vFiles;
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef, currentPlayList;
// retrieve the current playlist entry (media file link)
const DocLnk *current();
void useSelectedDocument();
int selected;
int whichList();
public slots:
bool first();
bool last();
bool next();
bool prev();
- void writeConfig( Config& cfg ) const;
+ void writeDefaultPlaylist( );
QString currentFileListPathName();
protected:
void keyReleaseEvent( QKeyEvent *e);
private:
int defaultSkinIndex;
bool audioScan, videoScan;
void readm3u(const QString &);
void readPls(const QString &);
void initializeStates();
- void readConfig( Config& cfg );
void populateAudioView();
void populateVideoView();
private slots:
void populateSkinsMenu();
void skinsMenuActivated(int);
void pmViewActivated(int);
void writem3u();
void writeCurrentM3u();
void scanForAudio();
void scanForVideo();
void openFile();
void setDocument( const QString& fileref );
void addToSelection( const DocLnk& ); // Add a media file to the playlist
void addToSelection( QListViewItem* ); // Add a media file to the playlist
void setPlaylist( bool ); // Show/Hide the playlist
void clearList();
void addAllToList();
void addAllMusicToList();
void addAllVideoToList();
void saveList(); // Save the playlist
void loadList( const DocLnk &); // Load a playlist
void playIt( QListViewItem *);
void btnPlay(bool);