-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 26 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 3 |
2 files changed, 12 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index b78ce24..889667c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -47,25 +47,26 @@ | |||
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 | #include "playlistfileview.h" |
53 | 53 | ||
54 | //only needed for the random play | 54 | //only needed for the random play |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <assert.h> | 56 | #include <assert.h> |
57 | 57 | ||
58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { | 59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) |
60 | { | ||
60 | 61 | ||
61 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
62 | "opieplayer2/add_to_playlist", | 63 | "opieplayer2/add_to_playlist", |
63 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
64 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
65 | "opieplayer2/remove_from_playlist", | 66 | "opieplayer2/remove_from_playlist", |
66 | this , SLOT(removeSelected() ) ); | 67 | this , SLOT(removeSelected() ) ); |
67 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
68 | this , SLOT( btnPlay( bool) ), TRUE ); | 69 | this , SLOT( btnPlay( bool) ), TRUE ); |
69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
70 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
@@ -468,38 +469,37 @@ void PlayListWidget::loadList( const DocLnk & lnk) { | |||
468 | if( name.length()>0) { | 469 | if( name.length()>0) { |
469 | setCaption("OpiePlayer: "+name); | 470 | setCaption("OpiePlayer: "+name); |
470 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 471 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
471 | clearList(); | 472 | clearList(); |
472 | readm3u(lnk.file()); | 473 | readm3u(lnk.file()); |
473 | tabWidget->setCurrentPage(0); | 474 | tabWidget->setCurrentPage(0); |
474 | } | 475 | } |
475 | } | 476 | } |
476 | 477 | ||
477 | void PlayListWidget::addSelected() { | 478 | void PlayListWidget::addSelected() { |
478 | assert( inFileListMode() ); | 479 | assert( inFileListMode() ); |
479 | 480 | ||
480 | QListView *fileListView = currentFileListView(); | 481 | QListViewItemIterator it( currentFileListView ); |
481 | QListViewItemIterator it( fileListView ); | ||
482 | for ( ; it.current(); ++it ) | 482 | for ( ; it.current(); ++it ) |
483 | if ( it.current()->isSelected() ) { | 483 | if ( it.current()->isSelected() ) { |
484 | QString filename = it.current()->text(3); | 484 | QString filename = it.current()->text(3); |
485 | 485 | ||
486 | DocLnk lnk; | 486 | DocLnk lnk; |
487 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 487 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
488 | lnk.setFile( filename ); //sets file name | 488 | lnk.setFile( filename ); //sets file name |
489 | 489 | ||
490 | d->selectedFiles->addToSelection( lnk ); | 490 | d->selectedFiles->addToSelection( lnk ); |
491 | } | 491 | } |
492 | 492 | ||
493 | fileListView->clearSelection(); | 493 | currentFileListView->clearSelection(); |
494 | 494 | ||
495 | tabWidget->setCurrentPage( 0 ); | 495 | tabWidget->setCurrentPage( 0 ); |
496 | writeCurrentM3u(); | 496 | writeCurrentM3u(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | void PlayListWidget::removeSelected() { | 500 | void PlayListWidget::removeSelected() { |
501 | d->selectedFiles->removeSelected( ); | 501 | d->selectedFiles->removeSelected( ); |
502 | writeCurrentM3u(); | 502 | writeCurrentM3u(); |
503 | } | 503 | } |
504 | 504 | ||
505 | 505 | ||
@@ -533,24 +533,26 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void PlayListWidget::tabChanged(QWidget *) { | 536 | void PlayListWidget::tabChanged(QWidget *) { |
537 | 537 | ||
538 | d->tbPlay->setEnabled( true ); | 538 | d->tbPlay->setEnabled( true ); |
539 | 539 | ||
540 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | 540 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), |
541 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 541 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
542 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | 542 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), |
543 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 543 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
544 | 544 | ||
545 | currentFileListView = 0; | ||
546 | |||
545 | switch ( currentTab() ) { | 547 | switch ( currentTab() ) { |
546 | case CurrentPlayList: | 548 | case CurrentPlayList: |
547 | { | 549 | { |
548 | if( !tbDeletePlaylist->isHidden() ) { | 550 | if( !tbDeletePlaylist->isHidden() ) { |
549 | tbDeletePlaylist->hide(); | 551 | tbDeletePlaylist->hide(); |
550 | } | 552 | } |
551 | d->tbRemoveFromList->setEnabled(TRUE); | 553 | d->tbRemoveFromList->setEnabled(TRUE); |
552 | d->tbAddToList->setEnabled(FALSE); | 554 | d->tbAddToList->setEnabled(FALSE); |
553 | 555 | ||
554 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 556 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
555 | } | 557 | } |
556 | break; | 558 | break; |
@@ -559,39 +561,43 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
559 | audioView->populateView(); | 561 | audioView->populateView(); |
560 | 562 | ||
561 | if( !tbDeletePlaylist->isHidden() ) { | 563 | if( !tbDeletePlaylist->isHidden() ) { |
562 | tbDeletePlaylist->hide(); | 564 | tbDeletePlaylist->hide(); |
563 | } | 565 | } |
564 | d->tbRemoveFromList->setEnabled(FALSE); | 566 | d->tbRemoveFromList->setEnabled(FALSE); |
565 | d->tbAddToList->setEnabled(TRUE); | 567 | d->tbAddToList->setEnabled(TRUE); |
566 | 568 | ||
567 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | 569 | connect( audioView, SIGNAL( itemsSelected( bool ) ), |
568 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 570 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
569 | 571 | ||
570 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 572 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
573 | |||
574 | currentFileListView = audioView; | ||
571 | } | 575 | } |
572 | break; | 576 | break; |
573 | case VideoFiles: | 577 | case VideoFiles: |
574 | { | 578 | { |
575 | videoView->populateView(); | 579 | videoView->populateView(); |
576 | if( !tbDeletePlaylist->isHidden() ) { | 580 | if( !tbDeletePlaylist->isHidden() ) { |
577 | tbDeletePlaylist->hide(); | 581 | tbDeletePlaylist->hide(); |
578 | } | 582 | } |
579 | d->tbRemoveFromList->setEnabled(FALSE); | 583 | d->tbRemoveFromList->setEnabled(FALSE); |
580 | d->tbAddToList->setEnabled(TRUE); | 584 | d->tbAddToList->setEnabled(TRUE); |
581 | 585 | ||
582 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | 586 | connect( videoView, SIGNAL( itemsSelected( bool ) ), |
583 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 587 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
584 | 588 | ||
585 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 589 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
590 | |||
591 | currentFileListView = videoView; | ||
586 | } | 592 | } |
587 | break; | 593 | break; |
588 | case PlayLists: | 594 | case PlayLists: |
589 | { | 595 | { |
590 | if( tbDeletePlaylist->isHidden() ) { | 596 | if( tbDeletePlaylist->isHidden() ) { |
591 | tbDeletePlaylist->show(); | 597 | tbDeletePlaylist->show(); |
592 | } | 598 | } |
593 | playLists->reread(); | 599 | playLists->reread(); |
594 | d->tbAddToList->setEnabled(FALSE); | 600 | d->tbAddToList->setEnabled(FALSE); |
595 | 601 | ||
596 | d->tbPlay->setEnabled( false ); | 602 | d->tbPlay->setEnabled( false ); |
597 | } | 603 | } |
@@ -616,34 +622,24 @@ void PlayListWidget::deletePlaylist() { | |||
616 | playLists->reread(); | 622 | playLists->reread(); |
617 | break; | 623 | break; |
618 | case 1: // Cancel | 624 | case 1: // Cancel |
619 | break; | 625 | break; |
620 | }; | 626 | }; |
621 | } | 627 | } |
622 | 628 | ||
623 | 629 | ||
624 | void PlayListWidget::playSelected() { | 630 | void PlayListWidget::playSelected() { |
625 | btnPlay( TRUE); | 631 | btnPlay( TRUE); |
626 | } | 632 | } |
627 | 633 | ||
628 | QListView *PlayListWidget::currentFileListView() const | ||
629 | { | ||
630 | switch ( currentTab() ) { | ||
631 | case AudioFiles: return audioView; | ||
632 | case VideoFiles: return videoView; | ||
633 | default: assert( false ); | ||
634 | } | ||
635 | return 0; | ||
636 | } | ||
637 | |||
638 | bool PlayListWidget::inFileListMode() const | 634 | bool PlayListWidget::inFileListMode() const |
639 | { | 635 | { |
640 | TabType tab = currentTab(); | 636 | TabType tab = currentTab(); |
641 | return tab == AudioFiles || tab == VideoFiles; | 637 | return tab == AudioFiles || tab == VideoFiles; |
642 | } | 638 | } |
643 | 639 | ||
644 | void PlayListWidget::openFile() { | 640 | void PlayListWidget::openFile() { |
645 | // http://66.28.164.33:2080 | 641 | // http://66.28.164.33:2080 |
646 | // http://somafm.com/star0242.m3u | 642 | // http://somafm.com/star0242.m3u |
647 | QString filename, name; | 643 | QString filename, name; |
648 | InputDialog *fileDlg; | 644 | InputDialog *fileDlg; |
649 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
@@ -1000,14 +996,14 @@ PlayListWidget::TabType PlayListWidget::currentTab() const | |||
1000 | 996 | ||
1001 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 997 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1002 | { | 998 | { |
1003 | if ( currentTab() == CurrentPlayList ) { | 999 | if ( currentTab() == CurrentPlayList ) { |
1004 | const DocLnk *lnk = current(); | 1000 | const DocLnk *lnk = current(); |
1005 | return Entry( lnk->name(), lnk->file() ); | 1001 | return Entry( lnk->name(), lnk->file() ); |
1006 | } | 1002 | } |
1007 | 1003 | ||
1008 | return Entry( currentFileListPathName() ); | 1004 | return Entry( currentFileListPathName() ); |
1009 | } | 1005 | } |
1010 | 1006 | ||
1011 | QString PlayListWidget::currentFileListPathName() const { | 1007 | QString PlayListWidget::currentFileListPathName() const { |
1012 | return currentFileListView()->currentItem()->text( 3 ); | 1008 | return currentFileListView->currentItem()->text( 3 ); |
1013 | } | 1009 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 5c8f30c..e8bf211 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -89,26 +89,24 @@ public slots: | |||
89 | protected: | 89 | protected: |
90 | void keyReleaseEvent( QKeyEvent *e); | 90 | void keyReleaseEvent( QKeyEvent *e); |
91 | 91 | ||
92 | signals: | 92 | signals: |
93 | void skinSelected(); | 93 | void skinSelected(); |
94 | 94 | ||
95 | private: | 95 | private: |
96 | int defaultSkinIndex; | 96 | int defaultSkinIndex; |
97 | void readm3u(const QString &); | 97 | void readm3u(const QString &); |
98 | void readPls(const QString &); | 98 | void readPls(const QString &); |
99 | void initializeStates(); | 99 | void initializeStates(); |
100 | 100 | ||
101 | QListView *currentFileListView() const; | ||
102 | |||
103 | bool inFileListMode() const; | 101 | bool inFileListMode() const; |
104 | 102 | ||
105 | private slots: | 103 | private slots: |
106 | void populateSkinsMenu(); | 104 | void populateSkinsMenu(); |
107 | void skinsMenuActivated(int); | 105 | void skinsMenuActivated(int); |
108 | void pmViewActivated(int); | 106 | void pmViewActivated(int); |
109 | void writem3u(); | 107 | void writem3u(); |
110 | void writeCurrentM3u(); | 108 | void writeCurrentM3u(); |
111 | void openFile(); | 109 | void openFile(); |
112 | void setDocument( const QString& fileref ); | 110 | void setDocument( const QString& fileref ); |
113 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 111 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
114 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 112 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
@@ -124,16 +122,17 @@ private slots: | |||
124 | void addSelected(); | 122 | void addSelected(); |
125 | void removeSelected(); | 123 | void removeSelected(); |
126 | void tabChanged(QWidget*); | 124 | void tabChanged(QWidget*); |
127 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 125 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
128 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 126 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
129 | void playSelected(); | 127 | void playSelected(); |
130 | 128 | ||
131 | private: | 129 | private: |
132 | bool fromSetDocument; | 130 | bool fromSetDocument; |
133 | bool insanityBool; | 131 | bool insanityBool; |
134 | QString setDocFileRef, currentPlayList; | 132 | QString setDocFileRef, currentPlayList; |
135 | int selected; | 133 | int selected; |
134 | QListView *currentFileListView; | ||
136 | }; | 135 | }; |
137 | 136 | ||
138 | #endif // PLAY_LIST_WIDGET_H | 137 | #endif // PLAY_LIST_WIDGET_H |
139 | 138 | ||