summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/playlistwidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp175
1 files changed, 54 insertions, 121 deletions
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
@@ -178,34 +178,3 @@ void PlayListWidget::initializeStates() {
-
-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 {
+void PlayListWidget::writeDefaultPlaylist() {
@@ -213,14 +182,11 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
config.setGroup( "PlayList" );
-
-// if(config.readBoolEntry("newPlaylist")) {
-// new for testing
- QString name, filename, list;
+ 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() );
@@ -228,47 +194,7 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
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 );
-// }
}
@@ -362,3 +288,3 @@ void PlayListWidget::addAllVideoToList() {
void PlayListWidget::setDocument( const QString& fileref ) {
- //qDebug( fileref );
+ qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
fromSetDocument = TRUE;
@@ -370,12 +296,12 @@ 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( 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();
@@ -509,3 +435,3 @@ void PlayListWidget::setPlaylist( bool shown ) {
void PlayListWidget::addSelected() {
-
+ qDebug("addSelected");
switch (whichList()) {
@@ -559,2 +485,3 @@ void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
+ writeCurrentM3u();
}
@@ -572,3 +499,3 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
-
+ qDebug("addToSelection2");
if(it) {
@@ -584,5 +511,3 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
writeCurrentM3u();
-
}
-
break;
@@ -782,10 +707,10 @@ void PlayListWidget::openFile() {
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
@@ -799,24 +724,13 @@ void PlayListWidget::openFile() {
}
-// 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 );
-
}
@@ -828,3 +742,12 @@ void PlayListWidget::openFile() {
}
+ 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 ) {
@@ -835,3 +758,3 @@ void PlayListWidget::openFile() {
/*
-reads m3u and adds files/urls to playlist */
+reads m3u and shows files/urls to playlist widget */
void PlayListWidget::readm3u( const QString &filename ) {
@@ -846,5 +769,10 @@ void PlayListWidget::readm3u( const QString &filename ) {
s = *it;
- s.replace( QRegExp( "%20" )," " );
+// s.replace( QRegExp( "%20" )," " );
// qDebug("reading "+ s);
-
+ 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() ) {
@@ -856,6 +784,6 @@ void PlayListWidget::readm3u( const QString &filename ) {
lnk.setFile( s+"/"); //if url with no extension
-
- d->selectedFiles->addToSelection( lnk );
}
}
+ d->selectedFiles->addToSelection( lnk );
+ }
Config config( "OpiePlayer" );
@@ -867,2 +795,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
+// m3uList->write();
m3uList->close();
@@ -871,3 +800,3 @@ void PlayListWidget::readm3u( const QString &filename ) {
d->selectedFiles->setSelectedItem( s);
- setCaption(tr("OpiePlayer: ")+ filename);
+ setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
@@ -928,3 +857,3 @@ void PlayListWidget::writeCurrentM3u() {
Om3u *m3uList;
- m3uList = new Om3u( currentPlaylist, IO_ReadWrite );
+ m3uList = new Om3u( currentPlaylist, IO_ReadWrite |IO_Truncate );
d->selectedFiles->first();
@@ -937,2 +866,4 @@ void PlayListWidget::writeCurrentM3u() {
m3uList->write();
+ m3uList->close();
+
if(m3uList) delete m3uList;
@@ -971,2 +902,4 @@ void PlayListWidget::writem3u() {
m3uList->write();
+ m3uList->close();
+
}