]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist.cpp
Qt: rename playlist root* functions and getters for clarity
[vlc] / modules / gui / qt4 / components / playlist / playlist.cpp
index e10a11bc1c4dcfe7790a53beb940164027290f24..382a7efc7d15d50d399ed0c86aaa0984198c644f 100644 (file)
@@ -41,8 +41,7 @@
 #include <QMenu>
 #include <QSignalMapper>
 #include <QSlider>
-#include <QSpacerItem>
-#include <QList>
+#include <QStackedWidget>
 
 /**********************************************************************
  * Playlist Widget. The embedded playlist
@@ -69,16 +68,13 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     /* 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& ) );
@@ -96,7 +92,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     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 );
@@ -112,11 +108,15 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     CONNECT( locationBar, invoked( const QModelIndex & ),
              mainView, browseInto( const QModelIndex & ) );
 
+    QHBoxLayout *topbarLayout = new QHBoxLayout();
+    layout->addLayout( topbarLayout, 0, 1 );
+    topbarLayout->setSpacing( 10 );
+
     /* Button to switch views */
     QToolButton *viewButton = new QToolButton( this );
     viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
     viewButton->setToolTip( qtr("Change playlistview") );
-    layout->addWidget( viewButton, 0, 2 );
+    topbarLayout->addWidget( viewButton );
 
     /* View selection menu */
     QSignalMapper *viewSelectionMapper = new QSignalMapper( this );
@@ -124,7 +124,12 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     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 );
@@ -142,7 +147,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     searchEdit = new SearchLineEdit( this );
     searchEdit->setMaximumWidth( 250 );
     searchEdit->setMinimumWidth( 80 );
-    layout->addWidget( searchEdit, 0, 3 );
+    searchEdit->setToolTip( qtr("Search the playlist") );
+    topbarLayout->addWidget( searchEdit );
     CONNECT( searchEdit, textChanged( const QString& ),
              mainView, search( const QString& ) );
     CONNECT( searchEdit, searchDelayedChanged( const QString& ),
@@ -150,12 +156,11 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     CONNECT( mainView, viewChanged( const QModelIndex& ),
              this, changeView( const QModelIndex &) );
-    layout->setColumnStretch( 3, 3 );
 
     /* 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 );
@@ -182,24 +187,6 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     layout->addWidget( split, 1, 0, 1, -1 );
 
-    /* Zoom */
-    QSlider *zoomSlider = new QSlider( Qt::Horizontal, this );
-    zoomSlider->setRange( -10, 10);
-    zoomSlider->setPageStep( 3 );
-    zoomSlider->setValue( model->getZoom() );
-    CONNECT( zoomSlider, valueChanged( int ), model, changeZoom( int ) );
-
-    /* pad our zoom slider */
-    QGridLayout *sliderLayout = new QGridLayout;
-    QSpacerItem* sliderSpacer =
-            new QSpacerItem( mainView->getScrollBarsSize(),
-                             mainView->getScrollBarsSize(),
-                            QSizePolicy::Fixed, QSizePolicy::Fixed );
-    sliderLayout->addWidget( zoomSlider, 0, 0, Qt::AlignCenter );
-    sliderLayout->addItem( sliderSpacer, 1, 1, Qt::AlignCenter );
-
-    layout->addLayout( sliderLayout, 1, 3, ( Qt::AlignBottom | Qt::AlignRight ) );
-
     setAcceptDrops( true );
     setWindowTitle( qtr( "Playlist" ) );
     setWindowRole( "vlc-playlist" );