author | simon <simon> | 2002-12-04 10:52:00 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-04 10:52:00 (UTC) |
commit | 63541c46776721ef5ae63903e5b40838c1c49a43 (patch) (unidiff) | |
tree | e9beaf0d1340b32a7fffdce8e6dad7b0cbc54866 /noncore/multimedia/opieplayer2/playlistwidget.cpp | |
parent | d000538b68b3411a409e829c4e68f42f9646b940 (diff) | |
download | opie-63541c46776721ef5ae63903e5b40838c1c49a43.zip opie-63541c46776721ef5ae63903e5b40838c1c49a43.tar.gz opie-63541c46776721ef5ae63903e5b40838c1c49a43.tar.bz2 |
- merged scanForVideo and scanForAudio into a common scanFiles method in
the PlayListFileView. less duplicated code :)
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6bda71e..93e7919 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -28,63 +28,61 @@ | |||
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | #include "playlistfileview.h" | ||
52 | 53 | ||
53 | //only needed for the random play | 54 | //only needed for the random play |
54 | #include <stdlib.h> | 55 | #include <stdlib.h> |
55 | #include <assert.h> | 56 | #include <assert.h> |
56 | 57 | ||
57 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
58 | #include "videowidget.h" | 59 | #include "videowidget.h" |
59 | 60 | ||
60 | extern MediaPlayerState *mediaPlayerState; | 61 | extern MediaPlayerState *mediaPlayerState; |
61 | // extern AudioWidget *audioUI; | 62 | // extern AudioWidget *audioUI; |
62 | // extern VideoWidget *videoUI; | 63 | // extern VideoWidget *videoUI; |
63 | 64 | ||
64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | ||
65 | // no m3u's here please | ||
66 | |||
67 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 65 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
68 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { | 66 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { |
69 | 67 | ||
70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
71 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
72 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
74 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
75 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
77 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
79 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
81 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
82 | 80 | ||
83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
85 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
87 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
89 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
90 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
@@ -618,124 +616,111 @@ void PlayListWidget::btnPlay(bool b) { | |||
618 | insanityBool=FALSE; | 616 | insanityBool=FALSE; |
619 | } | 617 | } |
620 | 618 | ||
621 | void PlayListWidget::deletePlaylist() { | 619 | void PlayListWidget::deletePlaylist() { |
622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 620 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
623 | (tr("You really want to delete\nthis playlist?")), | 621 | (tr("You really want to delete\nthis playlist?")), |
624 | (tr("Yes")), (tr("No")), 0 )){ | 622 | (tr("Yes")), (tr("No")), 0 )){ |
625 | case 0: // Yes clicked, | 623 | case 0: // Yes clicked, |
626 | QFile().remove(playLists->selectedDocument().file()); | 624 | QFile().remove(playLists->selectedDocument().file()); |
627 | QFile().remove(playLists->selectedDocument().linkFile()); | 625 | QFile().remove(playLists->selectedDocument().linkFile()); |
628 | playLists->reread(); | 626 | playLists->reread(); |
629 | break; | 627 | break; |
630 | case 1: // Cancel | 628 | case 1: // Cancel |
631 | break; | 629 | break; |
632 | }; | 630 | }; |
633 | } | 631 | } |
634 | 632 | ||
635 | 633 | ||
636 | void PlayListWidget::playSelected() { | 634 | void PlayListWidget::playSelected() { |
637 | btnPlay( TRUE); | 635 | btnPlay( TRUE); |
638 | } | 636 | } |
639 | 637 | ||
640 | 638 | ||
641 | void PlayListWidget::scanForAudio() { | 639 | void PlayListWidget::scanForAudio() { |
642 | // qDebug("scan for audio"); | 640 | audioView->scanFiles(); |
643 | files.detachChildren(); | ||
644 | QListIterator<DocLnk> sdit( files.children() ); | ||
645 | for ( ; sdit.current(); ++sdit ) { | ||
646 | delete sdit.current(); | ||
647 | } | ||
648 | // Global::findDocuments( &files, "audio/*"); | ||
649 | Global::findDocuments( &files, audioMimes); | ||
650 | audioScan = true; | 641 | audioScan = true; |
651 | populateAudioView(); | 642 | populateAudioView(); |
652 | } | 643 | } |
653 | 644 | ||
654 | void PlayListWidget::scanForVideo() { | 645 | void PlayListWidget::scanForVideo() { |
655 | // qDebug("scan for video"); | 646 | videoView->scanFiles(); |
656 | vFiles.detachChildren(); | ||
657 | QListIterator<DocLnk> sdit( vFiles.children() ); | ||
658 | for ( ; sdit.current(); ++sdit ) { | ||
659 | delete sdit.current(); | ||
660 | } | ||
661 | Global::findDocuments(&vFiles, "video/*"); | ||
662 | videoScan = true; | 647 | videoScan = true; |
663 | populateVideoView(); | 648 | populateVideoView(); |
664 | } | 649 | } |
665 | 650 | ||
666 | void PlayListWidget::populateAudioView() { | 651 | void PlayListWidget::populateAudioView() { |
667 | audioView->clear(); | 652 | audioView->clear(); |
668 | StorageInfo storageInfo; | 653 | StorageInfo storageInfo; |
669 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 654 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
670 | if(!audioScan) { | 655 | if(!audioScan) { |
671 | scanForAudio(); | 656 | scanForAudio(); |
672 | } | 657 | } |
673 | 658 | ||
674 | QListIterator<DocLnk> dit( files.children() ); | 659 | QListIterator<DocLnk> dit( audioView->files().children() ); |
675 | // QListIterator<FileSystem> it ( fs ); | 660 | // QListIterator<FileSystem> it ( fs ); |
676 | audioView->clear(); | 661 | audioView->clear(); |
677 | 662 | ||
678 | QString storage; | 663 | QString storage; |
679 | for ( ; dit.current(); ++dit ) { | 664 | for ( ; dit.current(); ++dit ) { |
680 | // // for( ; it.current(); ++it ){ | 665 | // // for( ; it.current(); ++it ){ |
681 | // const QString name = (*dit)->name(); | 666 | // const QString name = (*dit)->name(); |
682 | // const QString path = (*dit)->path(); | 667 | // const QString path = (*dit)->path(); |
683 | // if(dit.current()->file().find(path) != -1 ) { | 668 | // if(dit.current()->file().find(path) != -1 ) { |
684 | // storage = name; | 669 | // storage = name; |
685 | // // } | 670 | // // } |
686 | // } | 671 | // } |
687 | 672 | ||
688 | QListViewItem * newItem; | 673 | QListViewItem * newItem; |
689 | if ( QFile( dit.current()->file()).exists() || | 674 | if ( QFile( dit.current()->file()).exists() || |
690 | dit.current()->file().left(4) == "http" ) { | 675 | dit.current()->file().left(4) == "http" ) { |
691 | long size; | 676 | long size; |
692 | if( dit.current()->file().left(4) == "http" ) | 677 | if( dit.current()->file().left(4) == "http" ) |
693 | size=0; | 678 | size=0; |
694 | else | 679 | else |
695 | size = QFile( dit.current()->file() ).size(); | 680 | size = QFile( dit.current()->file() ).size(); |
696 | 681 | ||
697 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 682 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
698 | QString::number(size ), "" /*storage*/, | 683 | QString::number(size ), "" /*storage*/, |
699 | dit.current()->file() ); | 684 | dit.current()->file() ); |
700 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 685 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
701 | // qDebug("<<<< "+dit.current()->file()); | 686 | // qDebug("<<<< "+dit.current()->file()); |
702 | } | 687 | } |
703 | } | 688 | } |
704 | audioPopulated=true; | 689 | audioPopulated=true; |
705 | } | 690 | } |
706 | 691 | ||
707 | 692 | ||
708 | void PlayListWidget::populateVideoView() { | 693 | void PlayListWidget::populateVideoView() { |
709 | videoView->clear(); | 694 | videoView->clear(); |
710 | StorageInfo storageInfo; | 695 | StorageInfo storageInfo; |
711 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 696 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
712 | 697 | ||
713 | if(!videoScan ) { | 698 | if(!videoScan ) { |
714 | scanForVideo(); | 699 | scanForVideo(); |
715 | } | 700 | } |
716 | 701 | ||
717 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 702 | QListIterator<DocLnk> Vdit( videoView->files().children() ); |
718 | // QListIterator<FileSystem> it ( fs ); | 703 | // QListIterator<FileSystem> it ( fs ); |
719 | videoView->clear(); | 704 | videoView->clear(); |
720 | QString storage, pathName; | 705 | QString storage, pathName; |
721 | for ( ; Vdit.current(); ++Vdit ) { | 706 | for ( ; Vdit.current(); ++Vdit ) { |
722 | // // for( ; it.current(); ++it ) { | 707 | // // for( ; it.current(); ++it ) { |
723 | // const QString name = (*Vdit)->name(); | 708 | // const QString name = (*Vdit)->name(); |
724 | // const QString path = (*Vdit)->path(); | 709 | // const QString path = (*Vdit)->path(); |
725 | // if( Vdit.current()->file().find(path) != -1 ) { | 710 | // if( Vdit.current()->file().find(path) != -1 ) { |
726 | // storage=name; | 711 | // storage=name; |
727 | // pathName=path; | 712 | // pathName=path; |
728 | // // } | 713 | // // } |
729 | // } | 714 | // } |
730 | 715 | ||
731 | QListViewItem * newItem; | 716 | QListViewItem * newItem; |
732 | if ( QFile( Vdit.current()->file() ).exists() ) { | 717 | if ( QFile( Vdit.current()->file() ).exists() ) { |
733 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 718 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
734 | QString::number( QFile( Vdit.current()->file() ).size() ), | 719 | QString::number( QFile( Vdit.current()->file() ).size() ), |
735 | ""/*storage*/, Vdit.current()->file()); | 720 | ""/*storage*/, Vdit.current()->file()); |
736 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 721 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
737 | } | 722 | } |
738 | } | 723 | } |
739 | videoPopulated=true; | 724 | videoPopulated=true; |
740 | } | 725 | } |
741 | 726 | ||