-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 58 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 2 |
2 files changed, 24 insertions, 36 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 92da73b..c9ae225 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -513,87 +513,67 @@ bool PlayListWidget::last() { | |||
513 | void PlayListWidget::loadList( const DocLnk & lnk) { | 513 | void PlayListWidget::loadList( const DocLnk & lnk) { |
514 | QString name = lnk.name(); | 514 | QString name = lnk.name(); |
515 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 515 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
516 | 516 | ||
517 | if( name.length()>0) { | 517 | if( name.length()>0) { |
518 | setCaption("OpiePlayer: "+name); | 518 | setCaption("OpiePlayer: "+name); |
519 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 519 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
520 | clearList(); | 520 | clearList(); |
521 | readm3u(lnk.file()); | 521 | readm3u(lnk.file()); |
522 | tabWidget->setCurrentPage(0); | 522 | tabWidget->setCurrentPage(0); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | 526 | ||
527 | void PlayListWidget::setPlaylist( bool shown ) { | 527 | void PlayListWidget::setPlaylist( bool shown ) { |
528 | if ( shown ) { | 528 | if ( shown ) { |
529 | d->playListFrame->show(); | 529 | d->playListFrame->show(); |
530 | } else { | 530 | } else { |
531 | d->playListFrame->hide(); | 531 | d->playListFrame->hide(); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void PlayListWidget::addSelected() { | 536 | void PlayListWidget::addSelected() { |
537 | qDebug("addSelected"); | 537 | assert( inFileListMode() ); |
538 | DocLnk lnk; | ||
539 | QString filename; | ||
540 | switch (whichList()) { | ||
541 | 538 | ||
542 | case 0: //playlist | 539 | QListView *fileListView = currentFileListView(); |
543 | return; | 540 | QListViewItemIterator it( fileListView ); |
544 | break; | 541 | for ( ; it.current(); ++it ) |
545 | case 1: { //audio | ||
546 | QListViewItemIterator it( audioView ); | ||
547 | for ( ; it.current(); ++it ) { | ||
548 | if ( it.current()->isSelected() ) { | 542 | if ( it.current()->isSelected() ) { |
549 | filename=it.current()->text(3); | 543 | QString filename = it.current()->text(3); |
550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 544 | |
551 | lnk.setFile( filename ); //sets file name | 545 | DocLnk lnk; |
552 | d->selectedFiles->addToSelection( lnk); | 546 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
553 | 547 | lnk.setFile( filename ); //sets file name | |
554 | } | 548 | |
555 | } | 549 | d->selectedFiles->addToSelection( lnk ); |
556 | audioView->clearSelection(); | ||
557 | } | ||
558 | break; | ||
559 | |||
560 | case 2: { // video | ||
561 | QListViewItemIterator it( videoView ); | ||
562 | for ( ; it.current(); ++it ) { | ||
563 | if ( it.current()->isSelected() ) { | ||
564 | filename=it.current()->text(3); | ||
565 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
566 | lnk.setFile( filename ); //sets file name | ||
567 | d->selectedFiles->addToSelection( lnk); | ||
568 | } | 550 | } |
569 | } | 551 | |
570 | videoView->clearSelection(); | 552 | fileListView->clearSelection(); |
571 | } | 553 | |
572 | break; | 554 | tabWidget->setCurrentPage( 0 ); |
573 | }; | 555 | writeCurrentM3u(); |
574 | tabWidget->setCurrentPage(0); | ||
575 | writeCurrentM3u(); | ||
576 | } | 556 | } |
577 | 557 | ||
578 | 558 | ||
579 | void PlayListWidget::removeSelected() { | 559 | void PlayListWidget::removeSelected() { |
580 | d->selectedFiles->removeSelected( ); | 560 | d->selectedFiles->removeSelected( ); |
581 | writeCurrentM3u(); | 561 | writeCurrentM3u(); |
582 | } | 562 | } |
583 | 563 | ||
584 | 564 | ||
585 | void PlayListWidget::playIt( QListViewItem *it) { | 565 | void PlayListWidget::playIt( QListViewItem *it) { |
586 | if(!it) return; | 566 | if(!it) return; |
587 | mediaPlayerState->setPlaying(FALSE); | 567 | mediaPlayerState->setPlaying(FALSE); |
588 | mediaPlayerState->setPlaying(TRUE); | 568 | mediaPlayerState->setPlaying(TRUE); |
589 | d->selectedFiles->unSelect(); | 569 | d->selectedFiles->unSelect(); |
590 | } | 570 | } |
591 | 571 | ||
592 | 572 | ||
593 | void PlayListWidget::addToSelection( QListViewItem *it) { | 573 | void PlayListWidget::addToSelection( QListViewItem *it) { |
594 | d->setDocumentUsed = FALSE; | 574 | d->setDocumentUsed = FALSE; |
595 | 575 | ||
596 | if(it) { | 576 | if(it) { |
597 | switch ( whichList()) { | 577 | switch ( whichList()) { |
598 | case 0: //playlist | 578 | case 0: //playlist |
599 | return; | 579 | return; |
@@ -778,48 +758,54 @@ void PlayListWidget::populateVideoView() { | |||
778 | // // } | 758 | // // } |
779 | // } | 759 | // } |
780 | 760 | ||
781 | QListViewItem * newItem; | 761 | QListViewItem * newItem; |
782 | if ( QFile( Vdit.current()->file() ).exists() ) { | 762 | if ( QFile( Vdit.current()->file() ).exists() ) { |
783 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 763 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
784 | QString::number( QFile( Vdit.current()->file() ).size() ), | 764 | QString::number( QFile( Vdit.current()->file() ).size() ), |
785 | ""/*storage*/, Vdit.current()->file()); | 765 | ""/*storage*/, Vdit.current()->file()); |
786 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 766 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
787 | } | 767 | } |
788 | } | 768 | } |
789 | videoPopulated=true; | 769 | videoPopulated=true; |
790 | } | 770 | } |
791 | 771 | ||
792 | QListView *PlayListWidget::currentFileListView() const | 772 | QListView *PlayListWidget::currentFileListView() const |
793 | { | 773 | { |
794 | switch ( currentTab() ) { | 774 | switch ( currentTab() ) { |
795 | case AudioFiles: return audioView; | 775 | case AudioFiles: return audioView; |
796 | case VideoFiles: return videoView; | 776 | case VideoFiles: return videoView; |
797 | default: assert( false ); | 777 | default: assert( false ); |
798 | } | 778 | } |
799 | return 0; | 779 | return 0; |
800 | } | 780 | } |
801 | 781 | ||
782 | bool PlayListWidget::inFileListMode() const | ||
783 | { | ||
784 | TabType tab = currentTab(); | ||
785 | return tab == AudioFiles || tab == VideoFiles; | ||
786 | } | ||
787 | |||
802 | void PlayListWidget::openFile() { | 788 | void PlayListWidget::openFile() { |
803 | // http://66.28.164.33:2080 | 789 | // http://66.28.164.33:2080 |
804 | // http://somafm.com/star0242.m3u | 790 | // http://somafm.com/star0242.m3u |
805 | QString filename, name; | 791 | QString filename, name; |
806 | InputDialog *fileDlg; | 792 | InputDialog *fileDlg; |
807 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 793 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
808 | fileDlg->exec(); | 794 | fileDlg->exec(); |
809 | if( fileDlg->result() == 1 ) { | 795 | if( fileDlg->result() == 1 ) { |
810 | filename = fileDlg->text(); | 796 | filename = fileDlg->text(); |
811 | qDebug( "Selected filename is " + filename ); | 797 | qDebug( "Selected filename is " + filename ); |
812 | // Om3u *m3uList; | 798 | // Om3u *m3uList; |
813 | DocLnk lnk; | 799 | DocLnk lnk; |
814 | Config cfg( "OpiePlayer" ); | 800 | Config cfg( "OpiePlayer" ); |
815 | cfg.setGroup("PlayList"); | 801 | cfg.setGroup("PlayList"); |
816 | 802 | ||
817 | if(filename.left(4) == "http") { | 803 | if(filename.left(4) == "http") { |
818 | QString m3uFile, m3uFilePath; | 804 | QString m3uFile, m3uFilePath; |
819 | if(filename.find(":",8,TRUE) != -1) { //found a port | 805 | if(filename.find(":",8,TRUE) != -1) { //found a port |
820 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 806 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
821 | m3uFile = m3uFile.right( 7); | 807 | m3uFile = m3uFile.right( 7); |
822 | } else if(filename.left(4) == "http"){ | 808 | } else if(filename.left(4) == "http"){ |
823 | m3uFile=filename; | 809 | m3uFile=filename; |
824 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 810 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
825 | } else{ | 811 | } else{ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index a608eae..238a75c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -71,48 +71,50 @@ public: | |||
71 | int whichList() const; | 71 | int whichList() const; |
72 | TabType currentTab() const; | 72 | TabType currentTab() const; |
73 | 73 | ||
74 | public slots: | 74 | public slots: |
75 | bool first(); | 75 | bool first(); |
76 | bool last(); | 76 | bool last(); |
77 | bool next(); | 77 | bool next(); |
78 | bool prev(); | 78 | bool prev(); |
79 | void writeDefaultPlaylist( ); | 79 | void writeDefaultPlaylist( ); |
80 | QString currentFileListPathName() const; | 80 | QString currentFileListPathName() const; |
81 | protected: | 81 | protected: |
82 | void keyReleaseEvent( QKeyEvent *e); | 82 | void keyReleaseEvent( QKeyEvent *e); |
83 | 83 | ||
84 | private: | 84 | private: |
85 | int defaultSkinIndex; | 85 | int defaultSkinIndex; |
86 | bool audioScan, videoScan, audioPopulated, videoPopulated; | 86 | bool audioScan, videoScan, audioPopulated, videoPopulated; |
87 | void readm3u(const QString &); | 87 | void readm3u(const QString &); |
88 | void readPls(const QString &); | 88 | void readPls(const QString &); |
89 | void initializeStates(); | 89 | void initializeStates(); |
90 | void populateAudioView(); | 90 | void populateAudioView(); |
91 | void populateVideoView(); | 91 | void populateVideoView(); |
92 | 92 | ||
93 | QListView *currentFileListView() const; | 93 | QListView *currentFileListView() const; |
94 | 94 | ||
95 | bool inFileListMode() const; | ||
96 | |||
95 | private slots: | 97 | private slots: |
96 | void populateSkinsMenu(); | 98 | void populateSkinsMenu(); |
97 | void skinsMenuActivated(int); | 99 | void skinsMenuActivated(int); |
98 | void pmViewActivated(int); | 100 | void pmViewActivated(int); |
99 | void writem3u(); | 101 | void writem3u(); |
100 | void writeCurrentM3u(); | 102 | void writeCurrentM3u(); |
101 | void scanForAudio(); | 103 | void scanForAudio(); |
102 | void scanForVideo(); | 104 | void scanForVideo(); |
103 | void openFile(); | 105 | void openFile(); |
104 | void setDocument( const QString& fileref ); | 106 | void setDocument( const QString& fileref ); |
105 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 107 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
106 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 108 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
107 | void setPlaylist( bool ); // Show/Hide the playlist | 109 | void setPlaylist( bool ); // Show/Hide the playlist |
108 | void clearList(); | 110 | void clearList(); |
109 | void addAllToList(); | 111 | void addAllToList(); |
110 | void addAllMusicToList(); | 112 | void addAllMusicToList(); |
111 | void addAllVideoToList(); | 113 | void addAllVideoToList(); |
112 | void saveList(); // Save the playlist | 114 | void saveList(); // Save the playlist |
113 | void loadList( const DocLnk &); // Load a playlist | 115 | void loadList( const DocLnk &); // Load a playlist |
114 | void playIt( QListViewItem *); | 116 | void playIt( QListViewItem *); |
115 | void btnPlay(bool); | 117 | void btnPlay(bool); |
116 | void deletePlaylist(); | 118 | void deletePlaylist(); |
117 | void addSelected(); | 119 | void addSelected(); |
118 | void removeSelected(); | 120 | void removeSelected(); |