[vlc-commits] Qt: implement playlist empty button

Edward Wang git at videolan.org
Tue Nov 22 15:21:27 CET 2011


vlc | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Tue Nov 22 15:18:40 2011 +0100| [a4f1bc2b0806c9eb5cf33f965c980b72f836bd6e] | committer: Jean-Baptiste Kempf

Qt: implement playlist empty button

Close #4999

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a4f1bc2b0806c9eb5cf33f965c980b72f836bd6e
---

 modules/gui/qt4/components/playlist/playlist.cpp |   20 ++++++++++++++++++++
 modules/gui/qt4/components/playlist/playlist.hpp |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 382a7ef..661f376 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 <QSignalMapper>
 #include <QMenu>
 #include <QPainter>
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
index ae38a27..7a9886e 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



More information about the vlc-commits mailing list