Commit 157f43b7 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: playlist code cosmetics

parent 99b1edc0
...@@ -55,27 +55,32 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -55,27 +55,32 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
playlist_item_t *p_root ): playlist_item_t *p_root ):
QWidget( _parent ), p_intf( _p_intf ) QWidget( _parent ), p_intf( _p_intf )
{ {
model = new PLModel( p_playlist, p_intf, p_root, this ); QVBoxLayout *layout = new QVBoxLayout( this );
QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->setMargin( 0 );
model = new PLModel( p_playlist, p_intf, p_root, this );
/* Create and configure the QTreeView */ /* Create and configure the QTreeView */
view = new QVLCTreeView; view = new QVLCTreeView;
view->setModel( model ); view->setModel( model );
view->setIconSize( QSize( 20, 20 ) ); view->setIconSize( QSize( 20, 20 ) );
view->setAlternatingRowColors( true ); view->setAlternatingRowColors( true );
view->setAnimated( true ); view->setAnimated( true );
view->setUniformRowHeights( true );
view->setSortingEnabled( true );
view->header()->setSortIndicator( -1 , Qt::AscendingOrder );
view->header()->setSortIndicatorShown( true );
view->header()->setClickable( true );
view->header()->setContextMenuPolicy( Qt::CustomContextMenu );
view->setSelectionBehavior( QAbstractItemView::SelectRows ); view->setSelectionBehavior( QAbstractItemView::SelectRows );
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->header()->setSortIndicator( -1 , Qt::AscendingOrder );
view->setUniformRowHeights( true );
view->setSortingEnabled( true );
/* Saved Settings */
getSettings()->beginGroup("Playlist"); getSettings()->beginGroup("Playlist");
if( getSettings()->contains( "headerStateV2" ) ) if( getSettings()->contains( "headerStateV2" ) )
{ {
...@@ -84,17 +89,13 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -84,17 +89,13 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
} }
else else
{ {
int m, c; for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
for( m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
{ {
view->setColumnHidden( c, !( m & COLUMN_DEFAULT ) ); view->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
if( m == COLUMN_TITLE ) view->header()->resizeSection( c, 200 ); if( m == COLUMN_TITLE ) view->header()->resizeSection( c, 200 );
else if( m == COLUMN_DURATION ) view->header()->resizeSection( c, 80 ); else if( m == COLUMN_DURATION ) view->header()->resizeSection( c, 80 );
} }
} }
view->header()->setSortIndicatorShown( true );
view->header()->setClickable( true );
view->header()->setContextMenuPolicy( Qt::CustomContextMenu );
getSettings()->endGroup(); getSettings()->endGroup();
/* Connections for the TreeView */ /* Connections for the TreeView */
...@@ -149,12 +150,18 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -149,12 +150,18 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
layout->addWidget( view ); layout->addWidget( view );
layout->addLayout( buttons ); layout->addLayout( buttons );
// layout->addWidget( bar ); // layout->addWidget( bar );
setLayout( layout );
selectColumnsSigMapper = new QSignalMapper( this ); selectColumnsSigMapper = new QSignalMapper( this );
CONNECT( selectColumnsSigMapper, mapped( int ), this, toggleColumnShown( int ) ); CONNECT( selectColumnsSigMapper, mapped( int ), this, toggleColumnShown( int ) );
} }
StandardPLPanel::~StandardPLPanel()
{
getSettings()->beginGroup("Playlist");
getSettings()->setValue( "headerStateV2", view->header()->saveState() );
getSettings()->endGroup();
}
void StandardPLPanel::gotoPlayingItem() void StandardPLPanel::gotoPlayingItem()
{ {
view->scrollTo( model->currentIndex() ); view->scrollTo( model->currentIndex() );
...@@ -292,10 +299,3 @@ void StandardPLPanel::deleteSelection() ...@@ -292,10 +299,3 @@ void StandardPLPanel::deleteSelection()
model->doDelete( list ); model->doDelete( list );
} }
StandardPLPanel::~StandardPLPanel()
{
getSettings()->beginGroup("Playlist");
getSettings()->setValue( "headerStateV2", view->header()->saveState() );
getSettings()->endGroup();
}
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