X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fplaylist%2Fstandardpanel.cpp;h=4ac1da2240845f635b0430e7267306f4ec1a71ac;hb=5a38d2b20e1c04853679206bf2e7ec839d450563;hp=51cb0f9f15b7c95170e0359901de402cc51f12b6;hpb=454405607f658dd92b9454803b88308afddd7da3;p=vlc diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 51cb0f9f15..4ac1da2240 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -61,8 +61,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, /* Create and configure the QTreeView */ view = new QVLCTreeView; - view->header()->setSortIndicator( 0 , Qt::AscendingOrder ); - view->setSortingEnabled( true ); view->setModel( model ); view->setIconSize( QSize( 20, 20 ) ); view->setAlternatingRowColors( true ); @@ -72,6 +70,9 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, view->setDragEnabled( true ); view->setAcceptDrops( true ); view->setDropIndicatorShown( true ); + view->header()->setSortIndicator( -1 , Qt::AscendingOrder ); + view->setUniformRowHeights( true ); + view->setSortingEnabled( true ); getSettings()->beginGroup("Playlist"); @@ -100,6 +101,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, this, popupSelectColumn( QPoint ) ); CONNECT( model, currentChanged( const QModelIndex& ), this, handleExpansion( const QModelIndex& ) ); + CONNECT( model, columnsChanged( int ), + this, checkSortingIndicator( int ) ); currentRootId = -1; CONNECT( parent, rootChanged( int ), this, setCurrentRootId( int ) ); @@ -208,7 +211,7 @@ void StandardPLPanel::gotoPlayingItem() void StandardPLPanel::handleExpansion( const QModelIndex& index ) { - view->scrollTo( index, QAbstractItemView::EnsureVisible ); + view->scrollTo( index ); } void StandardPLPanel::setCurrentRootId( int _new ) @@ -257,14 +260,58 @@ void StandardPLPanel::popupAdd() + QPoint( 0, addButton->height() ) ); } +/* Set sortingindicator to -1 if it's on column thats removed, + * else check that it's still showing on correct column + */ +void StandardPLPanel::checkSortingIndicator( int meta ) +{ + int index=0; + + if( view->header()->isSortIndicatorShown() == false ) + return; + + int sortIndex = view->header()->sortIndicatorSection(); + if( sortIndex < 0 || sortIndex > view->header()->count() || meta == 0 ) + return; + + int _meta = meta; + + while( _meta ) + { + if( _meta & model->shownFlags() ) + index++; + _meta >>= 1; + } + + /* Adding column */ + if( model->shownFlags() & meta ) + { + /* If column is added before sortIndex, move it one to right*/ + if( sortIndex >= index ) + { + sortIndex += 1; + } + } else { + /* Column removed */ + if( sortIndex == index ) + { + sortIndex = -1; + } else if( sortIndex > index ) + { + /* Move indicator left one step*/ + sortIndex -= 1; + } + } + view->header()->setSortIndicator( sortIndex , + view->header()->sortIndicatorOrder() ); +} + void StandardPLPanel::popupSelectColumn( QPoint pos ) { ContextUpdateMapper = new QSignalMapper(this); QMenu selectColMenu; - CONNECT( ContextUpdateMapper, mapped( int ), model, viewchanged( int ) ); - int i_column = 1; for( i_column = 1; i_column != COLUMN_END; i_column<<=1 ) { @@ -276,6 +323,8 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) CONNECT( option, triggered(), ContextUpdateMapper, map() ); } + CONNECT( ContextUpdateMapper, mapped( int ), model, viewchanged( int ) ); + selectColMenu.exec( QCursor::pos() ); }