author | simon <simon> | 2002-12-08 19:57:21 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-08 19:57:21 (UTC) |
commit | ce313e53a56591fd883348f5e265606865fdcb50 (patch) (side-by-side diff) | |
tree | f7227b5ed4270b35c92e81545f0e067cf6da90c1 | |
parent | 77ab301a0ab41befda91e6a210c64a72f0d7c264 (diff) | |
download | opie-ce313e53a56591fd883348f5e265606865fdcb50.zip opie-ce313e53a56591fd883348f5e265606865fdcb50.tar.gz opie-ce313e53a56591fd883348f5e265606865fdcb50.tar.bz2 |
- when the file list view is visible only enable the play button if there
is something selected. one crash less ;)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.cpp | 17 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.h | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 15 |
3 files changed, 40 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index cb16415..3ef4d03 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp @@ -20,4 +20,7 @@ PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QStrin setMultiSelection( TRUE ); setSelectionMode( QListView::Extended ); + + connect( this, SIGNAL( selectionChanged() ), + this, SLOT( checkSelection() ) ); } @@ -26,4 +29,13 @@ PlayListFileView::~PlayListFileView() } +bool PlayListFileView::hasSelection() const +{ + for ( QListViewItemIterator it( const_cast<PlayListFileView *>( this ) ); it.current(); ++it ) + if ( it.current()->isSelected() ) + return true; + + return false; +} + void PlayListFileView::scanFiles() { @@ -75,4 +87,9 @@ void PlayListFileView::populateView() } +void PlayListFileView::checkSelection() +{ + emit itemsSelected( hasSelection() ); +} + /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index 6eea2fc..5b15526 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h @@ -13,8 +13,16 @@ public: virtual ~PlayListFileView(); + bool hasSelection() const; + public slots: void scanFiles(); void populateView(); +signals: + void itemsSelected( bool selected ); + +private slots: + void checkSelection(); + private: QString m_mimeTypePattern; diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 2df7f27..c05096a 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -545,4 +545,9 @@ void PlayListWidget::tabChanged(QWidget *) { d->tbPlay->setEnabled( true ); + disconnect( audioView, SIGNAL( itemsSelected( bool ) ), + d->tbPlay, SLOT( setEnabled( bool ) ) ); + disconnect( videoView, SIGNAL( itemsSelected( bool ) ), + d->tbPlay, SLOT( setEnabled( bool ) ) ); + switch ( currentTab() ) { case CurrentPlayList: @@ -566,4 +571,9 @@ void PlayListWidget::tabChanged(QWidget *) { d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); + + connect( audioView, SIGNAL( itemsSelected( bool ) ), + d->tbPlay, SLOT( setEnabled( bool ) ) ); + + d->tbPlay->setEnabled( audioView->hasSelection() ); } break; @@ -576,4 +586,9 @@ void PlayListWidget::tabChanged(QWidget *) { d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); + + connect( videoView, SIGNAL( itemsSelected( bool ) ), + d->tbPlay, SLOT( setEnabled( bool ) ) ); + + d->tbPlay->setEnabled( videoView->hasSelection() ); } break; |