]> git.sesse.net Git - vlc/commitdiff
Qt: implement playlist empty button
authorEdward Wang <edward.c.wang@compdigitec.com>
Tue, 22 Nov 2011 14:18:40 +0000 (15:18 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 22 Nov 2011 14:21:17 +0000 (15:21 +0100)
Close #4999

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.hpp

index 382a7efc7d15d50d399ed0c86aaa0984198c644f..661f376375ddf3534a269c65fa6d1f5341e781fc 100644 (file)
@@ -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>
index ae38a279a87a68966c0de59a9d4a1c88e7cbcf8f..7a9886e17b3cd116fadd99e980aa0b4b16eb20d9 100644 (file)
@@ -75,6 +75,7 @@ protected:
     virtual void closeEvent( QCloseEvent * );
 private slots:
     void changeView( const QModelIndex& index );
+    void clearPlaylist();
 };
 
 #ifdef Q_WS_MAC