Commit bb22f297 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Right click on the header on the QTreeView for the playlist enables you...

Qt4 - Right click on the header on the QTreeView for the playlist enables you to choose the columns you want to be shown. This removes also the code that was in the Model part since this is View Related. Ref #1282 (almost done).
There is still segfaults on close of VLC after that menu is triggered.

parent c0777c31
...@@ -75,6 +75,7 @@ private: ...@@ -75,6 +75,7 @@ private:
QPushButton *repeatButton , *randomButton,*addButton; QPushButton *repeatButton , *randomButton,*addButton;
ClickLineEdit *searchLine; ClickLineEdit *searchLine;
int currentRootId; int currentRootId;
QSignalMapper *ContextUpdateMapper;
public slots: public slots:
void removeItem( int ); void removeItem( int );
virtual void setRoot( int ); virtual void setRoot( int );
...@@ -88,6 +89,7 @@ private slots: ...@@ -88,6 +89,7 @@ private slots:
void clearFilter(); void clearFilter();
void add(); void add();
void setCurrentRootId( int ); void setCurrentRootId( int );
void popupSelectColumn( QPoint );
}; };
#endif #endif
...@@ -50,27 +50,34 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -50,27 +50,34 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
PLPanel( _parent, _p_intf ) PLPanel( _parent, _p_intf )
{ {
model = new PLModel( p_playlist, p_intf, p_root, -1, this ); model = new PLModel( p_playlist, p_intf, p_root, -1, this );
/* Create and configure the QTreeView */
view = new QVLCTreeView( 0 ); view = new QVLCTreeView( 0 );
view->setModel(model); view->setModel(model);
view->setIconSize( QSize(20,20) ); view->setIconSize( QSize(20,20) );
view->setAlternatingRowColors( true ); view->setAlternatingRowColors( true );
view->header()->resizeSection( 0, 230 ); view->setAnimated( true );
view->header()->resizeSection( 1, 170 ); view->setSortingEnabled( true );
view->header()->setSortIndicatorShown( true );
view->header()->setClickable( true );
view->setSelectionMode( QAbstractItemView::ExtendedSelection ); view->setSelectionMode( QAbstractItemView::ExtendedSelection );
view->setDragEnabled( true ); view->setDragEnabled( true );
view->setAcceptDrops( true ); view->setAcceptDrops( true );
view->setDropIndicatorShown( true ); view->setDropIndicatorShown( true );
view->setAutoScroll( 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& ) , CONNECT( view, activated( const QModelIndex& ) ,
model,activateItem( const QModelIndex& ) ); model,activateItem( const QModelIndex& ) );
CONNECT( view, rightClicked( QModelIndex , QPoint ), CONNECT( view, rightClicked( QModelIndex , QPoint ),
this, doPopup( QModelIndex, QPoint ) ); this, doPopup( QModelIndex, QPoint ) );
CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ), CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
CONNECT( view->header(), customContextMenuRequested( const QPoint & ),
this, popupSelectColumn( QPoint ) );
currentRootId = -1; currentRootId = -1;
CONNECT( parent, rootChanged(int), this, setCurrentRootId( int ) ); CONNECT( parent, rootChanged(int), this, setCurrentRootId( int ) );
...@@ -78,25 +85,29 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -78,25 +85,29 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->setMargin( 0 );
/* Buttons configuration */
QHBoxLayout *buttons = new QHBoxLayout(); QHBoxLayout *buttons = new QHBoxLayout();
addButton = new QPushButton( "+", this ); addButton = new QPushButton( "+", this );
addButton->setMaximumWidth( 25 ); addButton->setMaximumWidth( 25 );
BUTTONACT( addButton, add() ); BUTTONACT( addButton, add() );
buttons->addWidget( addButton ); buttons->addWidget( addButton );
repeatButton = new QPushButton( 0 ); buttons->addWidget( repeatButton ); repeatButton = new QPushButton( this );
if( model->hasRepeat() ) repeatButton->setText( qtr( I_PL_REPEAT ) ); if( model->hasRepeat() ) repeatButton->setText( qtr( I_PL_REPEAT ) );
else if( model->hasLoop() ) repeatButton->setText( qtr( I_PL_LOOP ) ); else if( model->hasLoop() ) repeatButton->setText( qtr( I_PL_LOOP ) );
else repeatButton->setText( qtr( I_PL_NOREPEAT ) ); else repeatButton->setText( qtr( I_PL_NOREPEAT ) );
BUTTONACT( repeatButton, toggleRepeat() ); 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 ) randomButton->setText( model->hasRandom() ? qtr( I_PL_RANDOM )
: qtr( I_PL_NORANDOM) ); : qtr( I_PL_NORANDOM) );
BUTTONACT( randomButton, toggleRandom() ); 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) + " " ); QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " );
buttons->addWidget( filter ); buttons->addWidget( filter );
...@@ -106,8 +117,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -106,8 +117,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
QPushButton *clear = new QPushButton( qfu( "CL") ); QPushButton *clear = new QPushButton( qfu( "CL") );
clear->setMaximumWidth( 30 ); clear->setMaximumWidth( 30 );
buttons->addWidget( clear );
BUTTONACT( clear, clearFilter() ); BUTTONACT( clear, clearFilter() );
buttons->addWidget( clear );
layout->addWidget( view ); layout->addWidget( view );
layout->addLayout( buttons ); layout->addLayout( buttons );
...@@ -195,6 +206,35 @@ void StandardPLPanel::add() ...@@ -195,6 +206,35 @@ void StandardPLPanel::add()
popup->popup( QCursor::pos() ); 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() void StandardPLPanel::clearFilter()
{ {
searchLine->setText( "" ); searchLine->setText( "" );
......
...@@ -72,7 +72,6 @@ void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m) ...@@ -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; i_id = _i_id; i_input_id = _i_input_id;
model = m; model = m;
if( parentItem == NULL ) if( parentItem == NULL )
{ {
i_showflags = config_GetInt( model->p_intf , "qt-pl-showflags" ); 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, ...@@ -289,7 +288,6 @@ PLModel::PLModel( playlist_t *_p_playlist, intf_thread_t *_p_intf,
rebuild( p_root ); rebuild( p_root );
} }
PLModel::~PLModel() PLModel::~PLModel()
{ {
delCallbacks(); delCallbacks();
...@@ -971,9 +969,9 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) ...@@ -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_SORT), this, SLOT( popupSort() ) );
menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) ); 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") ); QMenu *selectColMenu = new QMenu( qtr("Show columns") );
...@@ -996,7 +994,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) ...@@ -996,7 +994,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
ADD_META_ACTION( DESCRIPTION ); ADD_META_ACTION( DESCRIPTION );
#undef ADD_META_ACTION #undef ADD_META_ACTION
menu->addMenu( selectColMenu ); menu->addMenu( selectColMenu );*/
menu->popup( point ); menu->popup( point );
} }
else else
......
...@@ -66,6 +66,7 @@ protected: ...@@ -66,6 +66,7 @@ protected:
int i_id; int i_id;
int i_input_id; int i_input_id;
int i_showflags; int i_showflags;
void updateview( void ); void updateview( void );
friend class PLModel; friend class PLModel;
private: private:
...@@ -120,6 +121,7 @@ public: ...@@ -120,6 +121,7 @@ public:
bool b_need_update; bool b_need_update;
int i_items_to_append; int i_items_to_append;
void rebuild(); void rebuild( playlist_item_t *); void rebuild(); void rebuild( playlist_item_t *);
bool hasRandom(); bool hasLoop(); bool hasRepeat(); bool hasRandom(); bool hasLoop(); bool hasRepeat();
...@@ -139,6 +141,11 @@ public: ...@@ -139,6 +141,11 @@ public:
void sendArt( QString url ); void sendArt( QString url );
void removeArt( ); void removeArt( );
int shownFlags()
{
return rootItem->i_showflags;
}
private: private:
void addCallbacks(); void addCallbacks();
void delCallbacks(); void delCallbacks();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment