-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 | |||
@@ -319,18 +319,20 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
319 | QString currentString = cfg.readEntry("current", "" ); | 319 | QString currentString = cfg.readEntry("current", "" ); |
320 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 320 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
321 | for ( int i = 0; i < noOfFiles; i++ ) { | 321 | for ( int i = 0; i < noOfFiles; i++ ) { |
322 | QString entryName; | 322 | QString entryName; |
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 | ||
333 | 335 | ||
334 | void PlayListWidget::writeConfig( Config& cfg ) const { | 336 | void PlayListWidget::writeConfig( Config& cfg ) const { |
335 | 337 | ||
336 | d->selectedFiles->writeCurrent( cfg); | 338 | d->selectedFiles->writeCurrent( cfg); |
@@ -648,13 +650,14 @@ void PlayListWidget::addSelected() { | |||
648 | // iterate through all items of the listview | 650 | // iterate through all items of the listview |
649 | for ( ; it.current(); ++it ) { | 651 | for ( ; it.current(); ++it ) { |
650 | if ( it.current()->isSelected() ) { | 652 | if ( it.current()->isSelected() ) { |
651 | QListIterator<DocLnk> dit( files.children() ); | 653 | QListIterator<DocLnk> dit( files.children() ); |
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 | } |
657 | audioView->setSelected( it.current(),FALSE); | 660 | audioView->setSelected( it.current(),FALSE); |
658 | } | 661 | } |
659 | } | 662 | } |
660 | tabWidget->setCurrentPage(0); | 663 | tabWidget->setCurrentPage(0); |
@@ -665,13 +668,14 @@ void PlayListWidget::addSelected() { | |||
665 | // iterate through all items of the listview | 668 | // iterate through all items of the listview |
666 | for ( ; it.current(); ++it ) { | 669 | for ( ; it.current(); ++it ) { |
667 | if ( it.current()->isSelected() ) { | 670 | if ( it.current()->isSelected() ) { |
668 | QListIterator<DocLnk> dit( vFiles.children() ); | 671 | QListIterator<DocLnk> dit( vFiles.children() ); |
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 | } |
674 | videoView->setSelected( it.current(),FALSE); | 678 | videoView->setSelected( it.current(),FALSE); |
675 | } | 679 | } |
676 | } | 680 | } |
677 | tabWidget->setCurrentPage(0); | 681 | tabWidget->setCurrentPage(0); |
@@ -698,22 +702,24 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
698 | if(it) { | 702 | if(it) { |
699 | switch (tabWidget->currentPageIndex()) { | 703 | switch (tabWidget->currentPageIndex()) { |
700 | case 1: { | 704 | case 1: { |
701 | QListIterator<DocLnk> dit( files.children() ); | 705 | QListIterator<DocLnk> dit( files.children() ); |
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 | } |
707 | } | 712 | } |
708 | break; | 713 | break; |
709 | case 2: { | 714 | case 2: { |
710 | QListIterator<DocLnk> dit( vFiles.children() ); | 715 | QListIterator<DocLnk> dit( vFiles.children() ); |
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 | } |
716 | } | 722 | } |
717 | break; | 723 | break; |
718 | case 0: | 724 | case 0: |
719 | break; | 725 | break; |
@@ -1108,22 +1114,24 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1108 | s=t.readLine(); | 1114 | s=t.readLine(); |
1109 | 1115 | ||
1110 | if(s.find("#",0,TRUE) == -1) { | 1116 | if(s.find("#",0,TRUE) == -1) { |
1111 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1117 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
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")," "); |
1126 | DocLnk lnk( s ); | 1134 | DocLnk lnk( s ); |
1127 | QString name; | 1135 | QString name; |
1128 | if(name.left(4)=="http") { | 1136 | if(name.left(4)=="http") { |
1129 | name = s.right( s.length() - 7); | 1137 | name = s.right( s.length() - 7); |