author | simon <simon> | 2002-12-08 19:57:21 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-08 19:57:21 (UTC) |
commit | ce313e53a56591fd883348f5e265606865fdcb50 (patch) (unidiff) | |
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 | |||
@@ -14,22 +14,34 @@ PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QStrin | |||
14 | addColumn(tr( "Media" ), 0 ); | 14 | addColumn(tr( "Media" ), 0 ); |
15 | addColumn(tr( "Path" ), -1 ); | 15 | addColumn(tr( "Path" ), -1 ); |
16 | setColumnAlignment( 1, Qt::AlignRight ); | 16 | setColumnAlignment( 1, Qt::AlignRight ); |
17 | setColumnAlignment( 2, Qt::AlignRight ); | 17 | setColumnAlignment( 2, Qt::AlignRight ); |
18 | setAllColumnsShowFocus( TRUE ); | 18 | setAllColumnsShowFocus( TRUE ); |
19 | setSorting( 3, TRUE ); | 19 | setSorting( 3, TRUE ); |
20 | setMultiSelection( TRUE ); | 20 | setMultiSelection( TRUE ); |
21 | setSelectionMode( QListView::Extended ); | 21 | setSelectionMode( QListView::Extended ); |
22 | |||
23 | connect( this, SIGNAL( selectionChanged() ), | ||
24 | this, SLOT( checkSelection() ) ); | ||
22 | } | 25 | } |
23 | 26 | ||
24 | PlayListFileView::~PlayListFileView() | 27 | PlayListFileView::~PlayListFileView() |
25 | { | 28 | { |
26 | } | 29 | } |
27 | 30 | ||
31 | bool PlayListFileView::hasSelection() const | ||
32 | { | ||
33 | for ( QListViewItemIterator it( const_cast<PlayListFileView *>( this ) ); it.current(); ++it ) | ||
34 | if ( it.current()->isSelected() ) | ||
35 | return true; | ||
36 | |||
37 | return false; | ||
38 | } | ||
39 | |||
28 | void PlayListFileView::scanFiles() | 40 | void PlayListFileView::scanFiles() |
29 | { | 41 | { |
30 | m_files.detachChildren(); | 42 | m_files.detachChildren(); |
31 | QListIterator<DocLnk> sdit( m_files.children() ); | 43 | QListIterator<DocLnk> sdit( m_files.children() ); |
32 | for ( ; sdit.current(); ++sdit ) | 44 | for ( ; sdit.current(); ++sdit ) |
33 | delete sdit.current(); | 45 | delete sdit.current(); |
34 | 46 | ||
35 | Global::findDocuments( &m_files, m_mimeTypePattern ); | 47 | Global::findDocuments( &m_files, m_mimeTypePattern ); |
@@ -69,10 +81,15 @@ void PlayListFileView::populateView() | |||
69 | newItem = new QListViewItem( this, dit.current()->name(), | 81 | newItem = new QListViewItem( this, dit.current()->name(), |
70 | QString::number( size ), "" /*storage*/, | 82 | QString::number( size ), "" /*storage*/, |
71 | dit.current()->file() ); | 83 | dit.current()->file() ); |
72 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); | 84 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); |
73 | } | 85 | } |
74 | } | 86 | } |
75 | } | 87 | } |
76 | 88 | ||
89 | void PlayListFileView::checkSelection() | ||
90 | { | ||
91 | emit itemsSelected( hasSelection() ); | ||
92 | } | ||
93 | |||
77 | /* vim: et sw=4 ts=4 | 94 | /* vim: et sw=4 ts=4 |
78 | */ | 95 | */ |
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 @@ | |||
7 | 7 | ||
8 | class PlayListFileView : public PlayListView | 8 | class PlayListFileView : public PlayListView |
9 | { | 9 | { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | public: | 11 | public: |
12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); | 12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); |
13 | virtual ~PlayListFileView(); | 13 | virtual ~PlayListFileView(); |
14 | 14 | ||
15 | bool hasSelection() const; | ||
16 | |||
15 | public slots: | 17 | public slots: |
16 | void scanFiles(); | 18 | void scanFiles(); |
17 | void populateView(); | 19 | void populateView(); |
18 | 20 | ||
21 | signals: | ||
22 | void itemsSelected( bool selected ); | ||
23 | |||
24 | private slots: | ||
25 | void checkSelection(); | ||
26 | |||
19 | private: | 27 | private: |
20 | QString m_mimeTypePattern; | 28 | QString m_mimeTypePattern; |
21 | QString m_itemPixmapName; | 29 | QString m_itemPixmapName; |
22 | DocLnkSet m_files; | 30 | DocLnkSet m_files; |
23 | bool m_scannedFiles; | 31 | bool m_scannedFiles; |
24 | bool m_viewPopulated; | 32 | bool m_viewPopulated; |
25 | }; | 33 | }; |
26 | 34 | ||
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) { | |||
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | void PlayListWidget::tabChanged(QWidget *) { | 543 | void PlayListWidget::tabChanged(QWidget *) { |
544 | 544 | ||
545 | d->tbPlay->setEnabled( true ); | 545 | d->tbPlay->setEnabled( true ); |
546 | 546 | ||
547 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | ||
548 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
549 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | ||
550 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
551 | |||
547 | switch ( currentTab() ) { | 552 | switch ( currentTab() ) { |
548 | case CurrentPlayList: | 553 | case CurrentPlayList: |
549 | { | 554 | { |
550 | if( !tbDeletePlaylist->isHidden() ) { | 555 | if( !tbDeletePlaylist->isHidden() ) { |
551 | tbDeletePlaylist->hide(); | 556 | tbDeletePlaylist->hide(); |
552 | } | 557 | } |
553 | d->tbRemoveFromList->setEnabled(TRUE); | 558 | d->tbRemoveFromList->setEnabled(TRUE); |
554 | d->tbAddToList->setEnabled(FALSE); | 559 | d->tbAddToList->setEnabled(FALSE); |
@@ -560,26 +565,36 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
560 | { | 565 | { |
561 | audioView->populateView(); | 566 | audioView->populateView(); |
562 | 567 | ||
563 | if( !tbDeletePlaylist->isHidden() ) { | 568 | if( !tbDeletePlaylist->isHidden() ) { |
564 | tbDeletePlaylist->hide(); | 569 | tbDeletePlaylist->hide(); |
565 | } | 570 | } |
566 | d->tbRemoveFromList->setEnabled(FALSE); | 571 | d->tbRemoveFromList->setEnabled(FALSE); |
567 | d->tbAddToList->setEnabled(TRUE); | 572 | d->tbAddToList->setEnabled(TRUE); |
573 | |||
574 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | ||
575 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
576 | |||
577 | d->tbPlay->setEnabled( audioView->hasSelection() ); | ||
568 | } | 578 | } |
569 | break; | 579 | break; |
570 | case VideoFiles: | 580 | case VideoFiles: |
571 | { | 581 | { |
572 | videoView->populateView(); | 582 | videoView->populateView(); |
573 | if( !tbDeletePlaylist->isHidden() ) { | 583 | if( !tbDeletePlaylist->isHidden() ) { |
574 | tbDeletePlaylist->hide(); | 584 | tbDeletePlaylist->hide(); |
575 | } | 585 | } |
576 | d->tbRemoveFromList->setEnabled(FALSE); | 586 | d->tbRemoveFromList->setEnabled(FALSE); |
577 | d->tbAddToList->setEnabled(TRUE); | 587 | d->tbAddToList->setEnabled(TRUE); |
588 | |||
589 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | ||
590 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
591 | |||
592 | d->tbPlay->setEnabled( videoView->hasSelection() ); | ||
578 | } | 593 | } |
579 | break; | 594 | break; |
580 | case PlayLists: | 595 | case PlayLists: |
581 | { | 596 | { |
582 | if( tbDeletePlaylist->isHidden() ) { | 597 | if( tbDeletePlaylist->isHidden() ) { |
583 | tbDeletePlaylist->show(); | 598 | tbDeletePlaylist->show(); |
584 | } | 599 | } |
585 | playLists->reread(); | 600 | playLists->reread(); |