+ p_intf->p_sys->p_mi->playlistVisible = true;
+ event->accept();
+ }
+ else
+ {
+ p_intf->p_sys->p_mi->playlistVisible = false;
+ hide();
+ event->ignore();
+ }
+}
+
+void PlaylistWidget::forceHide()
+{
+ leftSplitter->hide();
+ mainView->hide();
+ updateGeometry();
+}
+
+void PlaylistWidget::forceShow()
+{
+ leftSplitter->show();
+ mainView->show();
+ updateGeometry();
+}
+
+void PlaylistWidget::changeView( const QModelIndex& index )
+{
+ searchEdit->clear();
+ locationBar->setIndex( index );
+ int i = mainView->currentViewIndex();
+ viewActions[i]->setChecked(true);
+}
+
+void PlaylistWidget::clearPlaylist()
+{
+ PLModel *model = PLModel::getPLModel( p_intf );
+ if( model->rowCount() < 1 ) return;
+
+ QModelIndexList* l = new QModelIndexList();
+ for( int i = 0; i < model->rowCount(); i++)
+ {
+ QModelIndex indexrecord = model->index( i, 0, QModelIndex() );
+ l->append( indexrecord );
+ }
+ model->doDelete(*l);
+}
+#include <QSignalMapper>
+#include <QMenu>
+#include <QPainter>
+LocationBar::LocationBar( PLModel *m )
+{
+ model = m;
+ mapper = new QSignalMapper( this );
+ CONNECT( mapper, mapped( int ), this, invoke( int ) );
+
+ btnMore = new LocationButton( "...", false, true, this );
+ menuMore = new QMenu( this );
+ btnMore->setMenu( menuMore );
+}
+
+void LocationBar::setIndex( const QModelIndex &index )
+{
+ qDeleteAll( buttons );
+ buttons.clear();
+ qDeleteAll( actions );
+ actions.clear();
+
+ QModelIndex i = index;
+ bool first = true;
+
+ while( true )
+ {
+ PLItem *item = model->getItem( i );
+ QString text;
+
+ char *fb_name = input_item_GetTitle( item->inputItem() );
+ if( EMPTY_STR( fb_name ) )
+ {
+ free( fb_name );
+ fb_name = input_item_GetName( item->inputItem() );
+ }
+ text = qfu(fb_name);
+ free(fb_name);
+
+ QAbstractButton *btn = new LocationButton( text, first, !first, this );
+ btn->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
+ buttons.append( btn );
+
+ QAction *action = new QAction( text, this );
+ actions.append( action );
+ CONNECT( btn, clicked(), action, trigger() );
+
+ mapper->setMapping( action, item->id() );
+ CONNECT( action, triggered(), mapper, map() );
+
+ first = false;
+
+ if( i.isValid() ) i = i.parent();
+ else break;
+ }
+
+ QString prefix;
+ for( int a = actions.count() - 1; a >= 0 ; a-- )
+ {
+ actions[a]->setText( prefix + actions[a]->text() );
+ prefix += QString(" ");
+ }
+
+ if( isVisible() ) layOut( size() );
+}
+
+void LocationBar::setRootIndex()
+{
+ setIndex( QModelIndex() );
+}
+
+void LocationBar::invoke( int i_id )
+{
+ QModelIndex index = model->index( i_id, 0 );
+ emit invoked ( index );
+}
+
+void LocationBar::layOut( const QSize& size )
+{
+ menuMore->clear();
+ widths.clear();
+
+ int count = buttons.count();
+ int totalWidth = 0;
+ for( int i = 0; i < count; i++ )
+ {
+ int w = buttons[i]->sizeHint().width();
+ widths.append( w );
+ totalWidth += w;
+ if( totalWidth > size.width() ) break;
+ }
+
+ int x = 0;
+ int shown = widths.count();
+
+ if( totalWidth > size.width() && count > 1 )
+ {
+ QSize sz = btnMore->sizeHint();
+ btnMore->setGeometry( 0, 0, sz.width(), size.height() );
+ btnMore->show();
+ x = sz.width();
+ totalWidth += x;