-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 | |||
@@ -53,13 +53,14 @@ | |||
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", |
@@ -474,26 +475,25 @@ void PlayListWidget::loadList( const DocLnk & lnk) { | |||
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 | ||
@@ -539,12 +539,14 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
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 | } |
@@ -565,12 +567,14 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
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() ) { |
@@ -580,12 +584,14 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
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(); |
@@ -622,22 +628,12 @@ void PlayListWidget::deletePlaylist() { | |||
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 | ||
@@ -1006,8 +1002,8 @@ PlayListWidget::Entry PlayListWidget::currentEntry() const | |||
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 | |||
@@ -95,14 +95,12 @@ signals: | |||
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); |
@@ -130,10 +128,11 @@ private slots: | |||
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 | ||