diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp index a3410bcfa0bb91772e6a958c8cadf83a533c1de3..92213b0e185cff99aefdddeb0e361d02ad25039c 100644 --- a/modules/gui/qt4/components/playlist/panels.hpp +++ b/modules/gui/qt4/components/playlist/panels.hpp @@ -75,6 +75,7 @@ private: QPushButton *repeatButton , *randomButton,*addButton; ClickLineEdit *searchLine; int currentRootId; +QSignalMapper *ContextUpdateMapper; public slots: void removeItem( int ); virtual void setRoot( int ); @@ -88,6 +89,7 @@ private slots: void clearFilter(); void add(); void setCurrentRootId( int ); + void popupSelectColumn( QPoint ); }; #endif diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index bba41f86971a7d7c29e314bcc85ab97f7b7db710..a9f7aa092cde0b3c209a6ea163df6db1669a0c4a 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -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,29 @@ 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->setMaximumWidth( 25 ); BUTTONACT( addButton, add() ); buttons->addWidget( addButton ); - repeatButton = new QPushButton( 0 ); buttons->addWidget( repeatButton ); + repeatButton = new QPushButton( this ); if( model->hasRepeat() ) repeatButton->setText( qtr( I_PL_REPEAT ) ); else if( model->hasLoop() ) repeatButton->setText( qtr( I_PL_LOOP ) ); else repeatButton->setText( qtr( I_PL_NOREPEAT ) ); BUTTONACT( repeatButton, toggleRepeat() ); + buttons->addWidget( repeatButton ); - randomButton = new QPushButton( 0 ); buttons->addWidget( randomButton ); + randomButton = new QPushButton( this ); randomButton->setText( model->hasRandom() ? qtr( I_PL_RANDOM ) : qtr( I_PL_NORANDOM) ); 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 +117,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 ); @@ -195,6 +206,35 @@ void StandardPLPanel::add() popup->popup( QCursor::pos() ); } +void StandardPLPanel::popupSelectColumn( QPoint ) +{ + ContextUpdateMapper = new QSignalMapper(this); + + QMenu *selectColMenu = new QMenu( qtr("Show columns") ); + +#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->popup( QCursor::pos() ); + } + void StandardPLPanel::clearFilter() { searchLine->setText( "" ); diff --git a/modules/gui/qt4/playlist_model.cpp b/modules/gui/qt4/playlist_model.cpp index 16d53cb3a4af7ba69456e35d62a5b8521fe510e3..0bbe46ff15cc8aa578d13a12b5c7a6158da2e52f 100644 --- a/modules/gui/qt4/playlist_model.cpp +++ b/modules/gui/qt4/playlist_model.cpp @@ -72,7 +72,6 @@ void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m) i_id = _i_id; i_input_id = _i_input_id; model = m; - if( parentItem == NULL ) { i_showflags = config_GetInt( model->p_intf , "qt-pl-showflags" ); @@ -289,7 +288,6 @@ PLModel::PLModel( playlist_t *_p_playlist, intf_thread_t *_p_intf, rebuild( p_root ); } - PLModel::~PLModel() { delCallbacks(); @@ -971,9 +969,9 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) ); menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) ); } - menu->addSeparator(); + // menu->addSeparator(); - ContextUpdateMapper = new QSignalMapper(this); + /*ContextUpdateMapper = new QSignalMapper(this); QMenu *selectColMenu = new QMenu( qtr("Show columns") ); @@ -996,7 +994,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) ADD_META_ACTION( DESCRIPTION ); #undef ADD_META_ACTION - menu->addMenu( selectColMenu ); + menu->addMenu( selectColMenu );*/ menu->popup( point ); } else diff --git a/modules/gui/qt4/playlist_model.hpp b/modules/gui/qt4/playlist_model.hpp index d8a87ea9f7bd6b9e42671c9f9e9642cd3d500b83..981acf2f33d1bf993b5d7b353e5505607cec2a36 100644 --- a/modules/gui/qt4/playlist_model.hpp +++ b/modules/gui/qt4/playlist_model.hpp @@ -66,6 +66,7 @@ protected: int i_id; int i_input_id; int i_showflags; + void updateview( void ); friend class PLModel; private: @@ -120,6 +121,7 @@ public: bool b_need_update; int i_items_to_append; + void rebuild(); void rebuild( playlist_item_t *); bool hasRandom(); bool hasLoop(); bool hasRepeat(); @@ -139,6 +141,11 @@ public: void sendArt( QString url ); void removeArt( ); + + int shownFlags() + { + return rootItem->i_showflags; + } private: void addCallbacks(); void delCallbacks();