summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-16 02:46:12 (UTC)
committer llornkcor <llornkcor>2002-08-16 02:46:12 (UTC)
commit40527ffb82b83ad521ed766f11b47636db055ffe (patch) (side-by-side diff)
treed94fb1f21fa57b9dfbe2aa45beab05de024c97a3
parentf25db7780ff234b2770ac13d8c02887b79a57a26 (diff)
downloadopie-40527ffb82b83ad521ed766f11b47636db055ffe.zip
opie-40527ffb82b83ad521ed766f11b47636db055ffe.tar.gz
opie-40527ffb82b83ad521ed766f11b47636db055ffe.tar.bz2
check for local file existing before adding to playlist
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp44
1 files changed, 26 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index e33998f..612fd45 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -313,30 +313,32 @@ void PlayListWidget::initializeStates() {
setPlaylist( true);
}
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 );
- DocLnk lnk( linkFile );
- if ( lnk.isValid() ) {
- d->selectedFiles->addToSelection( lnk );
+ 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);
+d->selectedFiles->setSelectedItem( currentString);
}
void PlayListWidget::writeConfig( Config& cfg ) const {
d->selectedFiles->writeCurrent( cfg);
cfg.setGroup("PlayList");
int noOfFiles = 0;
d->selectedFiles->first();
do {
const DocLnk *lnk = d->selectedFiles->current();
if ( lnk ) {
@@ -642,42 +644,44 @@ void PlayListWidget::addSelected() {
switch (tabWidget->currentPageIndex()) {
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) ) {
- d->selectedFiles->addToSelection( **dit );
+ if(QFileInfo( dit.current()->file()).exists())
+ d->selectedFiles->addToSelection( **dit );
}
}
audioView->setSelected( it.current(),FALSE);
}
}
tabWidget->setCurrentPage(0);
}
break;
case 2: { // video
QListViewItemIterator it( videoView );
// 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) ) {
- d->selectedFiles->addToSelection( **dit );
+ if(QFileInfo( dit.current()->file()).exists())
+ d->selectedFiles->addToSelection( **dit );
}
}
videoView->setSelected( it.current(),FALSE);
}
}
tabWidget->setCurrentPage(0);
}
break;
};
}
void PlayListWidget::removeSelected() {
@@ -692,34 +696,36 @@ void PlayListWidget::playIt( QListViewItem *it) {
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
switch (tabWidget->currentPageIndex()) {
case 1: {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it->text(0)) {
- d->selectedFiles->addToSelection( **dit );
+ if(QFileInfo( dit.current()->file()).exists())
+ d->selectedFiles->addToSelection( **dit );
}
}
}
break;
case 2: {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it->text(0)) {
- d->selectedFiles->addToSelection( **dit );
+ if(QFileInfo( dit.current()->file()).exists())
+ d->selectedFiles->addToSelection( **dit );
}
}
}
break;
case 0:
break;
};
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::tabChanged(QWidget *) {
@@ -1102,34 +1108,36 @@ void PlayListWidget::readm3u(const QString &filename) {
if(f.open(IO_ReadOnly)) {
QTextStream t(&f);
QString s;//, first, second;
int i=0;
while ( !t.atEnd()) {
s=t.readLine();
if(s.find("#",0,TRUE) == -1) {
if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
if(s.left(2) == "E:" || s.left(2) == "P:") {
s=s.right(s.length()-2);
- DocLnk lnk( s );
- QFileInfo f(s);
- QString name = f.baseName();
- name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
- lnk.setName( name );
- s=s.replace( QRegExp("\\"),"/");
- lnk.setFile( s );
- lnk.writeLink();
- qDebug("add "+name);
- d->selectedFiles->addToSelection( lnk);
+ if(QFile(s).exists()) {
+ DocLnk lnk( s );
+ QFileInfo f(s);
+ QString name = f.baseName();
+ name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
+ lnk.setName( name );
+ s=s.replace( QRegExp("\\"),"/");
+ lnk.setFile( s );
+ lnk.writeLink();
+ qDebug("add "+name);
+ d->selectedFiles->addToSelection( lnk);
+ }
} else { // is url
s.replace(QRegExp("%20")," ");
DocLnk lnk( s );
QString name;
if(name.left(4)=="http") {
name = s.right( s.length() - 7);
} else {
name = s;
}
lnk.setName(name);
if(s.at(s.length()-4) == '.') {
lnk.setFile( s);