]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/standardpanel.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / qt4 / components / playlist / standardpanel.cpp
index ad5dc82c386561f00673669deae7f5746a9f2db8..d80f965e61e96044725792ebccfb708dd44e4c84 100644 (file)
@@ -50,27 +50,34 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   PLPanel( _parent, _p_intf )
 {
     model = new PLModel( p_playlist, p_intf, p_root, -1, this );
+    /* Create and configure the QTreeView */
     view = new QVLCTreeView( 0 );
     view->setModel(model);
     view->setIconSize( QSize(20,20) );
     view->setAlternatingRowColors( true );
-    view->header()->resizeSection( 0, 230 );
-    view->header()->resizeSection( 1, 170 );
-    view->header()->setSortIndicatorShown( true );
-    view->header()->setClickable( true );
-
+    view->setAnimated( true );
+    view->setSortingEnabled( true );    
     view->setSelectionMode( QAbstractItemView::ExtendedSelection );
     view->setDragEnabled( true );
     view->setAcceptDrops( true );
     view->setDropIndicatorShown( true );
     view->setAutoScroll( true );
-
+    view->header()->resizeSection( 0, 230 );
+    view->header()->resizeSection( 1, 170 );
+    view->header()->setSortIndicatorShown( true );
+    view->header()->setClickable( true );
+    view->header()->setContextMenuPolicy( Qt::CustomContextMenu );
     CONNECT( view, activated( const QModelIndex& ) ,
              model,activateItem( const QModelIndex& ) );
     CONNECT( view, rightClicked( QModelIndex , QPoint ),
              this, doPopup( QModelIndex, QPoint ) );
     CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
+    CONNECT( view->header(), customContextMenuRequested( const QPoint & ),
+             this, popupSelectColumn( QPoint ) );
 
     currentRootId = -1;
     CONNECT( parent, rootChanged(int), this, setCurrentRootId( int ) );
@@ -78,25 +85,33 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     QVBoxLayout *layout = new QVBoxLayout();
     layout->setSpacing( 0 ); layout->setMargin( 0 );
 
+    /* Buttons configuration */
     QHBoxLayout *buttons = new QHBoxLayout();
-
-    addButton = new QPushButton( "+", this );
+    addButton = new QPushButton( QIcon( ":/pixmaps/vlc_playlist_add.png" ), "", this );
     addButton->setMaximumWidth( 25 );
-    BUTTONACT( addButton, add() );
+    BUTTONACT( addButton, popupAdd() );
     buttons->addWidget( addButton );
 
-    repeatButton = new QPushButton( 0 ); buttons->addWidget( repeatButton );
-    if( model->hasRepeat() ) repeatButton->setText( qtr( "R1" ) );
-    else if( model->hasLoop() ) repeatButton->setText( qtr( "RA" ) );
-    else repeatButton->setText( qtr( "NR" ) );
+    repeatButton = new QPushButton( this );
+    if( model->hasRepeat() ) repeatButton->setIcon(
+                        QIcon( ":/pixmaps/vlc_playlist_repeat_one.png" ) );
+    else if( model->hasLoop() ) repeatButton->setIcon(
+                        QIcon( ":/pixmaps/vlc_playlist_repeat_all.png" ) );
+    else repeatButton->setIcon(
+                        QIcon( ":/pixmaps/vlc_playlist_repeat_off.png" ) );
     BUTTONACT( repeatButton, toggleRepeat() );
+    buttons->addWidget( repeatButton );
 
-    randomButton = new QPushButton( 0 ); buttons->addWidget( randomButton );
-    if( model->hasRandom() ) randomButton->setText( qtr( " RND" ) );
-    else randomButton->setText( qtr( "NRND" ) );
+    randomButton = new QPushButton( this );
+    randomButton->setIcon( model->hasRandom() ?
+                            QIcon( ":/pixmaps/vlc_playlist_shuffle_on.png" ) :
+                            QIcon( ":/pixmaps/vlc_playlist_shuffle_off.png" ) );
     BUTTONACT( randomButton, toggleRandom() );
+    buttons->addWidget( randomButton );
 
-    QSpacerItem *spacer = new QSpacerItem( 10, 20 );buttons->addItem( spacer );
+    QSpacerItem *spacer = new QSpacerItem( 10, 20 );
+    buttons->addItem( spacer );
 
     QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " );
     buttons->addWidget( filter );
@@ -106,8 +121,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     QPushButton *clear = new QPushButton( qfu( "CL") );
     clear->setMaximumWidth( 30 );
-    buttons->addWidget( clear );
     BUTTONACT( clear, clearFilter() );
+    buttons->addWidget( clear );
 
     layout->addWidget( view );
     layout->addLayout( buttons );
@@ -120,17 +135,17 @@ void StandardPLPanel::toggleRepeat()
     if( model->hasRepeat() )
     {
         model->setRepeat( false ); model->setLoop( true );
-        repeatButton->setText( qtr(I_PL_LOOP) );
+        repeatButton->setIcon( QIcon( ":/pixmaps/vlc_playlist_repeat_all.png" ) );
     }
     else if( model->hasLoop() )
     {
         model->setRepeat( false ) ; model->setLoop( false );
-        repeatButton->setText( qtr(I_PL_NOREPEAT) );
+        repeatButton->setIcon( QIcon( ":/pixmaps/vlc_playlist_repeat_off.png" ) );
     }
     else
     {
         model->setRepeat( true );
-        repeatButton->setText( qtr(I_PL_REPEAT) );
+        repeatButton->setIcon( QIcon( ":/pixmaps/vlc_playlist_repeat_one.png" ) );
     }
 }
 
@@ -138,7 +153,9 @@ void StandardPLPanel::toggleRandom()
 {
     bool prev = model->hasRandom();
     model->setRandom( !prev );
-    randomButton->setText( prev ? qtr(I_PL_NORANDOM) : qtr(I_PL_RANDOM) );
+    randomButton->setIcon( prev ?
+                QIcon( ":/pixmaps/vlc_playlist_shuffle_off.png" ) :
+                QIcon( ":/pixmaps/vlc_playlist_shuffle_on.png" ) );
 }
 
 void StandardPLPanel::handleExpansion( const QModelIndex &index )
@@ -175,26 +192,55 @@ void StandardPLPanel::setCurrentRootId( int _new )
         addButton->setEnabled( false );
 }
 
-void StandardPLPanel::add()
+void StandardPLPanel::popupAdd()
 {
-    QMenu *popup = new QMenu();
+    QMenu popup;
     if( currentRootId == THEPL->p_local_category->i_id ||
         currentRootId == THEPL->p_local_onelevel->i_id )
     {
-        popup->addAction( qtr(I_PL_ADDF), THEDP, SLOT(simplePLAppendDialog()));
-        popup->addAction( qtr(I_PL_ADVADD), THEDP, SLOT(PLAppendDialog()) );
-        popup->addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) );
+        popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT(simplePLAppendDialog()));
+        popup.addAction( qtr(I_PL_ADVADD), THEDP, SLOT(PLAppendDialog()) );
+        popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) );
     }
     else if( currentRootId == THEPL->p_ml_category->i_id ||
              currentRootId == THEPL->p_ml_onelevel->i_id )
     {
-        popup->addAction( qtr(I_PL_ADDF), THEDP, SLOT(simpleMLAppendDialog()));
-        popup->addAction( qtr(I_PL_ADVADD), THEDP, SLOT( MLAppendDialog() ) );
-        popup->addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
+        popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT(simpleMLAppendDialog()));
+        popup.addAction( qtr(I_PL_ADVADD), THEDP, SLOT( MLAppendDialog() ) );
+        popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
     }
-    popup->popup( QCursor::pos() );
+    popup.exec( QCursor::pos() );
 }
 
+void StandardPLPanel::popupSelectColumn( QPoint )
+{
+    ContextUpdateMapper = new QSignalMapper(this);
+
+    QMenu selectColMenu;
+
+#define ADD_META_ACTION( meta ) { \
+   QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) );     \
+   option->setCheckable( true );                                           \
+   option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta );   \
+   ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta );      \
+   CONNECT( option, triggered(), ContextUpdateMapper, map() );             \
+   }
+    CONNECT( ContextUpdateMapper, mapped( int ),  model, viewchanged( int ) );
+
+    ADD_META_ACTION( TITLE );
+    ADD_META_ACTION( ARTIST );
+    ADD_META_ACTION( DURATION );
+    ADD_META_ACTION( COLLECTION );
+    ADD_META_ACTION( GENRE );
+    ADD_META_ACTION( SEQ_NUM );
+    ADD_META_ACTION( RATING );
+    ADD_META_ACTION( DESCRIPTION );
+
+#undef ADD_META_ACTION
+    selectColMenu.exec( QCursor::pos() );
+ }
+
 void StandardPLPanel::clearFilter()
 {
     searchLine->setText( "" );