playlist_item_t *p_root ):
PLPanel( _parent, _p_intf )
{
- model = new PLModel( p_playlist, p_intf, p_root, -1, this );
+ model = new PLModel( p_playlist, p_intf, p_root, this );
QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 );
view->setAcceptDrops( true );
view->setDropIndicatorShown( true );
view->header()->setSortIndicator( -1 , Qt::AscendingOrder );
+ view->setUniformRowHeights( true );
view->setSortingEnabled( true );
}
else
{
- /* Configure the size of the header */
- view->header()->resizeSection( 0, 200 );
- view->header()->resizeSection( 1, 80 );
+ int m, c;
+ for( m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
+ {
+ view->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
+ if( m == COLUMN_TITLE ) view->header()->resizeSection( c, 200 );
+ else if( m == COLUMN_DURATION ) view->header()->resizeSection( c, 80 );
+ }
}
view->header()->setSortIndicatorShown( true );
view->header()->setClickable( true );
this, handleExpansion( const QModelIndex& ) );
currentRootId = -1;
- CONNECT( parent, rootChanged( int ), this, setCurrentRootId( int ) );
/* Buttons configuration */
QHBoxLayout *buttons = new QHBoxLayout;
filter->setBuddy( search );
CONNECT( search, textChanged( const QString& ), this, search( const QString& ) );
+ /* Title label */
+ title = new QLabel;
+ QFont titleFont;
+ titleFont.setPointSize( titleFont.pointSize() + 6 );
+ titleFont.setFamily( "Verdana" );
+ title->setFont( titleFont );
+
/* Finish the layout */
+ layout->addWidget( title );
layout->addWidget( view );
layout->addLayout( buttons );
// layout->addWidget( bar );
setLayout( layout );
+
+ selectColumnsSigMapper = new QSignalMapper( this );
+ CONNECT( selectColumnsSigMapper, mapped( int ), this, toggleColumnShown( int ) );
}
/* Function to toggle between the Repeat states */
void StandardPLPanel::gotoPlayingItem()
{
- view->scrollTo( view->currentIndex() );
+ view->scrollTo( model->currentIndex() );
}
void StandardPLPanel::handleExpansion( const QModelIndex& index )
{
- view->scrollTo( index, QAbstractItemView::EnsureVisible );
-}
-
-void StandardPLPanel::setCurrentRootId( int _new )
-{
- currentRootId = _new;
- if( currentRootId == THEPL->p_local_category->i_id ||
- currentRootId == THEPL->p_local_onelevel->i_id )
- {
- addButton->setEnabled( true );
- addButton->setToolTip( qtr(I_PL_ADDPL) );
- }
- else if( ( THEPL->p_ml_category &&
- currentRootId == THEPL->p_ml_category->i_id ) ||
- ( THEPL->p_ml_onelevel &&
- currentRootId == THEPL->p_ml_onelevel->i_id ) )
- {
- addButton->setEnabled( true );
- addButton->setToolTip( qtr(I_PL_ADDML) );
- }
- else
- addButton->setEnabled( false );
+ view->scrollTo( index );
}
/* PopupAdd Menu for the Add Menu */
void StandardPLPanel::popupSelectColumn( QPoint pos )
{
- ContextUpdateMapper = new QSignalMapper(this);
-
- QMenu selectColMenu;
-
- CONNECT( ContextUpdateMapper, mapped( int ), model, viewchanged( int ) );
+ QMenu menu;
- int i_column = 1;
- for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
+ /* We do not offer the option to hide index 0 column, or
+ * QTreeView will behave weird */
+ int i, j;
+ for( i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
{
- QAction* option = selectColMenu.addAction(
- qfu( psz_column_title( i_column ) ) );
+ QAction* option = menu.addAction(
+ qfu( psz_column_title( i ) ) );
option->setCheckable( true );
- option->setChecked( model->shownFlags() & i_column );
- ContextUpdateMapper->setMapping( option, i_column );
- CONNECT( option, triggered(), ContextUpdateMapper, map() );
+ option->setChecked( !view->isColumnHidden( j ) );
+ selectColumnsSigMapper->setMapping( option, j );
+ CONNECT( option, triggered(), selectColumnsSigMapper, map() );
}
+ menu.exec( QCursor::pos() );
+}
- selectColMenu.exec( QCursor::pos() );
+void StandardPLPanel::toggleColumnShown( int i )
+{
+ view->setColumnHidden( i, !view->isColumnHidden( i ) );
}
/* Search in the playlist */
void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
{
- if( !index.isValid() ) return;
QItemSelectionModel *selection = view->selectionModel();
QModelIndexList list = selection->selectedIndexes();
model->popup( index, point, list );
/* Set the root of the new Playlist */
/* This activated by the selector selection */
-void StandardPLPanel::setRoot( int i_root_id )
+void StandardPLPanel::setRoot( playlist_item_t *p_item )
{
QPL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id );
- assert( p_item );
- p_item = playlist_GetPreferredNode( THEPL, p_item );
assert( p_item );
+
+ playlist_item_t *p_pref_item = playlist_GetPreferredNode( THEPL, p_item );
+ if( p_pref_item ) p_item = p_pref_item;
+
+ /* needed for popupAdd() */
+ currentRootId = p_item->i_id;
+
+ /* cosmetics, ..still need playlist locking.. */
+ char *psz_title = input_item_GetName( p_item->p_input );
+ title->setText( qfu(psz_title) );
+ free( psz_title );
+
QPL_UNLOCK;
+ /* do THE job */
model->rebuild( p_item );
+
+ /* enable/disable adding */
+ if( p_item == THEPL->p_local_category ||
+ p_item == THEPL->p_local_onelevel )
+ {
+ addButton->setEnabled( true );
+ addButton->setToolTip( qtr(I_PL_ADDPL) );
+ }
+ else if( ( THEPL->p_ml_category && p_item == THEPL->p_ml_category) ||
+ ( THEPL->p_ml_onelevel && p_item == THEPL->p_ml_onelevel ) )
+ {
+ addButton->setEnabled( true );
+ addButton->setToolTip( qtr(I_PL_ADDML) );
+ }
+ else
+ addButton->setEnabled( false );
}
void StandardPLPanel::removeItem( int i_id )
getSettings()->endGroup();
}
-