#include <QMenu>
#include <QSignalMapper>
#include <QSlider>
+#include <QStackedWidget>
/**********************************************************************
* Playlist Widget. The embedded playlist
/* Create a Container for the Art Label
in order to have a beautiful resizing for the selector above it */
- QWidget *artContainer = new QWidget;
- QHBoxLayout *artContLay = new QHBoxLayout( artContainer );
- artContLay->setMargin( 0 );
- artContLay->setSpacing( 0 );
+ artContainer = new QStackedWidget;
artContainer->setMaximumHeight( 128 );
/* Art label */
CoverArtLabel *art = new CoverArtLabel( artContainer, p_intf );
art->setToolTip( qtr( "Double click to get media information" ) );
- artContLay->addWidget( art, 1 );
+ artContainer->addWidget( art );
CONNECT( THEMIM->getIM(), artChanged( QString ),
art, showArtUpdate( const QString& ) );
setMinimumWidth( 400 );
- PLModel *model = new PLModel( p_playlist, p_intf, p_root, this );
+ PLModel *model = PLModel::getPLModel( p_intf );
#ifdef MEDIA_LIBRARY
MLModel *mlmodel = new MLModel( p_intf, this );
mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, mlmodel );
CONNECT( locationBar, invoked( const QModelIndex & ),
mainView, browseInto( const QModelIndex & ) );
- QHBoxLayout *topbarLayout = new QHBoxLayout( this );
+ QHBoxLayout *topbarLayout = new QHBoxLayout();
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 ) );
QActionGroup *actionGroup = new QActionGroup( this );
- for( int i = 0; i < StandardPLPanel::VIEW_COUNT; i++ )
+#ifndef NDEBUG
+# define MAX_VIEW StandardPLPanel::VIEW_COUNT
+#else
+# define MAX_VIEW StandardPLPanel::VIEW_COUNT - 1
+#endif
+ for( int i = 0; i < MAX_VIEW; i++ )
{
viewActions[i] = actionGroup->addAction( viewNames[i] );
viewActions[i]->setCheckable( true );
CONNECT( mainView, viewChanged( const QModelIndex& ),
this, changeView( const QModelIndex &) );
- /* Zoom */
- QSlider *zoomSlider = new QSlider( Qt::Horizontal, this );
- zoomSlider->setRange( -10, 10);
- zoomSlider->setPageStep( 3 );
- zoomSlider->setValue( model->getZoom() );
- zoomSlider->setToolTip( qtr("Zoom playlist") );
- CONNECT( zoomSlider, valueChanged( int ), model, changeZoom( int ) );
- topbarLayout->addWidget( zoomSlider );
-
/* Connect the activation of the selector to a redefining of the PL */
DCONNECT( selector, categoryActivated( playlist_item_t *, bool ),
- mainView, setRoot( playlist_item_t *, bool ) );
- mainView->setRoot( p_root, false );
+ mainView, setRootItem( playlist_item_t *, bool ) );
+ mainView->setRootItem( p_root, false );
/* */
split = new PlaylistSplitter( this );
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>