]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/standardpanel.cpp
Use pl_Locked and pl_Unlocked
[vlc] / modules / gui / qt4 / components / playlist / standardpanel.cpp
index 4709378c2e054b80d66c37962e6d0b7c7535dfd9..6bea1c92d463ddce4de2d39cd19d51119b5430d5 100644 (file)
@@ -20,6 +20,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include "qt4.hpp"
 #include "dialogs_provider.hpp"
@@ -44,6 +47,8 @@
 
 #include <assert.h>
 
+#include "sorting.h"
+
 StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   intf_thread_t *_p_intf,
                                   playlist_t *p_playlist,
@@ -57,11 +62,12 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     /* Create and configure the QTreeView */
     view = new QVLCTreeView( 0 );
-    view->setModel(model);
+    view->setSortingEnabled( true );
+    view->sortByColumn( 0 , Qt::AscendingOrder );
+    view->setModel( model );
     view->setIconSize( QSize( 20, 20 ) );
     view->setAlternatingRowColors( true );
     view->setAnimated( true );
-    view->setSortingEnabled( true );
     view->setSelectionMode( QAbstractItemView::ExtendedSelection );
     view->setDragEnabled( true );
     view->setAcceptDrops( true );
@@ -134,7 +140,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     buttons->addWidget( repeatButton );
 
     /* Goto */
-    gotoPlayingButton = new QPushButton( qtr( "X" ), this );
+    gotoPlayingButton = new QPushButton( "X" , this );
+    gotoPlayingButton->setToolTip( qtr( "Show the current item" ));
     BUTTONACT( gotoPlayingButton, gotoPlayingItem() );
     buttons->addWidget( gotoPlayingButton );
 
@@ -260,24 +267,24 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
 
     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() );             \
+#define ADD_META_ACTION( meta ) {                                              \
+    QAction* option = selectColMenu.addAction( qfu( psz_column_title( meta ) ) );     \
+    option->setCheckable( true );                                              \
+    option->setChecked( model->shownFlags() & meta );                          \
+    ContextUpdateMapper->setMapping( option, 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 );
+    ADD_META_ACTION( COLUMN_NUMBER );
+    ADD_META_ACTION( COLUMN_TITLE );
+    ADD_META_ACTION( COLUMN_DURATION );
+    ADD_META_ACTION( COLUMN_ARTIST );
+    ADD_META_ACTION( COLUMN_GENRE );
+    ADD_META_ACTION( COLUMN_ALBUM );
+    ADD_META_ACTION( COLUMN_TRACK_NUMBER );
+    ADD_META_ACTION( COLUMN_DESCRIPTION );
 
 #undef ADD_META_ACTION
 
@@ -308,11 +315,14 @@ void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
 /* This activated by the selector selection */
 void StandardPLPanel::setRoot( int i_root_id )
 {
+    QPL_LOCK;
     playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id,
-                                                    VLC_TRUE );
+                                                    pl_Locked );
     assert( p_item );
     p_item = playlist_GetPreferredNode( THEPL, p_item );
     assert( p_item );
+    QPL_UNLOCK;
+
     model->rebuild( p_item );
 }
 
@@ -321,7 +331,7 @@ void StandardPLPanel::removeItem( int i_id )
     model->removeItem( i_id );
 }
 
-/* Delete and Suppr key remove the selection 
+/* Delete and Suppr key remove the selection
    FilterKey function and code function */
 void StandardPLPanel::keyPressEvent( QKeyEvent *e )
 {