summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-08 02:01:16 (UTC)
committer llornkcor <llornkcor>2002-10-08 02:01:16 (UTC)
commit40e9c78666e74221e06329bb07dfd66648b2727b (patch) (side-by-side diff)
treeafccf992024cc56a64d8495d80ce10478f946478
parentc43b5d600a7d1dcaadcba2cb047a60313b37f2f2 (diff)
downloadopie-40e9c78666e74221e06329bb07dfd66648b2727b.zip
opie-40e9c78666e74221e06329bb07dfd66648b2727b.tar.gz
opie-40e9c78666e74221e06329bb07dfd66648b2727b.tar.bz2
fixed m3u handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/om3u.h2
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp180
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h1
4 files changed, 76 insertions, 123 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index d378145..c947033 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -49,13 +49,15 @@
//extern PlayListWidget *playList;
-Om3u::Om3u( const QString &filePath)
+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);
+// if(f.exists())
+// f.open( IO_ReadWrite);
+// else
+// f.open( IO_ReadWrite | IO_Truncate);
+ f.open(mode);
+
}
@@ -68,7 +70,6 @@ void Om3u::readM3u() { //it's m3u
while ( !t.atEnd() ) {
s=t.readLine();
-
+ // qDebug(s);
if( s.find( "#", 0, TRUE) == -1 ) {
- if( s.find( " ", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
@@ -90,5 +91,4 @@ void Om3u::readM3u() { //it's m3u
// qDebug(name);
}
- }
}
}
diff --git a/noncore/multimedia/opieplayer2/om3u.h b/noncore/multimedia/opieplayer2/om3u.h
index 392980e..9c7cf9a 100644
--- a/noncore/multimedia/opieplayer2/om3u.h
+++ b/noncore/multimedia/opieplayer2/om3u.h
@@ -54,5 +54,5 @@ class Om3u : public QStringList {
// Q_OBJECT
public:
- Om3u( const QString &filePath);
+ Om3u( const QString &filePath, int mode);
~Om3u();
void readM3u();
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 26c2896..b6525e1 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -149,13 +149,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
mediaPlayerState, SLOT( setVideoGamma( int ) ) );
-// cfg.setGroup( "PlayList" );
-// if( cfg.readBoolEntry("newPlaylist") ){
- QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
- loadList(DocLnk( currentPlaylist ) );
- setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
-// } else {
-// readConfig( cfg );
-
-// }
// see which skins are installed
videoScan=FALSE;
@@ -163,10 +154,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
populateSkinsMenu();
initializeStates();
+
+ QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
+ loadList(DocLnk( currentPlaylist ) );
+ setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
}
PlayListWidget::~PlayListWidget() {
- // WTF?!@?!
-
if ( d->current ) {
delete d->current;
@@ -207,10 +200,8 @@ void PlayListWidget::readConfig( Config& cfg ) {
d->selectedFiles->addToSelection( lnk );
-
}
}
}
d->selectedFiles->setSelectedItem( currentString );
-
}
@@ -228,16 +219,14 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
filename=QPEApplication::documentDir() + "/" + name+".m3u";
-
- m3uList = new Om3u(filename);
-
+ m3uList = new Om3u(filename, IO_ReadWrite);
d->selectedFiles->first();
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( list );
-
- m3uList->write();
+ // m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
@@ -250,11 +239,9 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
qDebug("writing default playlist "+filename);
- config.writeEntry("CurrentPlaylist", filename);
+ config.writeEntry("CurrentPlaylist", filename);
// currentPlayList=filename;
-
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
-
// } else {
@@ -286,5 +273,4 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
}
-
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = FALSE;
@@ -293,4 +279,5 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
+ writeCurrentM3u();
}
else
@@ -305,5 +292,4 @@ void PlayListWidget::clearList() {
}
-
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
@@ -347,4 +333,5 @@ void PlayListWidget::addAllToList() {
}
}
+ writeCurrentM3u();
}
@@ -357,4 +344,5 @@ void PlayListWidget::addAllMusicToList() {
}
}
+ writeCurrentM3u();
}
@@ -367,4 +355,5 @@ void PlayListWidget::addAllVideoToList() {
}
}
+ writeCurrentM3u();
}
@@ -383,17 +372,15 @@ void PlayListWidget::setDocument( const QString& fileref ) {
} 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( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
+// clearList();
+// loadList( DocLnk( fileref ) );
+// d->selectedFiles->first();
+// }
+ else {
clearList();
addToSelection( DocLnk( fileref ) );
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
-// qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
-// qApp->processEvents();
- setCaption( tr("OpiePlayer") );
}
}
@@ -492,44 +479,5 @@ bool PlayListWidget::last() {
void PlayListWidget::saveList() {
-// Config config( "OpiePlayer" );
-// config.setGroup( "PlayList" );
-
-// if(config.readBoolEntry("newPlaylist") ){
- writem3u();
-
-// } else {
-
-// QString filename;
-// InputDialog *fileDlg = 0l;
-// fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
-// fileDlg->exec();
-// if( fileDlg->result() == 1 ) {
-// if ( d->current )
-// delete d->current;
-// filename = fileDlg->text();//+".playlist";
-// // qDebug("saving playlist "+filename+".playlist");
-
-// Config cfg( filename +".playlist");
-// writeConfig( cfg );
-
-// DocLnk lnk;
-// lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf");
-// //sets File property
-// lnk.setType("playlist/plain");
-// lnk.setIcon("opieplayer2/playlist2");
-// lnk.setName( filename); //sets file name
-// // qDebug(filename);
-// if(!lnk.writeLink()) {
-// qDebug("Writing doclink did not work");
-// }
-// }
-
-// config.writeEntry("CurrentPlaylist",filename);
-// setCaption(tr("OpiePlayer: ")+filename);
-// d->selectedFiles->first();
-// if(fileDlg) {
-// delete fileDlg;
-// }
-// }
+ writem3u();
}
@@ -537,25 +485,12 @@ bool PlayListWidget::last() {
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
- qDebug("currentList is "+name);
+ // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
- qDebug("<<<<<<<<<<<<load list "+ lnk.file());
+ qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
-
-// if(name.right(3) == "m3u") {
-
readm3u(lnk.file());
-// } else {
-// / Config cfg( name+".playlist");
-// readConfig(cfg);
-
tabWidget->setCurrentPage(0);
-
- Config config( "OpiePlayer" );
- config.setGroup( "PlayList" );
- config.writeEntry("CurrentPlaylist", lnk.file());
-// // d->selectedFiles->first();
-// }
}
}
@@ -573,9 +508,4 @@ void PlayListWidget::setPlaylist( bool shown ) {
void PlayListWidget::addSelected() {
- Config cfg( "OpiePlayer" );
- cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
- // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
-
switch (whichList()) {
case 0: //playlist
@@ -589,12 +519,14 @@ void PlayListWidget::addSelected() {
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it.current()->text(0) ) {
- if(QFileInfo( dit.current()->file()).exists())
+ if( QFileInfo( dit.current()->file()).exists()) {
d->selectedFiles->addToSelection( **dit );
+ audioView->setSelected( it.current(),FALSE);
+ }
}
}
- audioView->setSelected( it.current(),FALSE);
}
}
tabWidget->setCurrentPage(0);
+ writeCurrentM3u();
}
break;
@@ -607,12 +539,14 @@ void PlayListWidget::addSelected() {
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it.current()->text(0) ) {
- if(QFileInfo( dit.current()->file()).exists())
+ if(QFileInfo( dit.current()->file()).exists()) {
d->selectedFiles->addToSelection( **dit );
+ videoView->setSelected( it.current(),FALSE);
+ }
}
}
- videoView->setSelected( it.current(),FALSE);
}
}
tabWidget->setCurrentPage(0);
+ writeCurrentM3u();
}
break;
@@ -647,5 +581,8 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
}
}
+ writeCurrentM3u();
+
}
+
break;
case 2: {
@@ -657,4 +594,6 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
}
}
+ writeCurrentM3u();
+
}
break;
@@ -851,16 +790,11 @@ void PlayListWidget::openFile() {
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);
@@ -868,10 +802,8 @@ void PlayListWidget::openFile() {
m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u";
// m3uFile += ".m3u";
- m3uList = new Om3u( m3uFile+".m3u");
-
+ m3uList = new Om3u( m3uFile+".m3u", IO_ReadWrite );
m3uList->add( filename);
m3uList->write();
if(m3uList) delete m3uList;
-
// qDebug( m3uFile);
lnk.setName( filename ); //sets file name
@@ -907,5 +839,5 @@ void PlayListWidget::readm3u( const QString &filename ) {
Om3u *m3uList;
QString s, name;
- m3uList = new Om3u( filename);
+ m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readM3u();
DocLnk lnk;
@@ -913,9 +845,9 @@ void PlayListWidget::readm3u( const QString &filename ) {
s = *it;
s.replace( QRegExp( "%20" )," " );
- qDebug("reading "+ s);
+// qDebug("reading "+ s);
if( QFileInfo( s ).exists() ) {
lnk.setName( QFileInfo(s).baseName());
- qDebug("set link "+s);
+// qDebug("set link "+s);
if(s.at(s.length()-4) == '.') //if regular file
lnk.setFile( s);
@@ -930,4 +862,5 @@ void PlayListWidget::readm3u( const QString &filename ) {
config.writeEntry("CurrentPlaylist",filename);
+ config.write();
currentPlayList=filename;
@@ -936,5 +869,5 @@ void PlayListWidget::readm3u( const QString &filename ) {
d->selectedFiles->setSelectedItem( s);
- setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName());
+ setCaption(tr("OpiePlayer: ")+ filename);
}
@@ -947,10 +880,10 @@ void PlayListWidget::readPls( const QString &filename ) {
Om3u *m3uList;
QString s, name;
- m3uList = new Om3u( filename);
+ m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
- s.replace( QRegExp( "%20" )," " );
+ // s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QFileInfo f( s );
@@ -985,4 +918,25 @@ void PlayListWidget::readPls( const QString &filename ) {
/*
+ 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 );
+ d->selectedFiles->first();
+
+ do {
+ m3uList->add( d->selectedFiles->current()->file());
+ }
+ while ( d->selectedFiles->next() );
+ // qDebug( list );
+ m3uList->write();
+ if(m3uList) delete m3uList;
+}
+
+ /*
writes current playlist to m3u file */
void PlayListWidget::writem3u() {
@@ -1005,5 +959,5 @@ void PlayListWidget::writem3u() {
}
- m3uList = new Om3u(filename);
+ m3uList = new Om3u(filename, IO_ReadWrite);
d->selectedFiles->first();
@@ -1014,7 +968,5 @@ void PlayListWidget::writem3u() {
while ( d->selectedFiles->next() );
// qDebug( list );
-
m3uList->write();
- m3uList->close();
}
if(m3uList) delete m3uList;
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 428821a..8a77619 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -94,4 +94,5 @@ private slots:
void pmViewActivated(int);
void writem3u();
+ void writeCurrentM3u();
void scanForAudio();
void scanForVideo();