X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fplaylist%2Fstandardpanel.cpp;h=4ac1da2240845f635b0430e7267306f4ec1a71ac;hb=5a38d2b20e1c04853679206bf2e7ec839d450563;hp=4ecc873918e405b70300ebf7d1775c97f68ab378;hpb=862258e86722f54e5e9fc417fc8fcd21bfdcc518;p=vlc diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 4ecc873918..4ac1da2240 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -34,14 +34,12 @@ #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -63,17 +61,18 @@ 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 ); view->setAnimated( true ); + view->setSelectionBehavior( QAbstractItemView::SelectRows ); view->setSelectionMode( QAbstractItemView::ExtendedSelection ); view->setDragEnabled( true ); view->setAcceptDrops( true ); view->setDropIndicatorShown( true ); - view->setAutoScroll( true ); + view->header()->setSortIndicator( -1 , Qt::AscendingOrder ); + view->setUniformRowHeights( true ); + view->setSortingEnabled( true ); getSettings()->beginGroup("Playlist"); @@ -98,10 +97,12 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, 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 ) ); + 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 ) ); @@ -111,14 +112,14 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, /* Add item to the playlist button */ addButton = new QPushButton; - addButton->setIcon( QIcon( ":/playlist_add" ) ); + addButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) ); addButton->setMaximumWidth( 30 ); BUTTONACT( addButton, popupAdd() ); buttons->addWidget( addButton ); /* Random 2-state button */ randomButton = new QPushButton( this ); - randomButton->setIcon( QIcon( ":/shuffle_on" )); + randomButton->setIcon( QIcon( ":/buttons/playlist/shuffle_on" )); randomButton->setToolTip( qtr( I_PL_RANDOM )); randomButton->setCheckable( true ); randomButton->setChecked( model->hasRandom() ); @@ -132,17 +133,17 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, if( model->hasRepeat() ) { - repeatButton->setIcon( QIcon( ":/repeat_one" ) ); + repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_one" ) ); repeatButton->setChecked( true ); } else if( model->hasLoop() ) { - repeatButton->setIcon( QIcon( ":/repeat_all" ) ); + repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) ); repeatButton->setChecked( true ); } else { - repeatButton->setIcon( QIcon( ":/repeat_one" ) ); + repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_one" ) ); repeatButton->setChecked( false ); } BUTTONACT( repeatButton, toggleRepeat() ); @@ -150,7 +151,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, /* Goto */ gotoPlayingButton = new QPushButton; - BUTTON_SET_ACT_I( gotoPlayingButton, "", jump_to, + BUTTON_SET_ACT_I( gotoPlayingButton, "", buttons/playlist/jump_to, qtr( "Show the current item" ), gotoPlayingItem() ); buttons->addWidget( gotoPlayingButton ); @@ -164,7 +165,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, SearchLineEdit *search = new SearchLineEdit( this ); buttons->addWidget( search ); filter->setBuddy( search ); - CONNECT( search, textChanged( QString ), this, search( QString ) ); + CONNECT( search, textChanged( const QString& ), this, search( const QString& ) ); /* Finish the layout */ layout->addWidget( view ); @@ -179,20 +180,20 @@ void StandardPLPanel::toggleRepeat() if( model->hasRepeat() ) { model->setRepeat( false ); model->setLoop( true ); - repeatButton->setIcon( QIcon( ":/repeat_all" ) ); + repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) ); repeatButton->setChecked( true ); } else if( model->hasLoop() ) { model->setRepeat( false ) ; model->setLoop( false ); repeatButton->setChecked( false ); - repeatButton->setIcon( QIcon( ":/repeat_one" ) ); + repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_one" ) ); } else { model->setRepeat( true ); model->setLoop( false ); repeatButton->setChecked( true ); - repeatButton->setIcon( QIcon( ":/repeat_one" ) ); + repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_one" ) ); } } @@ -208,10 +209,9 @@ void StandardPLPanel::gotoPlayingItem() view->scrollTo( view->currentIndex() ); } -void StandardPLPanel::handleExpansion( const QModelIndex &index ) +void StandardPLPanel::handleExpansion( const QModelIndex& index ) { - if( model->isCurrent( index ) ) - view->scrollTo( index, QAbstractItemView::EnsureVisible ); + view->scrollTo( index ); } void StandardPLPanel::setCurrentRootId( int _new ) @@ -242,29 +242,76 @@ void StandardPLPanel::popupAdd() if( currentRootId == THEPL->p_local_category->i_id || currentRootId == THEPL->p_local_onelevel->i_id ) { - popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT(PLAppendDialog()) ); + popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT( simplePLAppendDialog()) ); popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) ); + popup.addAction( qtr(I_OP_ADVOP), THEDP, SLOT( PLAppendDialog()) ); } else if( ( THEPL->p_ml_category && currentRootId == THEPL->p_ml_category->i_id ) || ( THEPL->p_ml_onelevel && currentRootId == THEPL->p_ml_onelevel->i_id ) ) { - popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT( MLAppendDialog() ) ); + popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT( simpleMLAppendDialog()) ); popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) ); + popup.addAction( qtr(I_OP_ADVOP), THEDP, SLOT( MLAppendDialog() ) ); } + popup.exec( QCursor::pos() - addButton->mapFromGlobal( QCursor::pos() ) + 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,11 +323,13 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) CONNECT( option, triggered(), ContextUpdateMapper, map() ); } + CONNECT( ContextUpdateMapper, mapped( int ), model, viewchanged( int ) ); + selectColMenu.exec( QCursor::pos() ); } /* Search in the playlist */ -void StandardPLPanel::search( QString searchText ) +void StandardPLPanel::search( const QString& searchText ) { model->search( searchText ); }