Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 10f1792..251c2e5 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -544,97 +544,97 @@ bool PlayListWidget::prev() { | |||
544 | } | 544 | } |
545 | 545 | ||
546 | 546 | ||
547 | bool PlayListWidget::next() { | 547 | bool PlayListWidget::next() { |
548 | if ( mediaPlayerState->playlist() ) { | 548 | if ( mediaPlayerState->playlist() ) { |
549 | if ( mediaPlayerState->shuffled() ) { | 549 | if ( mediaPlayerState->shuffled() ) { |
550 | return prev(); | 550 | return prev(); |
551 | } else { | 551 | } else { |
552 | if ( !d->selectedFiles->next() ) { | 552 | if ( !d->selectedFiles->next() ) { |
553 | if ( mediaPlayerState->looping() ) { | 553 | if ( mediaPlayerState->looping() ) { |
554 | return d->selectedFiles->first(); | 554 | return d->selectedFiles->first(); |
555 | } else { | 555 | } else { |
556 | return FALSE; | 556 | return FALSE; |
557 | } | 557 | } |
558 | } | 558 | } |
559 | return TRUE; | 559 | return TRUE; |
560 | } | 560 | } |
561 | } else { | 561 | } else { |
562 | return mediaPlayerState->looping(); | 562 | return mediaPlayerState->looping(); |
563 | } | 563 | } |
564 | } | 564 | } |
565 | 565 | ||
566 | 566 | ||
567 | bool PlayListWidget::first() { | 567 | bool PlayListWidget::first() { |
568 | if ( mediaPlayerState->playlist() ) | 568 | if ( mediaPlayerState->playlist() ) |
569 | return d->selectedFiles->first(); | 569 | return d->selectedFiles->first(); |
570 | else | 570 | else |
571 | return mediaPlayerState->looping(); | 571 | return mediaPlayerState->looping(); |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | bool PlayListWidget::last() { | 575 | bool PlayListWidget::last() { |
576 | if ( mediaPlayerState->playlist() ) | 576 | if ( mediaPlayerState->playlist() ) |
577 | return d->selectedFiles->last(); | 577 | return d->selectedFiles->last(); |
578 | else | 578 | else |
579 | return mediaPlayerState->looping(); | 579 | return mediaPlayerState->looping(); |
580 | } | 580 | } |
581 | 581 | ||
582 | 582 | ||
583 | void PlayListWidget::saveList() { | 583 | void PlayListWidget::saveList() { |
584 | 584 | ||
585 | QString filename; | 585 | QString filename; |
586 | InputDialog *fileDlg = 0l; | 586 | InputDialog *fileDlg = 0l; |
587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
588 | fileDlg->exec(); | 588 | fileDlg->exec(); |
589 | if( fileDlg->result() == 1 ) { | 589 | if( fileDlg->result() == 1 ) { |
590 | if ( d->current ) | 590 | if ( d->current ) |
591 | delete d->current; | 591 | delete d->current; |
592 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 592 | filename = fileDlg->text();//+".playlist"; |
593 | // qDebug("saving playlist "+filename+".playlist"); | 593 | // qDebug("saving playlist "+filename+".playlist"); |
594 | Config cfg( filename +".playlist"); | 594 | Config cfg( filename +".playlist"); |
595 | writeConfig( cfg ); | 595 | writeConfig( cfg ); |
596 | 596 | ||
597 | DocLnk lnk; | 597 | DocLnk lnk; |
598 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 598 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
599 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 599 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
600 | lnk.setIcon("opieplayer2/playlist2"); | 600 | lnk.setIcon("opieplayer2/playlist2"); |
601 | lnk.setName( filename); //sets file name | 601 | lnk.setName( filename); //sets file name |
602 | // qDebug(filename); | 602 | // qDebug(filename); |
603 | if(!lnk.writeLink()) { | 603 | if(!lnk.writeLink()) { |
604 | qDebug("Writing doclink did not work"); | 604 | qDebug("Writing doclink did not work"); |
605 | } | 605 | } |
606 | } | 606 | } |
607 | Config config( "OpiePlayer" ); | 607 | Config config( "OpiePlayer" ); |
608 | config.writeEntry("CurrentPlaylist",filename); | 608 | config.writeEntry("CurrentPlaylist",filename); |
609 | setCaption(tr("OpiePlayer: ")+filename); | 609 | setCaption(tr("OpiePlayer: ")+filename); |
610 | d->selectedFiles->first(); | 610 | d->selectedFiles->first(); |
611 | if(fileDlg) { | 611 | if(fileDlg) { |
612 | delete fileDlg; | 612 | delete fileDlg; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | 615 | ||
616 | void PlayListWidget::loadList( const DocLnk & lnk) { | 616 | void PlayListWidget::loadList( const DocLnk & lnk) { |
617 | QString name= lnk.name(); | 617 | QString name= lnk.name(); |
618 | // qDebug("currentList is "+name); | 618 | // qDebug("currentList is "+name); |
619 | if( name.length()>1) { | 619 | if( name.length()>1) { |
620 | setCaption("OpiePlayer: "+name); | 620 | setCaption("OpiePlayer: "+name); |
621 | // qDebug("load list "+ name+".playlist"); | 621 | // qDebug("load list "+ name+".playlist"); |
622 | clearList(); | 622 | clearList(); |
623 | Config cfg( name+".playlist"); | 623 | Config cfg( name+".playlist"); |
624 | readConfig(cfg); | 624 | readConfig(cfg); |
625 | 625 | ||
626 | tabWidget->setCurrentPage(0); | 626 | tabWidget->setCurrentPage(0); |
627 | 627 | ||
628 | Config config( "OpiePlayer" ); | 628 | Config config( "OpiePlayer" ); |
629 | config.writeEntry("CurrentPlaylist", name); | 629 | config.writeEntry("CurrentPlaylist", name); |
630 | // d->selectedFiles->first(); | 630 | // d->selectedFiles->first(); |
631 | } | 631 | } |
632 | 632 | ||
633 | } | 633 | } |
634 | 634 | ||
635 | void PlayListWidget::setPlaylist( bool shown ) { | 635 | void PlayListWidget::setPlaylist( bool shown ) { |
636 | if ( shown ) { | 636 | if ( shown ) { |
637 | d->playListFrame->show(); | 637 | d->playListFrame->show(); |
638 | } else { | 638 | } else { |
639 | d->playListFrame->hide(); | 639 | d->playListFrame->hide(); |
640 | } | 640 | } |
@@ -903,97 +903,97 @@ void PlayListWidget::populateAudioView() { | |||
903 | const QString path = (*it)->path(); | 903 | const QString path = (*it)->path(); |
904 | if(dit.current()->file().find(path) != -1 ) storage=name; | 904 | if(dit.current()->file().find(path) != -1 ) storage=name; |
905 | } | 905 | } |
906 | 906 | ||
907 | QListViewItem * newItem; | 907 | QListViewItem * newItem; |
908 | if ( QFile( dit.current()->file()).exists() ) { | 908 | if ( QFile( dit.current()->file()).exists() ) { |
909 | // qDebug(dit.current()->name()); | 909 | // qDebug(dit.current()->name()); |
910 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 910 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
911 | QString::number( QFile( dit.current()->file()).size() ), storage); | 911 | QString::number( QFile( dit.current()->file()).size() ), storage); |
912 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); | 912 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | 915 | ||
916 | } | 916 | } |
917 | 917 | ||
918 | void PlayListWidget::populateVideoView() { | 918 | void PlayListWidget::populateVideoView() { |
919 | videoView->clear(); | 919 | videoView->clear(); |
920 | StorageInfo storageInfo; | 920 | StorageInfo storageInfo; |
921 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 921 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
922 | 922 | ||
923 | if(!videoScan ) scanForVideo(); | 923 | if(!videoScan ) scanForVideo(); |
924 | 924 | ||
925 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 925 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
926 | QListIterator<FileSystem> it ( fs ); | 926 | QListIterator<FileSystem> it ( fs ); |
927 | videoView->clear(); | 927 | videoView->clear(); |
928 | QString storage; | 928 | QString storage; |
929 | for ( ; Vdit.current(); ++Vdit ) { | 929 | for ( ; Vdit.current(); ++Vdit ) { |
930 | for( ; it.current(); ++it ){ | 930 | for( ; it.current(); ++it ){ |
931 | const QString name = (*it)->name(); | 931 | const QString name = (*it)->name(); |
932 | const QString path = (*it)->path(); | 932 | const QString path = (*it)->path(); |
933 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 933 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
934 | } | 934 | } |
935 | 935 | ||
936 | QListViewItem * newItem; | 936 | QListViewItem * newItem; |
937 | if ( QFile( Vdit.current()->file()).exists() ) { | 937 | if ( QFile( Vdit.current()->file()).exists() ) { |
938 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 938 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
939 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 939 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
940 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); | 940 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); |
941 | } | 941 | } |
942 | } | 942 | } |
943 | } | 943 | } |
944 | 944 | ||
945 | void PlayListWidget::openFile() { | 945 | void PlayListWidget::openFile() { |
946 | QString filename, name; | 946 | QString filename, name; |
947 | InputDialog *fileDlg; | 947 | InputDialog *fileDlg; |
948 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 948 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
949 | fileDlg->exec(); | 949 | fileDlg->exec(); |
950 | if( fileDlg->result() == 1 ) { | 950 | if( fileDlg->result() == 1 ) { |
951 | filename = fileDlg->LineEdit1->text(); | 951 | filename = fileDlg->text(); |
952 | 952 | ||
953 | qDebug("Selected filename is "+filename); | 953 | qDebug("Selected filename is "+filename); |
954 | if(filename.right(3) == "m3u") { | 954 | if(filename.right(3) == "m3u") { |
955 | readm3u( filename ); | 955 | readm3u( filename ); |
956 | } else if(filename.right(3) == "pls") { | 956 | } else if(filename.right(3) == "pls") { |
957 | readPls( filename ); | 957 | readPls( filename ); |
958 | } else { | 958 | } else { |
959 | DocLnk lnk; | 959 | DocLnk lnk; |
960 | 960 | ||
961 | lnk.setName(filename); //sets file name | 961 | lnk.setName(filename); //sets file name |
962 | lnk.setFile(filename); //sets File property | 962 | lnk.setFile(filename); //sets File property |
963 | lnk.setType("audio/x-mpegurl"); | 963 | lnk.setType("audio/x-mpegurl"); |
964 | lnk.setExec("opieplayer"); | 964 | lnk.setExec("opieplayer"); |
965 | lnk.setIcon("opieplayer2/MPEGPlayer"); | 965 | lnk.setIcon("opieplayer2/MPEGPlayer"); |
966 | 966 | ||
967 | if(!lnk.writeLink()) { | 967 | if(!lnk.writeLink()) { |
968 | qDebug("Writing doclink did not work"); | 968 | qDebug("Writing doclink did not work"); |
969 | } | 969 | } |
970 | d->selectedFiles->addToSelection( lnk); | 970 | d->selectedFiles->addToSelection( lnk); |
971 | } | 971 | } |
972 | } | 972 | } |
973 | if(fileDlg) { | 973 | if(fileDlg) { |
974 | delete fileDlg; | 974 | delete fileDlg; |
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 978 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
979 | { | 979 | { |
980 | switch ( e->key() ) { | 980 | switch ( e->key() ) { |
981 | ////////////////////////////// Zaurus keys | 981 | ////////////////////////////// Zaurus keys |
982 | case Key_F9: //activity | 982 | case Key_F9: //activity |
983 | // if(audioUI->isHidden()) | 983 | // if(audioUI->isHidden()) |
984 | // audioUI->showMaximized(); | 984 | // audioUI->showMaximized(); |
985 | break; | 985 | break; |
986 | case Key_F10: //contacts | 986 | case Key_F10: //contacts |
987 | // if( videoUI->isHidden()) | 987 | // if( videoUI->isHidden()) |
988 | // videoUI->showMaximized(); | 988 | // videoUI->showMaximized(); |
989 | break; | 989 | break; |
990 | case Key_F11: //menu | 990 | case Key_F11: //menu |
991 | break; | 991 | break; |
992 | case Key_F12: //home | 992 | case Key_F12: //home |
993 | // doBlank(); | 993 | // doBlank(); |
994 | break; | 994 | break; |
995 | case Key_F13: //mail | 995 | case Key_F13: //mail |
996 | // doUnblank(); | 996 | // doUnblank(); |
997 | break; | 997 | break; |
998 | case Key_Q: //add to playlist | 998 | case Key_Q: //add to playlist |
999 | qDebug("Add"); | 999 | qDebug("Add"); |
@@ -1078,97 +1078,97 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1078 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1078 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1079 | s=s.right(s.length()-2); | 1079 | s=s.right(s.length()-2); |
1080 | // if(QFile(s).exists()) { | 1080 | // if(QFile(s).exists()) { |
1081 | DocLnk lnk( s ); | 1081 | DocLnk lnk( s ); |
1082 | QFileInfo f(s); | 1082 | QFileInfo f(s); |
1083 | QString name = f.baseName(); | 1083 | QString name = f.baseName(); |
1084 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1084 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1085 | lnk.setName( name ); | 1085 | lnk.setName( name ); |
1086 | s=s.replace( QRegExp("\\"),"/"); | 1086 | s=s.replace( QRegExp("\\"),"/"); |
1087 | lnk.setFile( s ); | 1087 | lnk.setFile( s ); |
1088 | lnk.writeLink(); | 1088 | lnk.writeLink(); |
1089 | qDebug("add "+name); | 1089 | qDebug("add "+name); |
1090 | d->selectedFiles->addToSelection( lnk); | 1090 | d->selectedFiles->addToSelection( lnk); |
1091 | // } | 1091 | // } |
1092 | } else { // is url | 1092 | } else { // is url |
1093 | s.replace(QRegExp("%20")," "); | 1093 | s.replace(QRegExp("%20")," "); |
1094 | DocLnk lnk( s ); | 1094 | DocLnk lnk( s ); |
1095 | QString name; | 1095 | QString name; |
1096 | if(name.left(4)=="http") { | 1096 | if(name.left(4)=="http") { |
1097 | name = s.right( s.length() - 7); | 1097 | name = s.right( s.length() - 7); |
1098 | } else { | 1098 | } else { |
1099 | name = s; | 1099 | name = s; |
1100 | } | 1100 | } |
1101 | lnk.setName(name); | 1101 | lnk.setName(name); |
1102 | if(s.at(s.length()-4) == '.') { | 1102 | if(s.at(s.length()-4) == '.') { |
1103 | lnk.setFile( s); | 1103 | lnk.setFile( s); |
1104 | } else { | 1104 | } else { |
1105 | lnk.setFile( s+"/"); | 1105 | lnk.setFile( s+"/"); |
1106 | } | 1106 | } |
1107 | lnk.setType("audio/x-mpegurl"); | 1107 | lnk.setType("audio/x-mpegurl"); |
1108 | lnk.writeLink(); | 1108 | lnk.writeLink(); |
1109 | d->selectedFiles->addToSelection( lnk); | 1109 | d->selectedFiles->addToSelection( lnk); |
1110 | } | 1110 | } |
1111 | i++; | 1111 | i++; |
1112 | } | 1112 | } |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | f.close(); | 1116 | f.close(); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void PlayListWidget::writem3u() { | 1119 | void PlayListWidget::writem3u() { |
1120 | 1120 | ||
1121 | InputDialog *fileDlg; | 1121 | InputDialog *fileDlg; |
1122 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1122 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1123 | fileDlg->exec(); | 1123 | fileDlg->exec(); |
1124 | QString filename,list; | 1124 | QString filename,list; |
1125 | if( fileDlg->result() == 1 ) { | 1125 | if( fileDlg->result() == 1 ) { |
1126 | filename = fileDlg->LineEdit1->text(); | 1126 | filename = fileDlg->text(); |
1127 | qDebug(filename); | 1127 | qDebug(filename); |
1128 | int noOfFiles = 0; | 1128 | int noOfFiles = 0; |
1129 | d->selectedFiles->first(); | 1129 | d->selectedFiles->first(); |
1130 | do { | 1130 | do { |
1131 | // we dont check for existance because of url's | 1131 | // we dont check for existance because of url's |
1132 | // qDebug(d->selectedFiles->current()->file()); | 1132 | // qDebug(d->selectedFiles->current()->file()); |
1133 | list += d->selectedFiles->current()->file()+"\n"; | 1133 | list += d->selectedFiles->current()->file()+"\n"; |
1134 | noOfFiles++; | 1134 | noOfFiles++; |
1135 | } | 1135 | } |
1136 | while ( d->selectedFiles->next() ); | 1136 | while ( d->selectedFiles->next() ); |
1137 | qDebug(list); | 1137 | qDebug(list); |
1138 | if(filename.left(1) != "/") | 1138 | if(filename.left(1) != "/") |
1139 | filename=QPEApplication::documentDir()+"/"+filename; | 1139 | filename=QPEApplication::documentDir()+"/"+filename; |
1140 | if(filename.right(3) != "m3u") | 1140 | if(filename.right(3) != "m3u") |
1141 | filename=filename+".m3u"; | 1141 | filename=filename+".m3u"; |
1142 | 1142 | ||
1143 | QFile f(filename); | 1143 | QFile f(filename); |
1144 | f.open(IO_WriteOnly); | 1144 | f.open(IO_WriteOnly); |
1145 | f.writeBlock(list, list.length()); | 1145 | f.writeBlock(list, list.length()); |
1146 | f.close(); | 1146 | f.close(); |
1147 | } | 1147 | } |
1148 | if(fileDlg) delete fileDlg; | 1148 | if(fileDlg) delete fileDlg; |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | void PlayListWidget::readPls(const QString &filename) { | 1151 | void PlayListWidget::readPls(const QString &filename) { |
1152 | 1152 | ||
1153 | qDebug("pls filename is "+filename); | 1153 | qDebug("pls filename is "+filename); |
1154 | QFile f(filename); | 1154 | QFile f(filename); |
1155 | 1155 | ||
1156 | if(f.open(IO_ReadOnly)) { | 1156 | if(f.open(IO_ReadOnly)) { |
1157 | QTextStream t(&f); | 1157 | QTextStream t(&f); |
1158 | QString s;//, first, second; | 1158 | QString s;//, first, second; |
1159 | int i=0; | 1159 | int i=0; |
1160 | while ( !t.atEnd()) { | 1160 | while ( !t.atEnd()) { |
1161 | s=t.readLine(); | 1161 | s=t.readLine(); |
1162 | if(s.left(4) == "File") { | 1162 | if(s.left(4) == "File") { |
1163 | s=s.right(s.length() - 6); | 1163 | s=s.right(s.length() - 6); |
1164 | s.replace(QRegExp("%20")," "); | 1164 | s.replace(QRegExp("%20")," "); |
1165 | qDebug("adding "+s+" to playlist"); | 1165 | qDebug("adding "+s+" to playlist"); |
1166 | // numberofentries=2 | 1166 | // numberofentries=2 |
1167 | // File1=http | 1167 | // File1=http |
1168 | // Title | 1168 | // Title |
1169 | // Length | 1169 | // Length |
1170 | // Version | 1170 | // Version |
1171 | // File2=http | 1171 | // File2=http |
1172 | s=s.replace( QRegExp("\\"),"/"); | 1172 | s=s.replace( QRegExp("\\"),"/"); |
1173 | DocLnk lnk( s ); | 1173 | DocLnk lnk( s ); |
1174 | QFileInfo f(s); | 1174 | QFileInfo f(s); |