+
+void StandardPLPanel::activate( const QModelIndex &index )
+{
+ if( model->hasChildren( index ) )
+ {
+ if( currentView == iconView ) {
+ iconView->setRootIndex( index );
+ //title->setText( index.data().toString() );
+ locationBar->setIndex( index );
+ }
+ }
+ else
+ {
+ playlist_Lock( THEPL );
+ playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
+ p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
+ last_activated_id = p_item->p_input->i_id;//model->getItem( index )->inputItem()->i_id;
+ playlist_Unlock( THEPL );
+ model->activateItem( index );
+ }
+}
+
+void StandardPLPanel::browseInto( input_item_t *p_input )
+{
+
+ if( p_input->i_id != last_activated_id ) return;
+
+ playlist_Lock( THEPL );
+
+ playlist_item_t *p_item = playlist_ItemGetByInput( THEPL, p_input );
+ if( !p_item )
+ {
+ playlist_Unlock( THEPL );
+ return;
+ }
+
+ QModelIndex index = model->index( p_item->i_id, 0 );
+
+ playlist_Unlock( THEPL );
+
+ if( currentView == iconView ) {
+ iconView->setRootIndex( index );
+ locationBar->setIndex( index );
+ }
+ else
+ treeView->setExpanded( index, true );
+
+ last_activated_id = -1;
+
+
+}
+
+LocationBar::LocationBar( PLModel *m )
+{
+ model = m;
+ mapper = new QSignalMapper( this );
+ CONNECT( mapper, mapped( int ), this, invoke( int ) );
+
+ box = new QHBoxLayout;
+ box->setSpacing( 0 );
+ setLayout( box );
+}
+
+void LocationBar::setIndex( const QModelIndex &index )
+{
+ qDeleteAll( buttons );
+ buttons.clear();
+ QModelIndex i = index;
+ bool bold = true;
+ while( true )
+ {
+ PLItem *item = model->getItem( i );
+
+ char *fb_name = input_item_GetTitleFbName( item->inputItem() );
+ QString text = qfu(fb_name);
+ free(fb_name);
+ QToolButton *btn = new LocationButton( text, bold );
+ box->insertWidget( 0, btn );
+ buttons.append( btn );
+
+ mapper->setMapping( btn, item->id() );
+ CONNECT( btn, clicked( ), mapper, map( ) );
+
+ bold = false;
+
+ if( i.isValid() ) i = i.parent();
+ else break;
+ }
+}
+
+void LocationBar::invoke( int i_id )
+{
+ QModelIndex index = model->index( i_id, 0 );
+ setIndex( index );
+ emit invoked ( index );
+}
+
+LocationButton::LocationButton( const QString &text, bool bold )
+{
+ QFont font;
+ font.setBold( bold );
+ setFont( font );
+ metrics = new QFontMetrics( font );
+ setText( metrics->elidedText( text, Qt::ElideRight, 150 ) );
+}
+
+void LocationButton::paintEvent ( QPaintEvent * event )
+{
+ QStyleOptionButton option;
+ option.initFrom( this );
+ option.rect = rect();
+ option.text = text();
+ option.features = QStyleOptionButton::Flat;
+ option.state |= QStyle::State_Enabled;
+ option.state |= isChecked() ? QStyle::State_On : QStyle::State_Off;
+ if( isDown() ) option.state |= QStyle::State_Sunken;
+ QPainter p( this );
+ style()->drawControl( QStyle::CE_PushButtonBevel, &option, &p );
+ option.rect.setLeft( 18 );
+ p.drawText( option.rect, Qt::AlignVCenter,
+ metrics->elidedText( text(), Qt::ElideRight, option.rect.width() - 5 ) );
+ option.rect = QRect( 0, 0, 18, height() );
+ style()->drawPrimitive( QStyle::PE_IndicatorArrowRight, &option, &p );
+}
+
+QSize LocationButton::sizeHint() const
+{
+ QSize s( metrics->boundingRect( text() ).size() );
+ s += QSize( 25, 10 );
+ return s;
+}