From: Edward Wang Date: Tue, 22 Nov 2011 14:18:40 +0000 (+0100) Subject: Qt: implement playlist empty button X-Git-Tag: 1.3.0-git~189 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a4f1bc2b0806c9eb5cf33f965c980b72f836bd6e;p=vlc Qt: implement playlist empty button Close #4999 Signed-off-by: Jean-Baptiste Kempf --- diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp index 382a7efc7d..661f376375 100644 --- a/modules/gui/qt4/components/playlist/playlist.cpp +++ b/modules/gui/qt4/components/playlist/playlist.cpp @@ -112,6 +112,13 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) layout->addLayout( topbarLayout, 0, 1 ); topbarLayout->setSpacing( 10 ); + /* Button to clear playlist */ + QToolButton *clearPlaylistButton = new QToolButton( this ); + clearPlaylistButton->setIcon( style()->standardIcon( QStyle::SP_TrashIcon ) ); + clearPlaylistButton->setToolTip( qtr("Clear playlist") ); + topbarLayout->addWidget( clearPlaylistButton ); + CONNECT( clearPlaylistButton, clicked(), this, clearPlaylist() ); + /* Button to switch views */ QToolButton *viewButton = new QToolButton( this ); viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) ); @@ -249,6 +256,19 @@ void PlaylistWidget::changeView( const QModelIndex& index ) viewActions[i]->setChecked(true); } +void PlaylistWidget::clearPlaylist() +{ + PLModel *model = PLModel::getPLModel( p_intf ); + if( model->rowCount() < 1 ) return; + + QModelIndexList* l = new QModelIndexList(); + for( int i = 0; i < model->rowCount(); i++) + { + QModelIndex indexrecord = model->index( i, 0, QModelIndex() ); + l->append( indexrecord ); + } + model->doDelete(*l); +} #include #include #include diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp index ae38a279a8..7a9886e17b 100644 --- a/modules/gui/qt4/components/playlist/playlist.hpp +++ b/modules/gui/qt4/components/playlist/playlist.hpp @@ -75,6 +75,7 @@ protected: virtual void closeEvent( QCloseEvent * ); private slots: void changeView( const QModelIndex& index ); + void clearPlaylist(); }; #ifdef Q_WS_MAC