]> git.sesse.net Git - vlc/commitdiff
qt4: access visible playlist column selector menu from general playlist popup menu
authorJakob Leben <jleben@videolan.org>
Sat, 29 Aug 2009 08:28:24 +0000 (10:28 +0200)
committerJakob Leben <jleben@videolan.org>
Sat, 29 Aug 2009 08:30:32 +0000 (10:30 +0200)
This fixes the issue that it was not possible to get any column back once all had been hidden

modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp

index 52cfc76c7c9f3df6b818d84ed3d7016caf6c05ed..62704e7724e33e2637b559a89c3387c1f28677ba 100644 (file)
@@ -102,11 +102,14 @@ PLModel::PLModel( playlist_t *_p_playlist,  /* THEPL */
     ADD_ICON( NODE, ":/type/node" );
 #undef ADD_ICON
 
+    ContextUpdateMapper = new QSignalMapper(this);
+
     rebuild( p_root );
     CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
             this, processInputItemUpdate( input_item_t *) );
     CONNECT( THEMIM, inputChanged( input_thread_t * ),
             this, processInputItemUpdate( input_thread_t* ) );
+    CONNECT( ContextUpdateMapper, mapped( int ),  this, toggleColumnShown( int ) );
 }
 
 PLModel::~PLModel()
@@ -1041,9 +1044,27 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
         menu->addSeparator();
         menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
     }
+    if( tree || i_popup_item > -1 )
+        menu->addSeparator();
+    QMenu *col_selector = menu->addMenu( qtr( "Visible columns" ) );
+    makeColumnSelectMenu( col_selector );
     menu->popup( point );
 }
 
+void PLModel::makeColumnSelectMenu( QMenu *menu )
+{
+    int i_column = 1;
+    for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
+    {
+        QAction* option = menu->addAction(
+            qfu( psz_column_title( i_column ) ) );
+        option->setCheckable( true );
+        option->setChecked( shownFlags() & i_column );
+        ContextUpdateMapper->setMapping( option, i_column );
+        CONNECT( option, triggered(), ContextUpdateMapper, map() );
+    }
+}
+
 void PLModel::toggleColumnShown( int meta )
 {
     assert( meta );
index c8d5da078e42e35ea8745d597cfdabe32672c81b..a10311602b32450718dc9da9bc5d20aecd3da0e0 100644 (file)
@@ -128,6 +128,8 @@ public:
     void removeItem( int );
     void rebuild(); void rebuild( playlist_item_t * );
 
+    /* Helpers */
+    void makeColumnSelectMenu( QMenu *menu );
 private:
 
     /* General */
index 18d68863f5f16721cc05ebbbe0b69ca113d6481c..770d0c467d2b4983d76f2ba677cee753c3d7af61 100644 (file)
@@ -308,22 +308,9 @@ void StandardPLPanel::checkSortingIndicator( int meta )
 
 void StandardPLPanel::popupSelectColumn( QPoint pos )
 {
-    ContextUpdateMapper = new QSignalMapper(this);
-
     QMenu selectColMenu;
 
-    int i_column = 1;
-    for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
-    {
-        QAction* option = selectColMenu.addAction(
-            qfu( psz_column_title( i_column ) ) );
-        option->setCheckable( true );
-        option->setChecked( model->shownFlags() & i_column );
-        ContextUpdateMapper->setMapping( option, i_column );
-        CONNECT( option, triggered(), ContextUpdateMapper, map() );
-    }
-
-    CONNECT( ContextUpdateMapper, mapped( int ),  model, toggleColumnShown( int ) );
+    model->makeColumnSelectMenu( &selectColMenu );
 
     selectColMenu.exec( QCursor::pos() );
 }