author | llornkcor <llornkcor> | 2002-08-16 02:46:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-16 02:46:12 (UTC) |
commit | 40527ffb82b83ad521ed766f11b47636db055ffe (patch) (unidiff) | |
tree | d94fb1f21fa57b9dfbe2aa45beab05de024c97a3 | |
parent | f25db7780ff234b2770ac13d8c02887b79a57a26 (diff) | |
download | opie-40527ffb82b83ad521ed766f11b47636db055ffe.zip opie-40527ffb82b83ad521ed766f11b47636db055ffe.tar.gz opie-40527ffb82b83ad521ed766f11b47636db055ffe.tar.bz2 |
check for local file existing before adding to playlist
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 44 |
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 | |||
@@ -323,10 +323,12 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
323 | entryName.sprintf( "File%i", i + 1 ); | 323 | entryName.sprintf( "File%i", i + 1 ); |
324 | QString linkFile = cfg.readEntry( entryName ); | 324 | QString linkFile = cfg.readEntry( entryName ); |
325 | DocLnk lnk( linkFile ); | 325 | if(QFileInfo( linkFile).exists() ) { |
326 | if ( lnk.isValid() ) { | 326 | DocLnk lnk( linkFile ); |
327 | d->selectedFiles->addToSelection( lnk ); | 327 | if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { |
328 | d->selectedFiles->addToSelection( lnk ); | ||
329 | } | ||
328 | } | 330 | } |
329 | } | 331 | } |
330 | d->selectedFiles->setSelectedItem( currentString); | 332 | d->selectedFiles->setSelectedItem( currentString); |
331 | } | 333 | } |
332 | 334 | ||
@@ -652,5 +654,6 @@ void PlayListWidget::addSelected() { | |||
652 | for ( ; dit.current(); ++dit ) { | 654 | for ( ; dit.current(); ++dit ) { |
653 | if( dit.current()->name() == it.current()->text(0) ) { | 655 | if( dit.current()->name() == it.current()->text(0) ) { |
654 | d->selectedFiles->addToSelection( **dit ); | 656 | if(QFileInfo( dit.current()->file()).exists()) |
657 | d->selectedFiles->addToSelection( **dit ); | ||
655 | } | 658 | } |
656 | } | 659 | } |
@@ -669,5 +672,6 @@ void PlayListWidget::addSelected() { | |||
669 | for ( ; dit.current(); ++dit ) { | 672 | for ( ; dit.current(); ++dit ) { |
670 | if( dit.current()->name() == it.current()->text(0) ) { | 673 | if( dit.current()->name() == it.current()->text(0) ) { |
671 | d->selectedFiles->addToSelection( **dit ); | 674 | if(QFileInfo( dit.current()->file()).exists()) |
675 | d->selectedFiles->addToSelection( **dit ); | ||
672 | } | 676 | } |
673 | } | 677 | } |
@@ -702,5 +706,6 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
702 | for ( ; dit.current(); ++dit ) { | 706 | for ( ; dit.current(); ++dit ) { |
703 | if( dit.current()->name() == it->text(0)) { | 707 | if( dit.current()->name() == it->text(0)) { |
704 | d->selectedFiles->addToSelection( **dit ); | 708 | if(QFileInfo( dit.current()->file()).exists()) |
709 | d->selectedFiles->addToSelection( **dit ); | ||
705 | } | 710 | } |
706 | } | 711 | } |
@@ -711,5 +716,6 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
711 | for ( ; dit.current(); ++dit ) { | 716 | for ( ; dit.current(); ++dit ) { |
712 | if( dit.current()->name() == it->text(0)) { | 717 | if( dit.current()->name() == it->text(0)) { |
713 | d->selectedFiles->addToSelection( **dit ); | 718 | if(QFileInfo( dit.current()->file()).exists()) |
719 | d->selectedFiles->addToSelection( **dit ); | ||
714 | } | 720 | } |
715 | } | 721 | } |
@@ -1112,14 +1118,16 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1112 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1118 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1113 | s=s.right(s.length()-2); | 1119 | s=s.right(s.length()-2); |
1114 | DocLnk lnk( s ); | 1120 | if(QFile(s).exists()) { |
1115 | QFileInfo f(s); | 1121 | DocLnk lnk( s ); |
1116 | QString name = f.baseName(); | 1122 | QFileInfo f(s); |
1117 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1123 | QString name = f.baseName(); |
1118 | lnk.setName( name ); | 1124 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1119 | s=s.replace( QRegExp("\\"),"/"); | 1125 | lnk.setName( name ); |
1120 | lnk.setFile( s ); | 1126 | s=s.replace( QRegExp("\\"),"/"); |
1121 | lnk.writeLink(); | 1127 | lnk.setFile( s ); |
1122 | qDebug("add "+name); | 1128 | lnk.writeLink(); |
1123 | d->selectedFiles->addToSelection( lnk); | 1129 | qDebug("add "+name); |
1130 | d->selectedFiles->addToSelection( lnk); | ||
1131 | } | ||
1124 | } else { // is url | 1132 | } else { // is url |
1125 | s.replace(QRegExp("%20")," "); | 1133 | s.replace(QRegExp("%20")," "); |