summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-08 19:37:34 (UTC)
committer llornkcor <llornkcor>2002-10-08 19:37:34 (UTC)
commitb81a4afcb4d363bf1ee50aa7b43a1f1566addc9d (patch) (side-by-side diff)
tree60246a741e7895f5efe6755c2aee455376ca0939
parentde9496b2e6e2784dc4cc83dd5800f89f0954affc (diff)
downloadopie-b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d.zip
opie-b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d.tar.gz
opie-b81a4afcb4d363bf1ee50aa7b43a1f1566addc9d.tar.bz2
more fixes 2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index cc4be23..c0d3108 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -476,49 +476,49 @@ void PlayListWidget::addSelected() {
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();
}
@@ -702,72 +702,63 @@ 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 );
Om3u *m3uList;
DocLnk lnk;
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);
- 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 name
lnk.setFile( filename ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
d->selectedFiles->addToSelection( lnk );
+ writeCurrentM3u();
}
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;
+ } else {
d->selectedFiles->addToSelection( DocLnk(filename) );
+ writeCurrentM3u();
}
}
if( fileDlg ) {
delete fileDlg;
}
}
/*
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" )," " );
// qDebug("reading "+ s);
if(s.left(4)=="http") {
lnk.setName( s ); //sets file name
@@ -828,80 +819,80 @@ void PlayListWidget::readPls( const QString &filename ) {
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
lnk.setName( name );
if( s.at( s.length() - 4) == '.') {// if this is probably a file
lnk.setFile( s );
} else { //if its a url
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");
+ 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 );
d->selectedFiles->first();
do {
m3uList->add( d->selectedFiles->current()->file());
}
while ( d->selectedFiles->next() );
- // qDebug( list );
+// 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 );
+// 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;