[vlc-commits] Qt: Move the clear playlist button to the context menu
Edward Wang
git at videolan.org
Mon Jan 2 17:20:04 CET 2012
vlc/vlc-1.2 | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Mon Jan 2 14:02:56 2012 +0100| [07fffc759628889b5eee1be4614db53823081111] | committer: Jean-Baptiste Kempf
Qt: Move the clear playlist button to the context menu
Modified-by: Jean-Baptiste Kempf <jb at videolan.org>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 4b21b04e9fde44100c61c259ce8282a504aaa748)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=07fffc759628889b5eee1be4614db53823081111
---
modules/gui/qt4/components/playlist/playlist.cpp | 18 +-----------------
.../gui/qt4/components/playlist/playlist_model.cpp | 17 +++++++++++++++++
.../gui/qt4/components/playlist/playlist_model.hpp | 2 +-
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 32b0ea9..7d04d12 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -112,13 +112,6 @@ 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 ) );
@@ -262,16 +255,7 @@ void PlaylistWidget::changeView( const QModelIndex& index )
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);
+ PLModel::getPLModel( p_intf )->clearPlaylist();
}
#include <QSignalMapper>
#include <QMenu>
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 8b3e089..4e69d3c 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -888,6 +888,19 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool
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 *********/
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
}
menu.addSeparator();
+
+ menu.addAction( QIcon( ":/toolbar/clear" ), qtr("Clear playlist"),
+ this, SLOT( clearPlaylist() ) );
+
/* Playlist sorting */
if( !sortingMenu )
{
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 6c66c7e..ea3bfb2 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -120,7 +120,7 @@ signals:
public slots:
virtual void activateItem( const QModelIndex &index );
-
+ void clearPlaylist();
private:
/* General */
PLItem *rootItem;
More information about the vlc-commits
mailing list