Commit 4b21b04e authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

Qt: Move the clear playlist button to the context menu

Modified-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 1a821f0b
...@@ -112,13 +112,6 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) ...@@ -112,13 +112,6 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
layout->addLayout( topbarLayout, 0, 1 ); layout->addLayout( topbarLayout, 0, 1 );
topbarLayout->setSpacing( 10 ); 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 */ /* Button to switch views */
QToolButton *viewButton = new QToolButton( this ); QToolButton *viewButton = new QToolButton( this );
viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) ); viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
...@@ -262,16 +255,7 @@ void PlaylistWidget::changeView( const QModelIndex& index ) ...@@ -262,16 +255,7 @@ void PlaylistWidget::changeView( const QModelIndex& index )
void PlaylistWidget::clearPlaylist() void PlaylistWidget::clearPlaylist()
{ {
PLModel *model = PLModel::getPLModel( p_intf ); PLModel::getPLModel( p_intf )->clearPlaylist();
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 <QSignalMapper>
#include <QMenu> #include <QMenu>
......
...@@ -888,6 +888,19 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool ...@@ -888,6 +888,19 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool
rebuild(); rebuild();
} }
void PLModel::clearPlaylist()
{
if( rowCount() < 1 ) return;
QModelIndexList l;
for( int i = 0; i < rowCount(); i++)
{
QModelIndex indexrecord = index( i, 0, QModelIndex() );
l.append( indexrecord );
}
doDelete(l);
}
/*********** Popup *********/ /*********** Popup *********/
bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list ) bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
{ {
...@@ -964,6 +977,10 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode ...@@ -964,6 +977,10 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
} }
menu.addSeparator(); menu.addSeparator();
menu.addAction( QIcon( ":/toolbar/clear" ), qtr("Clear playlist"),
this, SLOT( clearPlaylist() ) );
/* Playlist sorting */ /* Playlist sorting */
if( !sortingMenu ) if( !sortingMenu )
{ {
......
...@@ -120,7 +120,7 @@ signals: ...@@ -120,7 +120,7 @@ signals:
public slots: public slots:
virtual void activateItem( const QModelIndex &index ); virtual void activateItem( const QModelIndex &index );
void clearPlaylist();
private: private:
/* General */ /* General */
PLItem *rootItem; PLItem *rootItem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment