]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/standardpanel.cpp
Qt4: remove proto combo from open net tab
[vlc] / modules / gui / qt4 / components / playlist / standardpanel.cpp
index 3178c7db864c4ae9e1c95291d98129f4135d969a..aac73277d429ca4b2653e952bb5bc70f48bb31f7 100644 (file)
@@ -54,7 +54,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   playlist_item_t *p_root ):
                                   PLPanel( _parent, _p_intf )
 {
-    model = new PLModel( p_playlist, p_intf, p_root, -1, this );
+    model = new PLModel( p_playlist, p_intf, p_root, this );
 
     QVBoxLayout *layout = new QVBoxLayout();
     layout->setSpacing( 0 ); layout->setMargin( 0 );
@@ -71,6 +71,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     view->setAcceptDrops( true );
     view->setDropIndicatorShown( true );
     view->header()->setSortIndicator( -1 , Qt::AscendingOrder );
+    view->setUniformRowHeights( true );
     view->setSortingEnabled( true );
 
 
@@ -82,9 +83,13 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     }
     else
     {
-        /* Configure the size of the header */
-        view->header()->resizeSection( 0, 200 );
-        view->header()->resizeSection( 1, 80 );
+        int m, c;
+        for( m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
+        {
+            view->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
+            if( m == COLUMN_TITLE ) view->header()->resizeSection( c, 200 );
+            else if( m == COLUMN_DURATION ) view->header()->resizeSection( c, 80 );
+        }
     }
     view->header()->setSortIndicatorShown( true );
     view->header()->setClickable( true );
@@ -102,7 +107,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
              this, handleExpansion( const QModelIndex& ) );
 
     currentRootId = -1;
-    CONNECT( parent, rootChanged( int ), this, setCurrentRootId( int ) );
 
     /* Buttons configuration */
     QHBoxLayout *buttons = new QHBoxLayout;
@@ -164,11 +168,22 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     filter->setBuddy( search );
     CONNECT( search, textChanged( const QString& ), this, search( const QString& ) );
 
+    /* Title label */
+    title = new QLabel;
+    QFont titleFont;
+    titleFont.setPointSize( titleFont.pointSize() + 6 );
+    titleFont.setFamily( "Verdana" );
+    title->setFont( titleFont );
+
     /* Finish the layout */
+    layout->addWidget( title );
     layout->addWidget( view );
     layout->addLayout( buttons );
 //    layout->addWidget( bar );
     setLayout( layout );
+
+    selectColumnsSigMapper = new QSignalMapper( this );
+    CONNECT( selectColumnsSigMapper, mapped( int ), this, toggleColumnShown( int ) );
 }
 
 /* Function to toggle between the Repeat states */
@@ -203,33 +218,12 @@ void StandardPLPanel::toggleRandom()
 
 void StandardPLPanel::gotoPlayingItem()
 {
-    view->scrollTo( view->currentIndex() );
+    view->scrollTo( model->currentIndex() );
 }
 
 void StandardPLPanel::handleExpansion( const QModelIndex& index )
 {
-    view->scrollTo( index, QAbstractItemView::EnsureVisible );
-}
-
-void StandardPLPanel::setCurrentRootId( int _new )
-{
-    currentRootId = _new;
-    if( currentRootId == THEPL->p_local_category->i_id ||
-        currentRootId == THEPL->p_local_onelevel->i_id  )
-    {
-        addButton->setEnabled( true );
-        addButton->setToolTip( qtr(I_PL_ADDPL) );
-    }
-    else if( ( THEPL->p_ml_category &&
-                        currentRootId == THEPL->p_ml_category->i_id ) ||
-             ( THEPL->p_ml_onelevel &&
-                        currentRootId == THEPL->p_ml_onelevel->i_id ) )
-    {
-        addButton->setEnabled( true );
-        addButton->setToolTip( qtr(I_PL_ADDML) );
-    }
-    else
-        addButton->setEnabled( false );
+    view->scrollTo( index );
 }
 
 /* PopupAdd Menu for the Add Menu */
@@ -259,24 +253,26 @@ void StandardPLPanel::popupAdd()
 
 void StandardPLPanel::popupSelectColumn( QPoint pos )
 {
-    ContextUpdateMapper = new QSignalMapper(this);
-
-    QMenu selectColMenu;
-
-    CONNECT( ContextUpdateMapper, mapped( int ),  model, viewchanged( int ) );
+    QMenu menu;
 
-    int i_column = 1;
-    for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
+    /* We do not offer the option to hide index 0 column, or
+    * QTreeView will behave weird */
+    int i, j;
+    for( i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
     {
-        QAction* option = selectColMenu.addAction(
-            qfu( psz_column_title( i_column ) ) );
+        QAction* option = menu.addAction(
+            qfu( psz_column_title( i ) ) );
         option->setCheckable( true );
-        option->setChecked( model->shownFlags() & i_column );
-        ContextUpdateMapper->setMapping( option, i_column );
-        CONNECT( option, triggered(), ContextUpdateMapper, map() );
+        option->setChecked( !view->isColumnHidden( j ) );
+        selectColumnsSigMapper->setMapping( option, j );
+        CONNECT( option, triggered(), selectColumnsSigMapper, map() );
     }
+    menu.exec( QCursor::pos() );
+}
 
-    selectColMenu.exec( QCursor::pos() );
+void StandardPLPanel::toggleColumnShown( int i )
+{
+    view->setColumnHidden( i, !view->isColumnHidden( i ) );
 }
 
 /* Search in the playlist */
@@ -287,7 +283,6 @@ void StandardPLPanel::search( const QString& searchText )
 
 void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
 {
-    if( !index.isValid() ) return;
     QItemSelectionModel *selection = view->selectionModel();
     QModelIndexList list = selection->selectedIndexes();
     model->popup( index, point, list );
@@ -295,16 +290,42 @@ void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
 
 /* Set the root of the new Playlist */
 /* This activated by the selector selection */
-void StandardPLPanel::setRoot( int i_root_id )
+void StandardPLPanel::setRoot( playlist_item_t *p_item )
 {
     QPL_LOCK;
-    playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id );
-    assert( p_item );
-    p_item = playlist_GetPreferredNode( THEPL, p_item );
     assert( p_item );
+
+    playlist_item_t *p_pref_item = playlist_GetPreferredNode( THEPL, p_item );
+    if( p_pref_item ) p_item = p_pref_item;
+
+    /* needed for popupAdd() */
+    currentRootId = p_item->i_id;
+
+    /* cosmetics, ..still need playlist locking.. */
+    char *psz_title = input_item_GetName( p_item->p_input );
+    title->setText( qfu(psz_title) );
+    free( psz_title );
+
     QPL_UNLOCK;
 
+    /* do THE job */
     model->rebuild( p_item );
+
+    /* enable/disable adding */
+    if( p_item == THEPL->p_local_category ||
+        p_item == THEPL->p_local_onelevel )
+    {
+        addButton->setEnabled( true );
+        addButton->setToolTip( qtr(I_PL_ADDPL) );
+    }
+    else if( ( THEPL->p_ml_category && p_item == THEPL->p_ml_category) ||
+              ( THEPL->p_ml_onelevel && p_item == THEPL->p_ml_onelevel ) )
+    {
+        addButton->setEnabled( true );
+        addButton->setToolTip( qtr(I_PL_ADDML) );
+    }
+    else
+        addButton->setEnabled( false );
 }
 
 void StandardPLPanel::removeItem( int i_id )
@@ -339,4 +360,3 @@ StandardPLPanel::~StandardPLPanel()
     getSettings()->endGroup();
 }
 
-