summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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.cpp172
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h1
4 files changed, 72 insertions, 119 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
@@ -50,3 +50,3 @@
-Om3u::Om3u( const QString &filePath)
+Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
@@ -55,6 +55,8 @@ Om3u::Om3u( const QString &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);
+
}
@@ -69,5 +71,4 @@ void Om3u::readM3u() { //it's m3u
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:" ) {
@@ -94,3 +95,2 @@ void Om3u::readM3u() { //it's m3u
}
-}
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
@@ -55,3 +55,3 @@ class Om3u : public QStringList {
public:
- Om3u( const QString &filePath);
+ Om3u( const QString &filePath, int mode);
~Om3u();
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
@@ -150,11 +150,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
-// 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
@@ -164,2 +155,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
initializeStates();
+
+ QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
+ loadList(DocLnk( currentPlaylist ) );
+ setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
}
@@ -168,4 +163,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
PlayListWidget::~PlayListWidget() {
- // WTF?!@?!
-
if ( d->current ) {
@@ -208,3 +201,2 @@ void PlayListWidget::readConfig( Config& cfg ) {
d->selectedFiles->addToSelection( lnk );
-
}
@@ -213,3 +205,2 @@ void PlayListWidget::readConfig( Config& cfg ) {
d->selectedFiles->setSelectedItem( currentString );
-
}
@@ -229,7 +220,6 @@ 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 {
+ qDebug(d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file());
@@ -237,6 +227,5 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
while ( d->selectedFiles->next() );
+ // qDebug( list );
- qDebug( list );
-
- m3uList->write();
+ // m3uList->write();
m3uList->close();
@@ -253,3 +242,2 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
// currentPlayList=filename;
-
if(!lnk.writeLink()) {
@@ -257,3 +245,2 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
}
-
// } else {
@@ -287,3 +274,2 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
-
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
@@ -294,2 +280,3 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->selectedFiles->addToSelection( lnk );
+ writeCurrentM3u();
}
@@ -306,3 +293,2 @@ void PlayListWidget::clearList() {
-
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
@@ -348,2 +334,3 @@ void PlayListWidget::addAllToList() {
}
+ writeCurrentM3u();
}
@@ -358,2 +345,3 @@ void PlayListWidget::addAllMusicToList() {
}
+ writeCurrentM3u();
}
@@ -368,2 +356,3 @@ void PlayListWidget::addAllVideoToList() {
}
+ writeCurrentM3u();
}
@@ -384,7 +373,8 @@ void PlayListWidget::setDocument( const QString& fileref ) {
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();
@@ -393,6 +383,3 @@ void PlayListWidget::setDocument( const QString& fileref ) {
mediaPlayerState->setPlaying( FALSE );
-// qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
-// qApp->processEvents();
- setCaption( tr("OpiePlayer") );
}
@@ -493,42 +480,3 @@ 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;
-// }
-// }
}
@@ -538,3 +486,3 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
- qDebug("currentList is "+name);
+ // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
@@ -544,17 +492,4 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
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();
-// }
}
@@ -574,7 +509,2 @@ void PlayListWidget::addSelected() {
- Config cfg( "OpiePlayer" );
- cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
- // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
-
switch (whichList()) {
@@ -590,7 +520,8 @@ void PlayListWidget::addSelected() {
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);
}
@@ -598,2 +529,3 @@ void PlayListWidget::addSelected() {
tabWidget->setCurrentPage(0);
+ writeCurrentM3u();
}
@@ -608,7 +540,8 @@ void PlayListWidget::addSelected() {
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);
}
@@ -616,2 +549,3 @@ void PlayListWidget::addSelected() {
tabWidget->setCurrentPage(0);
+ writeCurrentM3u();
}
@@ -648,3 +582,6 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
}
+ writeCurrentM3u();
+
}
+
break;
@@ -658,2 +595,4 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
}
+ writeCurrentM3u();
+
}
@@ -852,10 +791,6 @@ void PlayListWidget::openFile() {
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{
@@ -863,3 +798,2 @@ void PlayListWidget::openFile() {
}
-
// qDebug( m3uFile);
@@ -869,4 +803,3 @@ void PlayListWidget::openFile() {
// m3uFile += ".m3u";
- m3uList = new Om3u( m3uFile+".m3u");
-
+ m3uList = new Om3u( m3uFile+".m3u", IO_ReadWrite );
m3uList->add( filename);
@@ -874,3 +807,2 @@ void PlayListWidget::openFile() {
if(m3uList) delete m3uList;
-
// qDebug( m3uFile);
@@ -908,3 +840,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
QString s, name;
- m3uList = new Om3u( filename);
+ m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readM3u();
@@ -914,3 +846,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
s.replace( QRegExp( "%20" )," " );
- qDebug("reading "+ s);
+// qDebug("reading "+ s);
@@ -918,3 +850,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
lnk.setName( QFileInfo(s).baseName());
- qDebug("set link "+s);
+// qDebug("set link "+s);
if(s.at(s.length()-4) == '.') //if regular file
@@ -931,2 +863,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
config.writeEntry("CurrentPlaylist",filename);
+ config.write();
currentPlayList=filename;
@@ -937,3 +870,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
d->selectedFiles->setSelectedItem( s);
- setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName());
+ setCaption(tr("OpiePlayer: ")+ filename);
@@ -948,3 +881,3 @@ void PlayListWidget::readPls( const QString &filename ) {
QString s, name;
- m3uList = new Om3u( filename);
+ m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
@@ -953,3 +886,3 @@ void PlayListWidget::readPls( const QString &filename ) {
s = *it;
- s.replace( QRegExp( "%20" )," " );
+ // s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
@@ -986,2 +919,23 @@ 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 */
@@ -1006,3 +960,3 @@ void PlayListWidget::writem3u() {
- m3uList = new Om3u(filename);
+ m3uList = new Om3u(filename, IO_ReadWrite);
@@ -1015,5 +969,3 @@ void PlayListWidget::writem3u() {
// qDebug( list );
-
m3uList->write();
- m3uList->close();
}
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
@@ -95,2 +95,3 @@ private slots:
void writem3u();
+ void writeCurrentM3u();
void scanForAudio();