-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 @@ -14,22 +14,34 @@ PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QStrin addColumn(tr( "Media" ), 0 ); addColumn(tr( "Path" ), -1 ); setColumnAlignment( 1, Qt::AlignRight ); setColumnAlignment( 2, Qt::AlignRight ); setAllColumnsShowFocus( TRUE ); setSorting( 3, TRUE ); setMultiSelection( TRUE ); setSelectionMode( QListView::Extended ); + + connect( this, SIGNAL( selectionChanged() ), + this, SLOT( checkSelection() ) ); } 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() { m_files.detachChildren(); QListIterator<DocLnk> sdit( m_files.children() ); for ( ; sdit.current(); ++sdit ) delete sdit.current(); Global::findDocuments( &m_files, m_mimeTypePattern ); @@ -69,10 +81,15 @@ void PlayListFileView::populateView() newItem = new QListViewItem( this, dit.current()->name(), QString::number( size ), "" /*storage*/, dit.current()->file() ); newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); } } } +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 @@ -7,20 +7,28 @@ class PlayListFileView : public PlayListView { Q_OBJECT public: PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); virtual ~PlayListFileView(); + bool hasSelection() const; + public slots: void scanFiles(); void populateView(); +signals: + void itemsSelected( bool selected ); + +private slots: + void checkSelection(); + private: QString m_mimeTypePattern; QString m_itemPixmapName; DocLnkSet m_files; bool m_scannedFiles; bool m_viewPopulated; }; 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 @@ -539,16 +539,21 @@ void PlayListWidget::addToSelection( QListViewItem *it) { } } 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: { if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(TRUE); d->tbAddToList->setEnabled(FALSE); @@ -560,26 +565,36 @@ void PlayListWidget::tabChanged(QWidget *) { { audioView->populateView(); if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); + + connect( audioView, SIGNAL( itemsSelected( bool ) ), + d->tbPlay, SLOT( setEnabled( bool ) ) ); + + d->tbPlay->setEnabled( audioView->hasSelection() ); } break; case VideoFiles: { videoView->populateView(); if( !tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->hide(); } d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); + + connect( videoView, SIGNAL( itemsSelected( bool ) ), + d->tbPlay, SLOT( setEnabled( bool ) ) ); + + d->tbPlay->setEnabled( videoView->hasSelection() ); } break; case PlayLists: { if( tbDeletePlaylist->isHidden() ) { tbDeletePlaylist->show(); } playLists->reread(); |