summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp11
3 files changed, 15 insertions, 8 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 0ced256..c54a00f 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -408,226 +408,226 @@ bool LauncherIconView::removeLink(const QString& linkfile)
408 delete item; 408 delete item;
409 did = TRUE; 409 did = TRUE;
410 } 410 }
411 item = (LauncherItem*)item->nextItem(); 411 item = (LauncherItem*)item->nextItem();
412 } 412 }
413 QListIterator<AppLnk> it(hidden); 413 QListIterator<AppLnk> it(hidden);
414 while ((l=it.current())) { 414 while ((l=it.current())) {
415 ++it; 415 ++it;
416 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { 416 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) {
417 hidden.removeRef(l); 417 hidden.removeRef(l);
418 did = TRUE; 418 did = TRUE;
419 } 419 }
420 } 420 }
421 return did; 421 return did;
422} 422}
423 423
424LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 424LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
425 : QVBox( parent, name, fl ) 425 : QVBox( parent, name, fl )
426{ 426{
427 icons = new LauncherIconView( this ); 427 icons = new LauncherIconView( this );
428 setFocusProxy(icons); 428 setFocusProxy(icons);
429 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 429 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
430 430
431 int dw = QApplication::desktop()->width(); 431 int dw = QApplication::desktop()->width();
432 icons->setItemsMovable( FALSE ); 432 icons->setItemsMovable( FALSE );
433 icons->setAutoArrange( TRUE ); 433 icons->setAutoArrange( TRUE );
434 icons->setSorting( TRUE ); 434 icons->setSorting( TRUE );
435 icons->setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240 435 icons->setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240
436 icons->setGridY( fontMetrics().height()*2+24 ); 436 icons->setGridY( fontMetrics().height()*2+24 );
437 icons->setFrameStyle( QFrame::NoFrame ); 437 icons->setFrameStyle( QFrame::NoFrame );
438 icons->setSpacing( 4 ); 438 icons->setSpacing( 4 );
439 icons->setMargin( 0 ); 439 icons->setMargin( 0 );
440 icons->setSelectionMode( QIconView::Multi ); 440 icons->setSelectionMode( QIconView::Multi );
441 icons->setBackgroundMode( PaletteBase ); 441 icons->setBackgroundMode( PaletteBase );
442 442
443 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 443 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
444 SLOT(itemClicked(int, QIconViewItem *)) ); 444 SLOT(itemClicked(int, QIconViewItem *)) );
445 connect( icons, SIGNAL(selectionChanged()), 445 connect( icons, SIGNAL(selectionChanged()),
446 SLOT(selectionChanged()) ); 446 SLOT(selectionChanged()) );
447 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 447 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
448 SLOT(returnPressed(QIconViewItem *)) ); 448 SLOT(returnPressed(QIconViewItem *)) );
449 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 449 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
450 SLOT(itemPressed(int, QIconViewItem *)) ); 450 SLOT(itemPressed(int, QIconViewItem *)) );
451 451
452 tools = 0; 452 tools = 0;
453} 453}
454 454
455LauncherView::~LauncherView() 455LauncherView::~LauncherView()
456{ 456{
457} 457}
458 458
459void LauncherView::setToolsEnabled(bool y) 459void LauncherView::setToolsEnabled(bool y)
460{ 460{
461 if ( !y != !tools ) { 461 if ( !y != !tools ) {
462 if ( y ) { 462 if ( y ) {
463 tools = new QHBox(this); 463 tools = new QHBox(this);
464 464
465 // Type filter 465 // Type filter
466 typemb = new MenuButton(tools); 466 typemb = new MenuButton(tools);
467 typemb->setLabel(tr("Type: %1")); 467 typemb->setLabel(tr("Type: %1"));
468 typemb->setFixedHeight ( 20 ); 468 typemb->setFixedHeight ( 20 );
469 469
470 // Category filter 470 // Category filter
471 catmb = new CategorySelect(tools); 471 catmb = new CategorySelect(tools);
472 catmb->setFixedHeight ( 20 ); 472 catmb->setFixedHeight ( 20 );
473 473
474 updateTools(); 474 updateTools();
475 tools->show(); 475 tools->show();
476 } else { 476 } else {
477 delete tools; 477 delete tools;
478 tools = 0; 478 tools = 0;
479 } 479 }
480 } 480 }
481} 481}
482 482
483void LauncherView::updateTools() 483void LauncherView::updateTools()
484{ 484{
485 disconnect( typemb, SIGNAL(selected(const QString&)), 485 disconnect( typemb, SIGNAL(selected(const QString&)),
486 this, SLOT(showType(const QString&)) ); 486 this, SLOT(showType(const QString&)) );
487 disconnect( catmb, SIGNAL(signalSelected(int)), 487 disconnect( catmb, SIGNAL(signalSelected(int)),
488 this, SLOT(showCategory(int)) ); 488 this, SLOT(showCategory(int)) );
489 489
490 icons->updateCategoriesAndMimeTypes(); 490 icons->updateCategoriesAndMimeTypes();
491 491
492 QString prev; 492 QString prev;
493 493
494 // Type filter 494 // Type filter
495 QStringList types; 495 QStringList types;
496 types << tr("All"); 496 types << tr("All");
497 types << "--"; 497 types << "--";
498 types += icons->mimeTypes(); 498 types += icons->mimeTypes();
499 prev = typemb->currentText(); 499 prev = typemb->currentText();
500 typemb->clear(); 500 typemb->clear();
501 typemb->insertItems(types); 501 typemb->insertItems(types);
502 typemb->select(prev); 502 typemb->select(prev);
503 503
504 Categories cats( 0 ); 504 Categories cats( 0 );
505 cats.load( categoryFileName() ); 505 cats.load( categoryFileName() );
506 QArray<int> vl( 0 ); 506 QArray<int> vl( 0 );
507 catmb->setCategories( vl, "Document View", tr("Document View") ); 507 catmb->setCategories( vl, "Document View", tr("Document View") );
508 catmb->setRemoveCategoryEdit( TRUE ); 508 catmb->setRemoveCategoryEdit( TRUE );
509 catmb->setAllCategories( TRUE ); 509 catmb->setAllCategories( TRUE );
510 510
511 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 511 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
512 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 512 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
513} 513}
514 514
515void LauncherView::sortBy(int s) 515void LauncherView::sortBy(int s)
516{ 516{
517 icons->setSortMethod((LauncherIconView::SortMethod)s); 517 icons->setSortMethod((LauncherIconView::SortMethod)s);
518} 518}
519 519
520void LauncherView::showType(const QString& t) 520void LauncherView::showType(const QString& t)
521{ 521{
522 if ( t == tr("All") ) { 522 if ( t == tr("All") ) {
523 icons->setTypeFilter("",TRUE); 523 icons->setTypeFilter("",TRUE);
524 } else { 524 } else {
525 icons->setTypeFilter(t+"/*",TRUE); 525 icons->setTypeFilter(t+"/*",TRUE);
526 } 526 }
527} 527}
528 528
529void LauncherView::showCategory( int c ) 529void LauncherView::showCategory( int c )
530{ 530{
531 icons->setCategoryFilter( c, TRUE ); 531 icons->setCategoryFilter( c, TRUE );
532} 532}
533 533
534void LauncherView::resizeEvent(QResizeEvent *e) 534void LauncherView::resizeEvent(QResizeEvent *e)
535{ 535{
536 QVBox::resizeEvent( e ); 536 QVBox::resizeEvent( e );
537 if ( e->size().width() != e->oldSize().width() ) 537 if ( e->size().width() != e->oldSize().width() )
538 sort(); 538 sort();
539} 539}
540 540
541void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 541void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
542{ 542{
543 icons->clear(); 543 icons->clear();
544 internalPopulate( folder, typefilter ); 544 internalPopulate( folder, typefilter );
545} 545}
546 546
547void LauncherView::selectionChanged() 547void LauncherView::selectionChanged()
548{ 548{
549 QIconViewItem* item = icons->currentItem(); 549 QIconViewItem* item = icons->currentItem();
550 if ( item && item->isSelected() ) { 550 if ( item && item->isSelected() ) {
551 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 551 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
552 if ( icons->inKeyEvent() ) // not for mouse press 552 if ( icons->inKeyEvent() ) // not for mouse press
553 emit clicked( appLnk ); 553 emit clicked( appLnk );
554 item->setSelected(FALSE); 554 item->setSelected(FALSE);
555 } 555 }
556} 556}
557 557
558void LauncherView::returnPressed( QIconViewItem *item ) 558void LauncherView::returnPressed( QIconViewItem *item )
559{ 559{
560 if ( item ) { 560 if ( item ) {
561 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 561 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
562 emit clicked( appLnk ); 562 emit clicked( appLnk );
563 } 563 }
564} 564}
565 565
566void LauncherView::itemClicked( int btn, QIconViewItem *item ) 566void LauncherView::itemClicked( int btn, QIconViewItem *item )
567{ 567{
568 if ( item ) { 568 if ( item ) {
569 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 569 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
570 if ( btn == LeftButton ) { 570 if ( btn == LeftButton ) {
571 // Make sure it's the item we execute that gets highlighted 571 // Make sure it's the item we execute that gets highlighted
572 icons->setCurrentItem( item ); 572 icons->setCurrentItem( item );
573 emit clicked( appLnk ); 573 emit clicked( appLnk );
574 } 574 }
575 item->setSelected(FALSE); 575 item->setSelected(FALSE);
576 } 576 }
577} 577}
578 578
579void LauncherView::itemPressed( int btn, QIconViewItem *item ) 579void LauncherView::itemPressed( int btn, QIconViewItem *item )
580{ 580{
581 if ( item ) { 581 if ( item ) {
582 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 582 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
583 if ( btn == RightButton ) 583 if ( btn == RightButton )
584 emit rightPressed( appLnk ); 584 emit rightPressed( appLnk );
585/* 585/*
586 else if ( btn == LeftButton ) 586 else if ( btn == LeftButton )
587 emit clicked( appLnk ); 587 emit clicked( appLnk );
588*/ 588*/
589 item->setSelected(FALSE); 589 item->setSelected(FALSE);
590 } 590 }
591} 591}
592 592
593void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 593void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
594{ 594{
595 QListIterator<AppLnk> it( folder->children() ); 595 QListIterator<AppLnk> it( folder->children() );
596 icons->setTypeFilter(typefilter,FALSE); 596 icons->setTypeFilter(typefilter,FALSE);
597 597
598 while ( it.current() ) { 598 while ( it.current() ) {
599 // show only the icons for existing files 599 // show only the icons for existing files
600 if (!QFile(it.current()->file()).exists() ) 600 if (!QFile(it.current()->file()).exists() & it.current()->file().left(4) != "http")
601 { 601 {
602 //maybe insert some .desktop file deletion code later 602 //maybe insert some .desktop file deletion code later
603 //maybe dir specific 603 //maybe dir specific
604 } 604 }
605 else 605 else
606 { 606 {
607 icons->addItem(*it,FALSE); 607 icons->addItem(*it,FALSE);
608 } 608 }
609 ++it; 609 ++it;
610 } 610 }
611 611
612 icons->sort(); 612 icons->sort();
613} 613}
614 614
615bool LauncherView::removeLink(const QString& linkfile) 615bool LauncherView::removeLink(const QString& linkfile)
616{ 616{
617 return icons->removeLink(linkfile); 617 return icons->removeLink(linkfile);
618} 618}
619 619
620void LauncherView::sort() 620void LauncherView::sort()
621{ 621{
622 icons->sort(); 622 icons->sort();
623} 623}
624 624
625void LauncherView::addItem(AppLnk* app, bool resort) 625void LauncherView::addItem(AppLnk* app, bool resort)
626{ 626{
627 icons->addItem(app,resort); 627 icons->addItem(app,resort);
628} 628}
629 629
630void LauncherView::setFileSystems(const QList<FileSystem> &) 630void LauncherView::setFileSystems(const QList<FileSystem> &)
631{ 631{
632 // ### does nothing now... 632 // ### does nothing now...
633} 633}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 65dc5fb..8d66407 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -841,388 +841,392 @@ void PlayListWidget::tabChanged(QWidget *widg) {
841 break; 841 break;
842 case 3: 842 case 3:
843 { 843 {
844 if( tbDeletePlaylist->isHidden()) 844 if( tbDeletePlaylist->isHidden())
845 tbDeletePlaylist->show(); 845 tbDeletePlaylist->show();
846 playLists->reread(); 846 playLists->reread();
847 } 847 }
848 break; 848 break;
849 }; 849 };
850} 850}
851 851
852void PlayListWidget::btnPlay(bool b) { 852void PlayListWidget::btnPlay(bool b) {
853 853
854// mediaPlayerState->setPlaying(b); 854// mediaPlayerState->setPlaying(b);
855 switch ( tabWidget->currentPageIndex()) { 855 switch ( tabWidget->currentPageIndex()) {
856 case 0: 856 case 0:
857 { 857 {
858// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 858// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
859// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 859// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
860// QMessageBox::message("Note","You are trying to play\na malformed url."); 860// QMessageBox::message("Note","You are trying to play\na malformed url.");
861// } else { 861// } else {
862 mediaPlayerState->setPlaying(b); 862 mediaPlayerState->setPlaying(b);
863// } 863// }
864 } 864 }
865 break; 865 break;
866 case 1: 866 case 1:
867 { 867 {
868 addToSelection( audioView->currentItem() ); 868 addToSelection( audioView->currentItem() );
869 mediaPlayerState->setPlaying(b); 869 mediaPlayerState->setPlaying(b);
870 d->selectedFiles->removeSelected( ); 870 d->selectedFiles->removeSelected( );
871 tabWidget->setCurrentPage(1); 871 tabWidget->setCurrentPage(1);
872 d->selectedFiles->unSelect(); 872 d->selectedFiles->unSelect();
873 insanityBool=FALSE; 873 insanityBool=FALSE;
874 }// audioView->clearSelection(); 874 }// audioView->clearSelection();
875 break; 875 break;
876 case 2: 876 case 2:
877 { 877 {
878 addToSelection( videoView->currentItem() ); 878 addToSelection( videoView->currentItem() );
879 mediaPlayerState->setPlaying(b); 879 mediaPlayerState->setPlaying(b);
880 qApp->processEvents(); 880 qApp->processEvents();
881 d->selectedFiles->removeSelected( ); 881 d->selectedFiles->removeSelected( );
882 tabWidget->setCurrentPage(2); 882 tabWidget->setCurrentPage(2);
883 d->selectedFiles->unSelect(); 883 d->selectedFiles->unSelect();
884 insanityBool=FALSE; 884 insanityBool=FALSE;
885 }// videoView->clearSelection(); 885 }// videoView->clearSelection();
886 break; 886 break;
887 }; 887 };
888 888
889} 889}
890 890
891void PlayListWidget::deletePlaylist() { 891void PlayListWidget::deletePlaylist() {
892 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 892 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
893 (tr("You really want to delete\nthis playlist?")), 893 (tr("You really want to delete\nthis playlist?")),
894 (tr("Yes")), (tr("No")), 0 )){ 894 (tr("Yes")), (tr("No")), 0 )){
895 case 0: // Yes clicked, 895 case 0: // Yes clicked,
896 QFile().remove(playLists->selected()->file()); 896 QFile().remove(playLists->selected()->file());
897 QFile().remove(playLists->selected()->linkFile()); 897 QFile().remove(playLists->selected()->linkFile());
898 playLists->reread(); 898 playLists->reread();
899 break; 899 break;
900 case 1: // Cancel 900 case 1: // Cancel
901 break; 901 break;
902 }; 902 };
903} 903}
904 904
905void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 905void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
906{ 906{
907 switch (mouse) { 907 switch (mouse) {
908 case 1: 908 case 1:
909 break; 909 break;
910 case 2:{ 910 case 2:{
911 911
912 QPopupMenu m; 912 QPopupMenu m;
913 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 913 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
914 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 914 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
915 m.insertSeparator(); 915 m.insertSeparator();
916 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 916 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
917 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 917 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
918 918
919 m.exec( QCursor::pos() ); 919 m.exec( QCursor::pos() );
920 } 920 }
921 break; 921 break;
922 }; 922 };
923} 923}
924 924
925void PlayListWidget::playSelected() 925void PlayListWidget::playSelected()
926{ 926{
927 btnPlay( TRUE); 927 btnPlay( TRUE);
928// d->selectedFiles->unSelect(); 928// d->selectedFiles->unSelect();
929} 929}
930 930
931void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 931void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
932{ 932{
933 switch (mouse) { 933 switch (mouse) {
934 case 1: 934 case 1:
935 935
936 break; 936 break;
937 case 2:{ 937 case 2:{
938 QPopupMenu m; 938 QPopupMenu m;
939 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 939 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
940 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 940 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
941// m.insertSeparator(); 941// m.insertSeparator();
942// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 942// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
943 m.exec( QCursor::pos() ); 943 m.exec( QCursor::pos() );
944 } 944 }
945 break; 945 break;
946 }; 946 };
947 947
948} 948}
949 949
950void PlayListWidget::listDelete() { 950void PlayListWidget::listDelete() {
951 Config cfg( "OpiePlayer" ); 951 Config cfg( "OpiePlayer" );
952 cfg.setGroup("PlayList"); 952 cfg.setGroup("PlayList");
953 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 953 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
954 QString file; 954 QString file;
955 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 955 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
956 switch ( tabWidget->currentPageIndex()) { 956 switch ( tabWidget->currentPageIndex()) {
957 case 0: 957 case 0:
958 break; 958 break;
959 case 1: 959 case 1:
960 { 960 {
961 file = audioView->currentItem()->text(0); 961 file = audioView->currentItem()->text(0);
962 QListIterator<DocLnk> Pdit( files.children() ); 962 QListIterator<DocLnk> Pdit( files.children() );
963 for ( ; Pdit.current(); ++Pdit ) { 963 for ( ; Pdit.current(); ++Pdit ) {
964 if( Pdit.current()->name() == file) { 964 if( Pdit.current()->name() == file) {
965 LnkProperties prop( Pdit.current() ); 965 LnkProperties prop( Pdit.current() );
966 prop.showMaximized(); 966 prop.showMaximized();
967 prop.exec(); 967 prop.exec();
968 } 968 }
969 } 969 }
970 populateAudioView(); 970 populateAudioView();
971 } 971 }
972 break; 972 break;
973 case 2: 973 case 2:
974 { 974 {
975// file = videoView->selectedItem()->text(0); 975// file = videoView->selectedItem()->text(0);
976// for ( int i = 0; i < noOfFiles; i++ ) { 976// for ( int i = 0; i < noOfFiles; i++ ) {
977// QString entryName; 977// QString entryName;
978// entryName.sprintf( "File%i", i + 1 ); 978// entryName.sprintf( "File%i", i + 1 );
979// QString linkFile = cfg.readEntry( entryName ); 979// QString linkFile = cfg.readEntry( entryName );
980// AppLnk lnk( AppLnk(linkFile)); 980// AppLnk lnk( AppLnk(linkFile));
981// if( lnk.name() == file ) { 981// if( lnk.name() == file ) {
982// LnkProperties prop( &lnk); 982// LnkProperties prop( &lnk);
983// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 983// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
984// prop.showMaximized(); 984// prop.showMaximized();
985// prop.exec(); 985// prop.exec();
986// } 986// }
987// } 987// }
988 } 988 }
989 break; 989 break;
990 }; 990 };
991} 991}
992 992
993void PlayListWidget::scanForAudio() { 993void PlayListWidget::scanForAudio() {
994 qDebug("scan for audio"); 994 qDebug("scan for audio");
995 files.detachChildren(); 995 files.detachChildren();
996 QListIterator<DocLnk> sdit( files.children() ); 996 QListIterator<DocLnk> sdit( files.children() );
997 for ( ; sdit.current(); ++sdit ) { 997 for ( ; sdit.current(); ++sdit ) {
998 delete sdit.current(); 998 delete sdit.current();
999 } 999 }
1000 Global::findDocuments(&files, "audio/*"); 1000 Global::findDocuments(&files, "audio/*");
1001 audioScan = TRUE; 1001 audioScan = TRUE;
1002} 1002}
1003void PlayListWidget::scanForVideo() { 1003void PlayListWidget::scanForVideo() {
1004 qDebug("scan for video"); 1004 qDebug("scan for video");
1005 vFiles.detachChildren(); 1005 vFiles.detachChildren();
1006 QListIterator<DocLnk> sdit( vFiles.children() ); 1006 QListIterator<DocLnk> sdit( vFiles.children() );
1007 for ( ; sdit.current(); ++sdit ) { 1007 for ( ; sdit.current(); ++sdit ) {
1008 delete sdit.current(); 1008 delete sdit.current();
1009 } 1009 }
1010 Global::findDocuments(&vFiles, "video/*"); 1010 Global::findDocuments(&vFiles, "video/*");
1011 videoScan = TRUE; 1011 videoScan = TRUE;
1012} 1012}
1013 1013
1014void PlayListWidget::populateAudioView() { 1014void PlayListWidget::populateAudioView() {
1015 1015
1016 audioView->clear(); 1016 audioView->clear();
1017 StorageInfo storageInfo; 1017 StorageInfo storageInfo;
1018 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1018 const QList<FileSystem> &fs = storageInfo.fileSystems();
1019 if(!audioScan) scanForAudio(); 1019 if(!audioScan) scanForAudio();
1020 1020
1021 QListIterator<DocLnk> dit( files.children() ); 1021 QListIterator<DocLnk> dit( files.children() );
1022 QListIterator<FileSystem> it ( fs ); 1022 QListIterator<FileSystem> it ( fs );
1023 1023
1024 QString storage; 1024 QString storage;
1025 for ( ; dit.current(); ++dit ) { 1025 for ( ; dit.current(); ++dit ) {
1026 for( ; it.current(); ++it ){ 1026 for( ; it.current(); ++it ){
1027 const QString name = (*it)->name(); 1027 const QString name = (*it)->name();
1028 const QString path = (*it)->path(); 1028 const QString path = (*it)->path();
1029 if(dit.current()->file().find(path) != -1 ) storage=name; 1029 if(dit.current()->file().find(path) != -1 ) storage=name;
1030 } 1030 }
1031 1031
1032 QListViewItem * newItem; 1032 QListViewItem * newItem;
1033 if ( QFile( dit.current()->file()).exists() ) { 1033 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1034// qDebug(dit.current()->name()); 1034 long size;
1035 if( dit.current()->file().left(4) == "http" )
1036 size=0;
1037 else
1038 size = QFile( dit.current()->file() ).size();
1035 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1039 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1036 QString::number( QFile( dit.current()->file()).size() ), storage); 1040 QString::number(size ), storage);
1037 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1041 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1038 } 1042 }
1039 } 1043 }
1040 1044
1041} 1045}
1042 1046
1043void PlayListWidget::populateVideoView() { 1047void PlayListWidget::populateVideoView() {
1044 videoView->clear(); 1048 videoView->clear();
1045 StorageInfo storageInfo; 1049 StorageInfo storageInfo;
1046 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1050 const QList<FileSystem> &fs = storageInfo.fileSystems();
1047 1051
1048 if(!videoScan ) scanForVideo(); 1052 if(!videoScan ) scanForVideo();
1049 1053
1050 QListIterator<DocLnk> Vdit( vFiles.children() ); 1054 QListIterator<DocLnk> Vdit( vFiles.children() );
1051 QListIterator<FileSystem> it ( fs ); 1055 QListIterator<FileSystem> it ( fs );
1052 videoView->clear(); 1056 videoView->clear();
1053 QString storage; 1057 QString storage;
1054 for ( ; Vdit.current(); ++Vdit ) { 1058 for ( ; Vdit.current(); ++Vdit ) {
1055 for( ; it.current(); ++it ){ 1059 for( ; it.current(); ++it ){
1056 const QString name = (*it)->name(); 1060 const QString name = (*it)->name();
1057 const QString path = (*it)->path(); 1061 const QString path = (*it)->path();
1058 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1062 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1059 } 1063 }
1060 1064
1061 QListViewItem * newItem; 1065 QListViewItem * newItem;
1062 if ( QFile( Vdit.current()->file()).exists() ) { 1066 if ( QFile( Vdit.current()->file()).exists() ) {
1063 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1067 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1064 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1068 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1065 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1069 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1066 } 1070 }
1067 } 1071 }
1068} 1072}
1069 1073
1070void PlayListWidget::openFile() { 1074void PlayListWidget::openFile() {
1071 QString filename, name; 1075 QString filename, name;
1072 InputDialog *fileDlg; 1076 InputDialog *fileDlg;
1073 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1077 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1074 fileDlg->exec(); 1078 fileDlg->exec();
1075 if( fileDlg->result() == 1 ) { 1079 if( fileDlg->result() == 1 ) {
1076 filename = fileDlg->LineEdit1->text(); 1080 filename = fileDlg->LineEdit1->text();
1077// http://205.188.234.129:8030 1081// http://205.188.234.129:8030
1078// http://66.28.68.70:8000 1082// http://66.28.68.70:8000
1079// filename.replace(QRegExp("%20")," "); 1083// filename.replace(QRegExp("%20")," ");
1080 qDebug("Selected filename is "+filename); 1084 qDebug("Selected filename is "+filename);
1081 if(filename.right(3) == "m3u") 1085 if(filename.right(3) == "m3u")
1082 readm3u( filename); 1086 readm3u( filename);
1083 else if(filename.right(3) == "pls") 1087 else if(filename.right(3) == "pls")
1084 readPls( filename); 1088 readPls( filename);
1085 else { 1089 else {
1086 DocLnk lnk; 1090 DocLnk lnk;
1087 1091
1088 lnk.setName(filename); //sets file name 1092 lnk.setName(filename); //sets file name
1089 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1093 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1090 filename += "/"; 1094 filename += "/";
1091 lnk.setFile(filename); //sets File property 1095 lnk.setFile(filename); //sets File property
1092 1096
1093 lnk.setType("audio/x-mpegurl"); 1097 lnk.setType("audio/x-mpegurl");
1094 lnk.setExec("opieplayer"); 1098 lnk.setExec("opieplayer");
1095 lnk.setIcon("opieplayer/MPEGPlayer"); 1099 lnk.setIcon("opieplayer/MPEGPlayer");
1096 1100
1097 if(!lnk.writeLink()) 1101 if(!lnk.writeLink())
1098 qDebug("Writing doclink did not work"); 1102 qDebug("Writing doclink did not work");
1099 d->selectedFiles->addToSelection( lnk); 1103 d->selectedFiles->addToSelection( lnk);
1100// if(fileDlg2) 1104// if(fileDlg2)
1101// delete fileDlg2; 1105// delete fileDlg2;
1102 } 1106 }
1103 } 1107 }
1104 if(fileDlg) 1108 if(fileDlg)
1105 delete fileDlg; 1109 delete fileDlg;
1106} 1110}
1107 1111
1108void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1112void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1109{ 1113{
1110 switch ( e->key() ) { 1114 switch ( e->key() ) {
1111////////////////////////////// Zaurus keys 1115////////////////////////////// Zaurus keys
1112 case Key_F9: //activity 1116 case Key_F9: //activity
1113// if(audioUI->isHidden()) 1117// if(audioUI->isHidden())
1114// audioUI->showMaximized(); 1118// audioUI->showMaximized();
1115 break; 1119 break;
1116 case Key_F10: //contacts 1120 case Key_F10: //contacts
1117// if( videoUI->isHidden()) 1121// if( videoUI->isHidden())
1118// videoUI->showMaximized(); 1122// videoUI->showMaximized();
1119 break; 1123 break;
1120 case Key_F11: //menu 1124 case Key_F11: //menu
1121 break; 1125 break;
1122 case Key_F12: //home 1126 case Key_F12: //home
1123// doBlank(); 1127// doBlank();
1124 break; 1128 break;
1125 case Key_F13: //mail 1129 case Key_F13: //mail
1126// doUnblank(); 1130// doUnblank();
1127 break; 1131 break;
1128 case Key_Q: //add to playlist 1132 case Key_Q: //add to playlist
1129 qDebug("Add"); 1133 qDebug("Add");
1130 addSelected(); 1134 addSelected();
1131 break; 1135 break;
1132 case Key_R: //remove from playlist 1136 case Key_R: //remove from playlist
1133 removeSelected(); 1137 removeSelected();
1134 break; 1138 break;
1135// case Key_P: //play 1139// case Key_P: //play
1136// qDebug("Play"); 1140// qDebug("Play");
1137// playSelected(); 1141// playSelected();
1138// break; 1142// break;
1139 case Key_Space: 1143 case Key_Space:
1140 qDebug("Play"); 1144 qDebug("Play");
1141// playSelected(); puh 1145// playSelected(); puh
1142 break; 1146 break;
1143 case Key_1: 1147 case Key_1:
1144 tabWidget->setCurrentPage(0); 1148 tabWidget->setCurrentPage(0);
1145 break; 1149 break;
1146 case Key_2: 1150 case Key_2:
1147 tabWidget->setCurrentPage(1); 1151 tabWidget->setCurrentPage(1);
1148 break; 1152 break;
1149 case Key_3: 1153 case Key_3:
1150 tabWidget->setCurrentPage(2); 1154 tabWidget->setCurrentPage(2);
1151 break; 1155 break;
1152 case Key_4: 1156 case Key_4:
1153 tabWidget->setCurrentPage(3); 1157 tabWidget->setCurrentPage(3);
1154 break; 1158 break;
1155 case Key_Down: 1159 case Key_Down:
1156 if ( !d->selectedFiles->next() ) 1160 if ( !d->selectedFiles->next() )
1157 d->selectedFiles->first(); 1161 d->selectedFiles->first();
1158 1162
1159 break; 1163 break;
1160 case Key_Up: 1164 case Key_Up:
1161 if ( !d->selectedFiles->prev() ) 1165 if ( !d->selectedFiles->prev() )
1162 // d->selectedFiles->last(); 1166 // d->selectedFiles->last();
1163 1167
1164 break; 1168 break;
1165 1169
1166 } 1170 }
1167} 1171}
1168 1172
1169void PlayListWidget::keyPressEvent( QKeyEvent *e) 1173void PlayListWidget::keyPressEvent( QKeyEvent *e)
1170{ 1174{
1171// qDebug("Key press"); 1175// qDebug("Key press");
1172// switch ( e->key() ) { 1176// switch ( e->key() ) {
1173// ////////////////////////////// Zaurus keys 1177// ////////////////////////////// Zaurus keys
1174// case Key_A: //add to playlist 1178// case Key_A: //add to playlist
1175// qDebug("Add"); 1179// qDebug("Add");
1176// addSelected(); 1180// addSelected();
1177// break; 1181// break;
1178// case Key_R: //remove from playlist 1182// case Key_R: //remove from playlist
1179// removeSelected(); 1183// removeSelected();
1180// break; 1184// break;
1181// case Key_P: //play 1185// case Key_P: //play
1182// qDebug("Play"); 1186// qDebug("Play");
1183// playSelected(); 1187// playSelected();
1184// break; 1188// break;
1185// case Key_Space: 1189// case Key_Space:
1186// qDebug("Play"); 1190// qDebug("Play");
1187// playSelected(); 1191// playSelected();
1188// break; 1192// break;
1189// } 1193// }
1190} 1194}
1191 1195
1192void PlayListWidget::doBlank() { 1196void PlayListWidget::doBlank() {
1193 qDebug("do blanking"); 1197 qDebug("do blanking");
1194 fd=open("/dev/fb0",O_RDWR); 1198 fd=open("/dev/fb0",O_RDWR);
1195 if (fd != -1) { 1199 if (fd != -1) {
1196 ioctl(fd,FBIOBLANK,1); 1200 ioctl(fd,FBIOBLANK,1);
1197// close(fd); 1201// close(fd);
1198 } 1202 }
1199} 1203}
1200 1204
1201void PlayListWidget::doUnblank() { 1205void PlayListWidget::doUnblank() {
1202 // this crashes opieplayer with a segfault 1206 // this crashes opieplayer with a segfault
1203// int fd; 1207// int fd;
1204// fd=open("/dev/fb0",O_RDWR); 1208// fd=open("/dev/fb0",O_RDWR);
1205 qDebug("do unblanking"); 1209 qDebug("do unblanking");
1206 if (fd != -1) { 1210 if (fd != -1) {
1207 ioctl(fd,FBIOBLANK,0); 1211 ioctl(fd,FBIOBLANK,0);
1208 close(fd); 1212 close(fd);
1209 } 1213 }
1210 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1214 QCopEnvelope h("QPE/System", "setBacklight(int)");
1211 h <<-3;// v[1]; // -3 Force on 1215 h <<-3;// v[1]; // -3 Force on
1212} 1216}
1213 1217
1214void PlayListWidget::readm3u(const QString &filename) { 1218void PlayListWidget::readm3u(const QString &filename) {
1215 1219
1216 qDebug("m3u filename is "+filename); 1220 qDebug("m3u filename is "+filename);
1217 QFile f(filename); 1221 QFile f(filename);
1218 1222
1219 if(f.open(IO_ReadOnly)) { 1223 if(f.open(IO_ReadOnly)) {
1220 QTextStream t(&f); 1224 QTextStream t(&f);
1221 QString s;//, first, second; 1225 QString s;//, first, second;
1222 int i=0; 1226 int i=0;
1223 while ( !t.atEnd()) { 1227 while ( !t.atEnd()) {
1224// Lview->insertLine(t.readLine(),-1); 1228// Lview->insertLine(t.readLine(),-1);
1225 s=t.readLine(); 1229 s=t.readLine();
1226 1230
1227 if(s.find("#",0,TRUE) == -1) { 1231 if(s.find("#",0,TRUE) == -1) {
1228 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1232 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 603a7a3..6c4d07f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -540,388 +540,391 @@ void PlayListWidget::addSelected() {
540 540
541 541
542void PlayListWidget::removeSelected() { 542void PlayListWidget::removeSelected() {
543 d->selectedFiles->removeSelected( ); 543 d->selectedFiles->removeSelected( );
544} 544}
545 545
546 546
547void PlayListWidget::playIt( QListViewItem *it) { 547void PlayListWidget::playIt( QListViewItem *it) {
548 if(!it) return; 548 if(!it) return;
549 mediaPlayerState->setPlaying(FALSE); 549 mediaPlayerState->setPlaying(FALSE);
550 mediaPlayerState->setPlaying(TRUE); 550 mediaPlayerState->setPlaying(TRUE);
551 d->selectedFiles->unSelect(); 551 d->selectedFiles->unSelect();
552} 552}
553 553
554 554
555void PlayListWidget::addToSelection( QListViewItem *it) { 555void PlayListWidget::addToSelection( QListViewItem *it) {
556 d->setDocumentUsed = FALSE; 556 d->setDocumentUsed = FALSE;
557 557
558 if(it) { 558 if(it) {
559 switch (tabWidget->currentPageIndex()) { 559 switch (tabWidget->currentPageIndex()) {
560 case 1: { 560 case 1: {
561 QListIterator<DocLnk> dit( files.children() ); 561 QListIterator<DocLnk> dit( files.children() );
562 for ( ; dit.current(); ++dit ) { 562 for ( ; dit.current(); ++dit ) {
563 if( dit.current()->name() == it->text(0)) { 563 if( dit.current()->name() == it->text(0)) {
564 if(QFileInfo( dit.current()->file()).exists()) 564 if(QFileInfo( dit.current()->file()).exists())
565 d->selectedFiles->addToSelection( **dit ); 565 d->selectedFiles->addToSelection( **dit );
566 } 566 }
567 } 567 }
568 } 568 }
569 break; 569 break;
570 case 2: { 570 case 2: {
571 QListIterator<DocLnk> dit( vFiles.children() ); 571 QListIterator<DocLnk> dit( vFiles.children() );
572 for ( ; dit.current(); ++dit ) { 572 for ( ; dit.current(); ++dit ) {
573 if( dit.current()->name() == it->text(0)) { 573 if( dit.current()->name() == it->text(0)) {
574 if(QFileInfo( dit.current()->file()).exists()) 574 if(QFileInfo( dit.current()->file()).exists())
575 d->selectedFiles->addToSelection( **dit ); 575 d->selectedFiles->addToSelection( **dit );
576 } 576 }
577 } 577 }
578 } 578 }
579 break; 579 break;
580 case 0: 580 case 0:
581 break; 581 break;
582 }; 582 };
583 tabWidget->setCurrentPage(0); 583 tabWidget->setCurrentPage(0);
584 } 584 }
585} 585}
586 586
587 587
588void PlayListWidget::tabChanged(QWidget *) { 588void PlayListWidget::tabChanged(QWidget *) {
589 589
590 switch ( tabWidget->currentPageIndex()) { 590 switch ( tabWidget->currentPageIndex()) {
591 case 0: 591 case 0:
592 { 592 {
593 if( !tbDeletePlaylist->isHidden() ) { 593 if( !tbDeletePlaylist->isHidden() ) {
594 tbDeletePlaylist->hide(); 594 tbDeletePlaylist->hide();
595 } 595 }
596 d->tbRemoveFromList->setEnabled(TRUE); 596 d->tbRemoveFromList->setEnabled(TRUE);
597 d->tbAddToList->setEnabled(FALSE); 597 d->tbAddToList->setEnabled(FALSE);
598 } 598 }
599 break; 599 break;
600 case 1: 600 case 1:
601 { 601 {
602 audioView->clear(); 602 audioView->clear();
603 populateAudioView(); 603 populateAudioView();
604 604
605 if( !tbDeletePlaylist->isHidden() ) { 605 if( !tbDeletePlaylist->isHidden() ) {
606 tbDeletePlaylist->hide(); 606 tbDeletePlaylist->hide();
607 } 607 }
608 d->tbRemoveFromList->setEnabled(FALSE); 608 d->tbRemoveFromList->setEnabled(FALSE);
609 d->tbAddToList->setEnabled(TRUE); 609 d->tbAddToList->setEnabled(TRUE);
610 } 610 }
611 break; 611 break;
612 case 2: 612 case 2:
613 { 613 {
614 videoView->clear(); 614 videoView->clear();
615 populateVideoView(); 615 populateVideoView();
616 if( !tbDeletePlaylist->isHidden() ) { 616 if( !tbDeletePlaylist->isHidden() ) {
617 tbDeletePlaylist->hide(); 617 tbDeletePlaylist->hide();
618 } 618 }
619 d->tbRemoveFromList->setEnabled(FALSE); 619 d->tbRemoveFromList->setEnabled(FALSE);
620 d->tbAddToList->setEnabled(TRUE); 620 d->tbAddToList->setEnabled(TRUE);
621 } 621 }
622 break; 622 break;
623 case 3: 623 case 3:
624 { 624 {
625 if( tbDeletePlaylist->isHidden() ) { 625 if( tbDeletePlaylist->isHidden() ) {
626 tbDeletePlaylist->show(); 626 tbDeletePlaylist->show();
627 } 627 }
628 playLists->reread(); 628 playLists->reread();
629 } 629 }
630 break; 630 break;
631 }; 631 };
632} 632}
633 633
634 634
635void PlayListWidget::btnPlay(bool b) { 635void PlayListWidget::btnPlay(bool b) {
636 // mediaPlayerState->setPlaying(b); 636 // mediaPlayerState->setPlaying(b);
637 switch ( tabWidget->currentPageIndex()) { 637 switch ( tabWidget->currentPageIndex()) {
638 case 0: 638 case 0:
639 { 639 {
640 mediaPlayerState->setPlaying(b); 640 mediaPlayerState->setPlaying(b);
641 } 641 }
642 break; 642 break;
643 case 1: 643 case 1:
644 { 644 {
645 addToSelection( audioView->currentItem() ); 645 addToSelection( audioView->currentItem() );
646 mediaPlayerState->setPlaying(b); 646 mediaPlayerState->setPlaying(b);
647 d->selectedFiles->removeSelected( ); 647 d->selectedFiles->removeSelected( );
648 tabWidget->setCurrentPage(1); 648 tabWidget->setCurrentPage(1);
649 d->selectedFiles->unSelect(); 649 d->selectedFiles->unSelect();
650 insanityBool=FALSE; 650 insanityBool=FALSE;
651 }// audioView->clearSelection(); 651 }// audioView->clearSelection();
652 break; 652 break;
653 case 2: 653 case 2:
654 { 654 {
655 addToSelection( videoView->currentItem() ); 655 addToSelection( videoView->currentItem() );
656 mediaPlayerState->setPlaying(b); 656 mediaPlayerState->setPlaying(b);
657 qApp->processEvents(); 657 qApp->processEvents();
658 d->selectedFiles->removeSelected( ); 658 d->selectedFiles->removeSelected( );
659 tabWidget->setCurrentPage(2); 659 tabWidget->setCurrentPage(2);
660 d->selectedFiles->unSelect(); 660 d->selectedFiles->unSelect();
661 insanityBool=FALSE; 661 insanityBool=FALSE;
662 }// videoView->clearSelection(); 662 }// videoView->clearSelection();
663 break; 663 break;
664 }; 664 };
665 665
666} 666}
667 667
668void PlayListWidget::deletePlaylist() { 668void PlayListWidget::deletePlaylist() {
669 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 669 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
670 (tr("You really want to delete\nthis playlist?")), 670 (tr("You really want to delete\nthis playlist?")),
671 (tr("Yes")), (tr("No")), 0 )){ 671 (tr("Yes")), (tr("No")), 0 )){
672 case 0: // Yes clicked, 672 case 0: // Yes clicked,
673 QFile().remove(playLists->selected()->file()); 673 QFile().remove(playLists->selected()->file());
674 QFile().remove(playLists->selected()->linkFile()); 674 QFile().remove(playLists->selected()->linkFile());
675 playLists->reread(); 675 playLists->reread();
676 break; 676 break;
677 case 1: // Cancel 677 case 1: // Cancel
678 break; 678 break;
679 }; 679 };
680} 680}
681 681
682 682
683void PlayListWidget::playSelected() { 683void PlayListWidget::playSelected() {
684 btnPlay( TRUE); 684 btnPlay( TRUE);
685} 685}
686 686
687 687
688void PlayListWidget::scanForAudio() { 688void PlayListWidget::scanForAudio() {
689// qDebug("scan for audio"); 689// qDebug("scan for audio");
690 files.detachChildren(); 690 files.detachChildren();
691 QListIterator<DocLnk> sdit( files.children() ); 691 QListIterator<DocLnk> sdit( files.children() );
692 for ( ; sdit.current(); ++sdit ) { 692 for ( ; sdit.current(); ++sdit ) {
693 delete sdit.current(); 693 delete sdit.current();
694 } 694 }
695 Global::findDocuments(&files, "audio/*"); 695 Global::findDocuments(&files, "audio/*");
696 audioScan = TRUE; 696 audioScan = TRUE;
697} 697}
698 698
699void PlayListWidget::scanForVideo() { 699void PlayListWidget::scanForVideo() {
700// qDebug("scan for video"); 700// qDebug("scan for video");
701 vFiles.detachChildren(); 701 vFiles.detachChildren();
702 QListIterator<DocLnk> sdit( vFiles.children() ); 702 QListIterator<DocLnk> sdit( vFiles.children() );
703 for ( ; sdit.current(); ++sdit ) { 703 for ( ; sdit.current(); ++sdit ) {
704 delete sdit.current(); 704 delete sdit.current();
705 } 705 }
706 Global::findDocuments(&vFiles, "video/*"); 706 Global::findDocuments(&vFiles, "video/*");
707 videoScan = TRUE; 707 videoScan = TRUE;
708} 708}
709 709
710void PlayListWidget::populateAudioView() { 710void PlayListWidget::populateAudioView() {
711 audioView->clear(); 711 audioView->clear();
712 StorageInfo storageInfo; 712 StorageInfo storageInfo;
713 const QList<FileSystem> &fs = storageInfo.fileSystems(); 713 const QList<FileSystem> &fs = storageInfo.fileSystems();
714 if(!audioScan) { 714 if(!audioScan) {
715 scanForAudio(); 715 scanForAudio();
716 } 716 }
717 717
718 QListIterator<DocLnk> dit( files.children() ); 718 QListIterator<DocLnk> dit( files.children() );
719 QListIterator<FileSystem> it ( fs ); 719 QListIterator<FileSystem> it ( fs );
720 720
721 QString storage; 721 QString storage;
722 for ( ; dit.current(); ++dit ) { 722 for ( ; dit.current(); ++dit ) {
723 for( ; it.current(); ++it ){ 723 for( ; it.current(); ++it ){
724 const QString name = (*it)->name(); 724 const QString name = (*it)->name();
725 const QString path = (*it)->path(); 725 const QString path = (*it)->path();
726 if(dit.current()->file().find(path) != -1 ) { 726 if(dit.current()->file().find(path) != -1 ) {
727 storage = name; 727 storage = name;
728 } 728 }
729 } 729 }
730 730
731 QListViewItem * newItem; 731 QListViewItem * newItem;
732 if ( QFile( dit.current()->file()).exists() ) { 732 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
733 // qDebug(dit.current()->name()); 733 long size;
734 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 734 if( dit.current()->file().left(4) == "http" )
735 QString::number( QFile( dit.current()->file()).size() ), storage); 735 size=0;
736 else
737 size = QFile( dit.current()->file() ).size();
738 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage);
736 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 739 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
737 } 740 }
738 } 741 }
739} 742}
740 743
741 744
742void PlayListWidget::populateVideoView() { 745void PlayListWidget::populateVideoView() {
743 videoView->clear(); 746 videoView->clear();
744 StorageInfo storageInfo; 747 StorageInfo storageInfo;
745 const QList<FileSystem> &fs = storageInfo.fileSystems(); 748 const QList<FileSystem> &fs = storageInfo.fileSystems();
746 749
747 if(!videoScan ) { 750 if(!videoScan ) {
748 scanForVideo(); 751 scanForVideo();
749 } 752 }
750 753
751 QListIterator<DocLnk> Vdit( vFiles.children() ); 754 QListIterator<DocLnk> Vdit( vFiles.children() );
752 QListIterator<FileSystem> it ( fs ); 755 QListIterator<FileSystem> it ( fs );
753 videoView->clear(); 756 videoView->clear();
754 QString storage; 757 QString storage;
755 for ( ; Vdit.current(); ++Vdit ) { 758 for ( ; Vdit.current(); ++Vdit ) {
756 for( ; it.current(); ++it ) { 759 for( ; it.current(); ++it ) {
757 const QString name = (*it)->name(); 760 const QString name = (*it)->name();
758 const QString path = (*it)->path(); 761 const QString path = (*it)->path();
759 if( Vdit.current()->file().find(path) != -1 ) { 762 if( Vdit.current()->file().find(path) != -1 ) {
760 storage=name; 763 storage=name;
761 } 764 }
762 } 765 }
763 766
764 QListViewItem * newItem; 767 QListViewItem * newItem;
765 if ( QFile( Vdit.current()->file() ).exists() ) { 768 if ( QFile( Vdit.current()->file() ).exists() ) {
766 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 769 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
767 QString::number( QFile( Vdit.current()->file() ).size() ), storage ); 770 QString::number( QFile( Vdit.current()->file() ).size() ), storage );
768 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 771 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
769 } 772 }
770 } 773 }
771} 774}
772 775
773 776
774void PlayListWidget::openFile() { 777void PlayListWidget::openFile() {
775 QString filename, name; 778 QString filename, name;
776 InputDialog *fileDlg; 779 InputDialog *fileDlg;
777 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 780 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
778 fileDlg->exec(); 781 fileDlg->exec();
779 if( fileDlg->result() == 1 ) { 782 if( fileDlg->result() == 1 ) {
780 filename = fileDlg->text(); 783 filename = fileDlg->text();
781 784
782 qDebug( "Selected filename is " + filename ); 785 qDebug( "Selected filename is " + filename );
783 if( filename.right( 3 ) == "m3u" ) { 786 if( filename.right( 3 ) == "m3u" ) {
784 readm3u( filename ); 787 readm3u( filename );
785 } else if( filename.right(3) == "pls" ) { 788 } else if( filename.right(3) == "pls" ) {
786 readPls( filename ); 789 readPls( filename );
787 } else { 790 } else {
788 // this doesnt need fixing 791 // this doesnt need fixing
789 DocLnk lnk; 792 DocLnk lnk;
790 lnk.setName( filename ); //sets file name 793 lnk.setName( filename ); //sets file name
791 lnk.setFile( filename ); //sets File property 794 lnk.setFile( filename ); //sets File property
792 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); 795 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
793 lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); 796 lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
794 lnk.setExec( "opieplayer" ); 797 lnk.setExec( "opieplayer" );
795 lnk.setIcon( "opieplayer2/MPEGPlayer" ); 798 lnk.setIcon( "opieplayer2/MPEGPlayer" );
796 799
797 if( !lnk.writeLink() ) { 800 if( !lnk.writeLink() ) {
798 qDebug( "Writing doclink did not work" ); 801 qDebug( "Writing doclink did not work" );
799 } 802 }
800 d->selectedFiles->addToSelection( lnk ); 803 d->selectedFiles->addToSelection( lnk );
801 } 804 }
802 } 805 }
803 if( fileDlg ) { 806 if( fileDlg ) {
804 delete fileDlg; 807 delete fileDlg;
805 } 808 }
806} 809}
807 810
808void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 811void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
809 switch ( e->key() ) { 812 switch ( e->key() ) {
810 ////////////////////////////// Zaurus keys 813 ////////////////////////////// Zaurus keys
811 case Key_F9: //activity 814 case Key_F9: //activity
812 // if(audioUI->isHidden()) 815 // if(audioUI->isHidden())
813 // audioUI->showMaximized(); 816 // audioUI->showMaximized();
814 break; 817 break;
815 case Key_F10: //contacts 818 case Key_F10: //contacts
816 // if( videoUI->isHidden()) 819 // if( videoUI->isHidden())
817 // videoUI->showMaximized(); 820 // videoUI->showMaximized();
818 break; 821 break;
819 case Key_F11: //menu 822 case Key_F11: //menu
820 break; 823 break;
821 case Key_F12: //home 824 case Key_F12: //home
822 // doBlank(); 825 // doBlank();
823 break; 826 break;
824 case Key_F13: //mail 827 case Key_F13: //mail
825 // doUnblank(); 828 // doUnblank();
826 break; 829 break;
827 case Key_Q: //add to playlist 830 case Key_Q: //add to playlist
828 addSelected(); 831 addSelected();
829 break; 832 break;
830 case Key_R: //remove from playlist 833 case Key_R: //remove from playlist
831 removeSelected(); 834 removeSelected();
832 break; 835 break;
833 // case Key_P: //play 836 // case Key_P: //play
834 // qDebug("Play"); 837 // qDebug("Play");
835 // playSelected(); 838 // playSelected();
836 // break; 839 // break;
837 case Key_Space: 840 case Key_Space:
838 // playSelected(); puh 841 // playSelected(); puh
839 break; 842 break;
840 case Key_1: 843 case Key_1:
841 tabWidget->setCurrentPage( 0 ); 844 tabWidget->setCurrentPage( 0 );
842 break; 845 break;
843 case Key_2: 846 case Key_2:
844 tabWidget->setCurrentPage( 1 ); 847 tabWidget->setCurrentPage( 1 );
845 break; 848 break;
846 case Key_3: 849 case Key_3:
847 tabWidget->setCurrentPage( 2 ); 850 tabWidget->setCurrentPage( 2 );
848 break; 851 break;
849 case Key_4: 852 case Key_4:
850 tabWidget->setCurrentPage( 3 ); 853 tabWidget->setCurrentPage( 3 );
851 break; 854 break;
852 case Key_Down: 855 case Key_Down:
853 if ( !d->selectedFiles->next() ) 856 if ( !d->selectedFiles->next() )
854 d->selectedFiles->first(); 857 d->selectedFiles->first();
855 858
856 break; 859 break;
857 case Key_Up: 860 case Key_Up:
858 if ( !d->selectedFiles->prev() ) 861 if ( !d->selectedFiles->prev() )
859 // d->selectedFiles->last(); 862 // d->selectedFiles->last();
860 863
861 break; 864 break;
862 865
863 } 866 }
864} 867}
865 868
866void PlayListWidget::readm3u( const QString &filename ) { 869void PlayListWidget::readm3u( const QString &filename ) {
867 qDebug( "m3u filename is " + filename ); 870 qDebug( "m3u filename is " + filename );
868 QFile f( filename ); 871 QFile f( filename );
869 872
870 if( f.open( IO_ReadOnly ) ) { 873 if( f.open( IO_ReadOnly ) ) {
871 QTextStream t(&f); 874 QTextStream t(&f);
872 QString s;//, first, second; 875 QString s;//, first, second;
873 int i=0; 876 int i=0;
874 while ( !t.atEnd() ) { 877 while ( !t.atEnd() ) {
875 s=t.readLine(); 878 s=t.readLine();
876 879
877 if( s.find( "#", 0, TRUE) == -1 ) { 880 if( s.find( "#", 0, TRUE) == -1 ) {
878 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat 881 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat
879 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 882 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
880 s = s.right( s.length() -2 ); 883 s = s.right( s.length() -2 );
881 DocLnk lnk( s ); 884 DocLnk lnk( s );
882 QFileInfo f( s ); 885 QFileInfo f( s );
883 QString name = f.baseName(); 886 QString name = f.baseName();
884 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 887 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
885 lnk.setName( name ); 888 lnk.setName( name );
886 s=s.replace( QRegExp( "\\" ), "/" ); 889 s=s.replace( QRegExp( "\\" ), "/" );
887 lnk.setFile( s ); 890 lnk.setFile( s );
888 lnk.writeLink(); 891 lnk.writeLink();
889 qDebug( "add " + name); 892 qDebug( "add " + name);
890 d->selectedFiles->addToSelection( lnk ); 893 d->selectedFiles->addToSelection( lnk );
891 } else { // is url 894 } else { // is url
892 s.replace( QRegExp( "%20" )," " ); 895 s.replace( QRegExp( "%20" )," " );
893 DocLnk lnk( s ); 896 DocLnk lnk( s );
894 QString name; 897 QString name;
895 if( name.left( 4 ) == "http" ) { 898 if( name.left( 4 ) == "http" ) {
896 name = s.right( s.length() - 7 ); 899 name = s.right( s.length() - 7 );
897 } else { 900 } else {
898 name = s; 901 name = s;
899 } 902 }
900 lnk.setName( name ); 903 lnk.setName( name );
901 if( s.at( s.length() - 4) == '.' ) { 904 if( s.at( s.length() - 4) == '.' ) {
902 lnk.setFile( s ); 905 lnk.setFile( s );
903 } else { 906 } else {
904 lnk.setFile( s + "/" ); 907 lnk.setFile( s + "/" );
905 } 908 }
906 lnk.setType( "audio/x-mpegurl" ); 909 lnk.setType( "audio/x-mpegurl" );
907 lnk.writeLink(); 910 lnk.writeLink();
908 d->selectedFiles->addToSelection( lnk ); 911 d->selectedFiles->addToSelection( lnk );
909 } 912 }
910 i++; 913 i++;
911 } 914 }
912 } 915 }
913 } 916 }
914 } 917 }
915 f.close(); 918 f.close();
916} 919}
917 920
918void PlayListWidget::writem3u() { 921void PlayListWidget::writem3u() {
919 InputDialog *fileDlg; 922 InputDialog *fileDlg;
920 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 923 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
921 fileDlg->exec(); 924 fileDlg->exec();
922 QString filename, list; 925 QString filename, list;
923 if( fileDlg->result() == 1 ) { 926 if( fileDlg->result() == 1 ) {
924 filename = fileDlg->text(); 927 filename = fileDlg->text();
925 qDebug( filename ); 928 qDebug( filename );
926 int noOfFiles = 0; 929 int noOfFiles = 0;
927 d->selectedFiles->first(); 930 d->selectedFiles->first();