+ currentRootId = -1;
+ currentRootIndexId = -1;
+ lastActivatedId = -1;
+
+ locationBar = new LocationBar( model );
+ locationBar->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
+ layout->addWidget( locationBar, 0, 0 );
+ layout->setColumnStretch( 0, 5 );
+ CONNECT( locationBar, invoked( const QModelIndex & ),
+ this, browseInto( const QModelIndex & ) );
+
+ searchEdit = new SearchLineEdit( this );
+ searchEdit->setMaximumWidth( 250 );
+ searchEdit->setMinimumWidth( 80 );
+ layout->addWidget( searchEdit, 0, 2 );
+ CONNECT( searchEdit, textChanged( const QString& ),
+ this, search( const QString& ) );
+ layout->setColumnStretch( 2, 3 );
+
+ /* Button to switch views */
+ QToolButton *viewButton = new QToolButton( this );
+ viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
+ viewButton->setToolTip( qtr("Change playlistview"));
+ layout->addWidget( viewButton, 0, 1 );
+
+ /* View selection menu */
+ viewSelectionMapper = new QSignalMapper( this );
+ CONNECT( viewSelectionMapper, mapped( int ), this, showView( int ) );
+
+ QActionGroup *actionGroup = new QActionGroup( this );
+
+ for( int i = 0; i < VIEW_COUNT; i++ )
+ {
+ viewActions[i] = actionGroup->addAction( viewNames[i] );
+ viewActions[i]->setCheckable( true );
+ viewSelectionMapper->setMapping( viewActions[i], i );
+ CONNECT( viewActions[i], triggered(), viewSelectionMapper, map() );
+ }
+
+ BUTTONACT( viewButton, cycleViews() );
+ QMenu *viewMenu = new QMenu( this );
+ viewMenu->addActions( actionGroup->actions() );
+
+ viewButton->setMenu( viewMenu );
+
+ /* Saved Settings */
+ getSettings()->beginGroup("Playlist");
+
+ int i_viewMode = getSettings()->value( "view-mode", TREE_VIEW ).toInt();
+
+ getSettings()->endGroup();
+
+ showView( i_viewMode );
+
+ DCONNECT( THEMIM, leafBecameParent( input_item_t *),
+ this, browseInto( input_item_t * ) );
+
+ CONNECT( model, currentChanged( const QModelIndex& ),
+ this, handleExpansion( const QModelIndex& ) );
+ CONNECT( model, rootChanged(), this, handleRootChange() );
+}
+
+StandardPLPanel::~StandardPLPanel()
+{
+ getSettings()->beginGroup("Playlist");
+ if( treeView )
+ getSettings()->setValue( "headerStateV2", treeView->header()->saveState() );
+ if( currentView == treeView )
+ getSettings()->setValue( "view-mode", TREE_VIEW );
+ else if( currentView == listView )
+ getSettings()->setValue( "view-mode", LIST_VIEW );
+ else if( currentView == iconView )
+ getSettings()->setValue( "view-mode", ICON_VIEW );
+ getSettings()->endGroup();
+}
+
+/* Unused anymore, but might be useful, like in right-click menu */
+void StandardPLPanel::gotoPlayingItem()
+{
+ currentView->scrollTo( model->currentIndex() );
+}
+
+void StandardPLPanel::handleExpansion( const QModelIndex& index )
+{
+ assert( currentView );
+ browseInto( index.parent() );
+ currentView->scrollTo( index );
+}
+
+void StandardPLPanel::handleRootChange()
+{
+ browseInto();
+}
+
+void StandardPLPanel::popupPlView( const QPoint &point )
+{
+ QModelIndex index = currentView->indexAt( point );
+ QPoint globalPoint = currentView->viewport()->mapToGlobal( point );
+ QItemSelectionModel *selection = currentView->selectionModel();
+ QModelIndexList list = selection->selectedIndexes();
+
+ if( !model->popup( index, globalPoint, list ) )
+ QVLCMenu::PopupMenu( p_intf, true );
+}
+
+void StandardPLPanel::popupSelectColumn( QPoint pos )
+{
+ QMenu menu;
+ assert( treeView );
+
+ /* 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 = menu.addAction(
+ qfu( psz_column_title( i ) ) );
+ option->setCheckable( true );
+ option->setChecked( !treeView->isColumnHidden( j ) );
+ selectColumnsSigMapper->setMapping( option, j );
+ CONNECT( option, triggered(), selectColumnsSigMapper, map() );
+ }
+ menu.exec( QCursor::pos() );
+}
+
+void StandardPLPanel::toggleColumnShown( int i )
+{
+ treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
+}
+
+/* Search in the playlist */
+void StandardPLPanel::search( const QString& searchText )
+{
+ bool flat = currentView == iconView || currentView == listView;
+ model->search( searchText,
+ flat ? currentView->rootIndex() : QModelIndex(),
+ !flat );
+}