1 /*****************************************************************************
2 * standardpanel.cpp : The "standard" playlist panel : just a treeview
3 ****************************************************************************
4 * Copyright © 2000-2010 VideoLAN
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include "components/playlist/standardpanel.hpp"
31 #include "components/playlist/vlc_model.hpp" /* VLCModel */
32 #include "components/playlist/playlist_model.hpp" /* PLModel */
33 #include "components/playlist/ml_model.hpp" /* MLModel */
34 #include "components/playlist/views.hpp" /* 3 views */
35 #include "components/playlist/selector.hpp" /* PLSelector */
36 #include "util/animators.hpp" /* PixmapAnimator */
37 #include "menus.hpp" /* Popup */
38 #include "input_manager.hpp" /* THEMIM */
39 #include "dialogs_provider.hpp" /* THEDP */
40 #include "recents.hpp" /* RecentMRL */
41 #include "dialogs/playlist.hpp" /* Playlist Dialog */
42 #include "dialogs/mediainfo.hpp" /* MediaInfoDialog */
43 #include "util/qt_dirs.hpp"
45 #include <vlc_services_discovery.h> /* SD_CMD_SEARCH */
46 #include <vlc_intf_strings.h> /* POP_ */
49 I_DIR_OR_FOLDER( N_("Create Directory"), N_( "Create Folder" ) )
50 #define I_NEW_DIR_NAME \
51 I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
52 N_( "Enter name for new folder:" ) )
54 #define I_RENAME_DIR \
55 I_DIR_OR_FOLDER( N_("Rename Directory"), N_( "Rename Folder" ) )
56 #define I_RENAME_DIR_NAME \
57 I_DIR_OR_FOLDER( N_( "Enter a new name for the directory:" ), \
58 N_( "Enter a new name for the folder:" ) )
60 #include <QHeaderView>
63 #include <QWheelEvent>
64 #include <QStackedLayout>
65 #include <QSignalMapper>
67 #include <QStylePainter>
68 #include <QInputDialog>
69 #include <QDesktopServices>
76 inline QModelIndex popupIndex( QAbstractItemView *view );
78 StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
79 intf_thread_t *_p_intf,
80 playlist_item_t *p_root,
81 PLSelector *_p_selector,
82 VLCProxyModel *_p_model )
86 p_selector( _p_selector )
88 viewStack = new QStackedLayout( this );
89 viewStack->setSpacing( 0 ); viewStack->setMargin( 0 );
90 setMinimumWidth( 300 );
97 currentRootIndexPLId = -1;
98 lastActivatedPLItemId = -1;
100 QList<QString> frames;
101 frames << ":/util/wait1";
102 frames << ":/util/wait2";
103 frames << ":/util/wait3";
104 frames << ":/util/wait4";
105 spinnerAnimation = new PixmapAnimator( this, frames );
106 CONNECT( spinnerAnimation, pixmapReady( const QPixmap & ), this, updateViewport() );
109 int i_savedViewMode = getSettings()->value( "Playlist/view-mode", TREE_VIEW ).toInt();
110 i_zoom = getSettings()->value( "Playlist/zoom", 0 ).toInt();
112 showView( i_savedViewMode );
114 DCONNECT( THEMIM, leafBecameParent( int ),
115 this, browseInto( int ) );
117 CONNECT( model->sigs, currentIndexChanged( const QModelIndex& ),
118 this, handleExpansion( const QModelIndex& ) );
119 CONNECT( model->sigs, rootIndexChanged(), this, browseInto() );
121 setRootItem( p_root, false );
124 StandardPLPanel::~StandardPLPanel()
126 getSettings()->beginGroup("Playlist");
128 getSettings()->setValue( "headerStateV2", treeView->header()->saveState() );
129 getSettings()->setValue( "view-mode", currentViewIndex() );
130 getSettings()->setValue( "zoom", i_zoom );
131 getSettings()->endGroup();
134 /* Unused anymore, but might be useful, like in right-click menu */
135 void StandardPLPanel::gotoPlayingItem()
137 currentView->scrollTo( model->currentIndex() );
140 void StandardPLPanel::handleExpansion( const QModelIndex& index )
142 assert( currentView );
143 if( currentRootIndexPLId != -1 && currentRootIndexPLId != model->itemId( index.parent(), PLAYLIST_ID ) )
144 browseInto( index.parent() );
145 currentView->scrollTo( index );
148 void StandardPLPanel::popupPlView( const QPoint &point )
150 QPoint globalPoint = currentView->viewport()->mapToGlobal( point );
151 QModelIndex index = currentView->indexAt( point );
152 if ( !index.isValid() )
154 currentView->clearSelection();
156 else if ( ! currentView->selectionModel()->selectedIndexes().contains( index ) )
158 currentView->selectionModel()->select( index, QItemSelectionModel::Select );
161 if( !popup( globalPoint ) ) VLCMenuBar::PopupMenu( p_intf, true );
164 /*********** Popup *********/
165 bool StandardPLPanel::popup( const QPoint &point )
167 QModelIndex index = popupIndex( currentView ); /* index for menu logic only. Do not store.*/
168 VLCProxyModel *model = qobject_cast<VLCProxyModel *>(currentView->model());
170 #define ADD_MENU_ENTRY( icon, title, act ) \
171 if ( model->isSupportedAction( act, index ) )\
173 action = menu.addAction( icon, title ); \
174 container.action = act; \
175 action->setData( QVariant::fromValue( container ) );\
181 VLCModelSubInterface::actionsContainerType container;
183 /* Play/Stream/Info static actions */
185 ADD_MENU_ENTRY( QIcon( ":/menu/play" ), qtr(I_POP_PLAY),
186 VLCModelSubInterface::ACTION_PLAY )
188 ADD_MENU_ENTRY( QIcon( ":/menu/stream" ), qtr(I_POP_STREAM),
189 VLCModelSubInterface::ACTION_STREAM )
191 ADD_MENU_ENTRY( QIcon(), qtr(I_POP_SAVE),
192 VLCModelSubInterface::ACTION_SAVE );
194 ADD_MENU_ENTRY( QIcon( ":/menu/info" ), qtr(I_POP_INFO),
195 VLCModelSubInterface::ACTION_INFO );
199 ADD_MENU_ENTRY( QIcon( ":/type/folder-grey" ), qtr(I_POP_EXPLORE),
200 VLCModelSubInterface::ACTION_EXPLORE );
202 QIcon addIcon( ":/buttons/playlist/playlist_add" );
204 ADD_MENU_ENTRY( addIcon, qtr(I_POP_NEWFOLDER),
205 VLCModelSubInterface::ACTION_CREATENODE )
207 ADD_MENU_ENTRY( QIcon(), qtr(I_POP_RENAMEFOLDER),
208 VLCModelSubInterface::ACTION_RENAMENODE )
211 /* In PL or ML, allow to add a file/folder */
212 ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDF),
213 VLCModelSubInterface::ACTION_ENQUEUEFILE )
215 ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDDIR),
216 VLCModelSubInterface::ACTION_ENQUEUEDIR )
218 ADD_MENU_ENTRY( addIcon, qtr(I_OP_ADVOP),
219 VLCModelSubInterface::ACTION_ENQUEUEGENERIC )
221 ADD_MENU_ENTRY( QIcon(), qtr(I_PL_ADDPL),
222 VLCModelSubInterface::ACTION_ADDTOPLAYLIST );
225 ADD_MENU_ENTRY( QIcon(), qtr( I_PL_SAVE ),
226 VLCModelSubInterface::ACTION_SAVETOPLAYLIST );
232 ADD_MENU_ENTRY( QIcon( ":/buttons/playlist/playlist_remove" ), qtr(I_POP_DEL),
233 VLCModelSubInterface::ACTION_REMOVE );
235 ADD_MENU_ENTRY( QIcon( ":/toolbar/clear" ), qtr("Clear the playlist"),
236 VLCModelSubInterface::ACTION_CLEAR );
240 /* Playlist sorting */
241 if ( model->isSupportedAction( VLCModelSubInterface::ACTION_SORT, index ) )
243 QMenu *sortingMenu = new QMenu( qtr( "Sort by" ) );
244 /* Choose what columns to show in sorting menu, not sure if this should be configurable*/
245 QList<int> sortingColumns;
246 sortingColumns << COLUMN_TITLE << COLUMN_ARTIST << COLUMN_ALBUM << COLUMN_TRACK_NUMBER << COLUMN_URI;
247 container.action = VLCModelSubInterface::ACTION_SORT;
248 foreach( int Column, sortingColumns )
250 action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Ascending") );
251 container.column = model->columnFromMeta(Column) + 1;
252 action->setData( QVariant::fromValue( container ) );
254 action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Descending") );
255 container.column = -1 * (model->columnFromMeta(Column)+1);
256 action->setData( QVariant::fromValue( container ) );
258 menu.addMenu( sortingMenu );
262 QMenu *zoomMenu = new QMenu( qtr( "Display size" ) );
263 zoomMenu->addAction( qtr( "Increase" ), this, SLOT( increaseZoom() ) );
264 zoomMenu->addAction( qtr( "Decrease" ), this, SLOT( decreaseZoom() ) );
265 menu.addMenu( zoomMenu );
267 CONNECT( &menu, triggered( QAction * ), this, popupAction( QAction * ) );
269 menu.addMenu( StandardPLPanel::viewSelectionMenu( this ) );
271 /* Display and forward the result */
272 if( !menu.isEmpty() )
274 menu.exec( point ); return true;
278 #undef ADD_MENU_ENTRY
281 void StandardPLPanel::popupAction( QAction *action )
283 VLCProxyModel *model = qobject_cast<VLCProxyModel *>(currentView->model());
284 VLCModelSubInterface::actionsContainerType a =
285 action->data().value<VLCModelSubInterface::actionsContainerType>();
286 QModelIndexList list = currentView->selectionModel()->selectedRows();
287 QModelIndex index = popupIndex( currentView );
294 /* first try to complete actions requiring missing parameters thru UI dialogs */
297 case VLCModelSubInterface::ACTION_INFO:
298 /* locally handled only */
299 if( index.isValid() )
301 input_item_t* p_input = model->getInputItem( index );
302 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
303 mid->setParent( PlaylistDialog::getInstance( p_intf ),
309 case VLCModelSubInterface::ACTION_EXPLORE:
310 /* locally handled only */
311 temp = model->getURI( index );
312 if( ! temp.isEmpty() ) path = make_path( temp.toLatin1().constData() );
313 if( path == NULL ) return;
314 QDesktopServices::openUrl(
315 QUrl::fromLocalFile( QFileInfo( qfu( path ) ).absolutePath() ) );
319 case VLCModelSubInterface::ACTION_STREAM:
320 /* locally handled only */
321 temp = model->getURI( index );
322 if ( ! temp.isEmpty() )
323 THEDP->streamingDialog( NULL, temp, false );
326 case VLCModelSubInterface::ACTION_SAVE:
327 /* locally handled only */
328 temp = model->getURI( index );
329 if ( ! temp.isEmpty() )
330 THEDP->streamingDialog( NULL, temp );
333 case VLCModelSubInterface::ACTION_CREATENODE:
334 temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
335 qtr( I_NEW_DIR ), qtr( I_NEW_DIR_NAME ),
336 QLineEdit::Normal, QString(), &ok);
338 model->createNode( index, temp );
341 case VLCModelSubInterface::ACTION_RENAMENODE:
342 temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
343 qtr( I_RENAME_DIR ), qtr( I_RENAME_DIR_NAME ),
344 QLineEdit::Normal, model->getTitle( index ), &ok);
346 model->renameNode( index, temp );
349 case VLCModelSubInterface::ACTION_ENQUEUEFILE:
350 uris = THEDP->showSimpleOpen();
351 if ( uris.isEmpty() ) return;
353 foreach( const QString &file, uris )
354 a.uris << qtu( toURI( toNativeSeparators( file ) ) );
355 action->setData( QVariant::fromValue( a ) );
356 if ( model->action( action, list ) )
357 foreach( const QString &file, a.uris )
358 RecentsMRL::getInstance( p_intf )->addRecent( file );
361 case VLCModelSubInterface::ACTION_ENQUEUEDIR:
362 temp = THEDP->getDirectoryDialog();
363 if ( temp.isEmpty() ) return;
365 action->setData( QVariant::fromValue( a ) );
366 model->action( action, list );
369 case VLCModelSubInterface::ACTION_ENQUEUEGENERIC:
370 dialog = OpenDialog::getInstance( this, p_intf, false, SELECT, true, true );
371 dialog->showTab( OPEN_FILE_TAB );
372 dialog->exec(); /* make it modal */
373 a.uris = dialog->getMRLs( false );
374 a.options = dialog->getOptions();
375 if ( a.uris.isEmpty() ) return;
376 action->setData( QVariant::fromValue( a ) );
377 if ( model->action( action, list ) )
378 foreach( const QString &file, a.uris )
379 RecentsMRL::getInstance( p_intf )->addRecent( file );
382 case VLCModelSubInterface::ACTION_SAVETOPLAYLIST:
383 THEDP->savePlayingToPlaylist();
386 model->action( action, list );
390 QMenu* StandardPLPanel::viewSelectionMenu( StandardPLPanel *panel )
392 QMenu *viewMenu = new QMenu( qtr( "Playlist View Mode" ) );
393 QSignalMapper *viewSelectionMapper = new QSignalMapper( viewMenu );
394 CONNECT( viewSelectionMapper, mapped( int ), panel, showView( int ) );
396 QActionGroup *viewGroup = new QActionGroup( viewMenu );
397 # define MAX_VIEW StandardPLPanel::VIEW_COUNT
398 for( int i = 0; i < MAX_VIEW; i++ )
400 QAction *action = viewMenu->addAction( viewNames[i] );
401 action->setCheckable( true );
402 viewGroup->addAction( action );
403 viewSelectionMapper->setMapping( action, i );
404 CONNECT( action, triggered(), viewSelectionMapper, map() );
405 if( panel->currentViewIndex() == i )
406 action->setChecked( true );
411 inline QModelIndex popupIndex( QAbstractItemView *view )
413 QModelIndexList list = view->selectionModel()->selectedIndexes();
414 if ( list.isEmpty() )
415 return QModelIndex();
420 void StandardPLPanel::popupSelectColumn( QPoint )
425 /* We do not offer the option to hide index 0 column, or
426 * QTreeView will behave weird */
427 for( int i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
429 QAction* option = menu.addAction( qfu( psz_column_title( i ) ) );
430 option->setCheckable( true );
431 option->setChecked( !treeView->isColumnHidden( j ) );
432 selectColumnsSigMapper->setMapping( option, j );
433 CONNECT( option, triggered(), selectColumnsSigMapper, map() );
435 menu.exec( QCursor::pos() );
438 void StandardPLPanel::toggleColumnShown( int i )
440 treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
443 /* Search in the playlist */
444 void StandardPLPanel::search( const QString& searchText )
449 p_selector->getCurrentItemInfos( &type, &can_search, &name );
451 if( type != SD_TYPE || !can_search )
453 bool flat = ( currentView == iconView ||
454 currentView == listView ||
455 currentView == picFlowView );
456 model->filter( searchText,
457 flat ? currentView->rootIndex() : QModelIndex(),
462 void StandardPLPanel::searchDelayed( const QString& searchText )
467 p_selector->getCurrentItemInfos( &type, &can_search, &name );
469 if( type == SD_TYPE && can_search )
471 if( !name.isEmpty() && !searchText.isEmpty() )
472 playlist_ServicesDiscoveryControl( THEPL, qtu( name ), SD_CMD_SEARCH,
477 /* Set the root of the new Playlist */
478 /* This activated by the selector selection */
479 void StandardPLPanel::setRootItem( playlist_item_t *p_item, bool b )
481 #ifdef SQL_MEDIA_LIBRARY
484 msg_Dbg( p_intf, "Setting the SQL ML" );
485 if ( model->switchToModel( VLCProxyModel::SQLML_MODEL ) )
486 currentView->setModel( model );
493 if ( model->switchToModel( VLCProxyModel::PL_MODEL ) )
494 model->rebuild( p_item );
498 void StandardPLPanel::browseInto( const QModelIndex &index )
500 if( currentView == iconView || currentView == listView || currentView == picFlowView )
503 currentView->setRootIndex( index );
505 /* When going toward root in LocationBar, scroll to the item
506 that was previously as root */
507 QModelIndex newIndex = model->indexByPLID(currentRootIndexPLId,0);
508 while( newIndex.isValid() && (newIndex.parent() != index) )
509 newIndex = newIndex.parent();
510 if( newIndex.isValid() )
511 currentView->scrollTo( newIndex );
513 /* Store new rootindexid*/
514 currentRootIndexPLId = model->itemId( index, PLAYLIST_ID );
516 model->ensureArtRequested( index );
519 emit viewChanged( index );
522 void StandardPLPanel::browseInto()
524 browseInto( (currentRootIndexPLId != -1 && currentView != treeView) ?
525 model->indexByPLID( currentRootIndexPLId, 0 ) :
529 void StandardPLPanel::wheelEvent( QWheelEvent *e )
531 if( e->modifiers() & Qt::ControlModifier ) {
532 int numSteps = e->delta() / 8 / 15;
535 else if( numSteps < 0)
538 // Accept this event in order to prevent unwanted volume up/down changes
542 bool StandardPLPanel::eventFilter ( QObject *obj, QEvent * event )
544 if (event->type() == QEvent::KeyPress)
546 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
547 if( keyEvent->key() == Qt::Key_Delete ||
548 keyEvent->key() == Qt::Key_Backspace )
554 else if ( event->type() == QEvent::Paint )
555 {/* Warn! Don't filter events from anything else than views ! */
556 if ( model->rowCount() == 0 && p_selector->getCurrentItemCategory() == PL_ITEM_TYPE )
558 QWidget *viewport = qobject_cast<QWidget *>( obj );
559 QStylePainter painter( viewport );
560 QPixmap dropzone(":/dropzone");
561 QRect rect = viewport->geometry();
562 QSize size = rect.size() / 2 - dropzone.size() / 2;
563 rect.adjust( 0, size.height(), 0 , 0 );
564 painter.drawItemPixmap( rect, Qt::AlignHCenter, dropzone );
565 /* now select the zone just below the drop zone and let Qt center
566 the text by itself */
567 rect.adjust( 0, dropzone.size().height() + 10, 0, 0 );
568 rect.setRight( viewport->geometry().width() );
570 painter.drawItemText( rect,
574 qtr("Playlist is currently empty.\n"
575 "Drop a file here or select a "
576 "media source from the left."),
579 else if ( spinnerAnimation->state() == PixmapAnimator::Running )
581 if ( currentView->model()->rowCount() )
582 spinnerAnimation->stop(); /* Trick until SD emits events */
585 QWidget *viewport = qobject_cast<QWidget *>( obj );
586 QStylePainter painter( viewport );
587 QPixmap *spinner = spinnerAnimation->getPixmap();
588 QPoint point = viewport->geometry().center();
589 point -= QPoint( spinner->size().width() / 2, spinner->size().height() / 2 );
590 painter.drawPixmap( point, *spinner );
597 void StandardPLPanel::deleteSelection()
599 QModelIndexList list = currentView->selectionModel()->selectedIndexes();
600 model->doDelete( list );
603 void StandardPLPanel::createIconView()
605 iconView = new PlIconView( model, this );
606 iconView->setContextMenuPolicy( Qt::CustomContextMenu );
607 CONNECT( iconView, customContextMenuRequested( const QPoint & ),
608 this, popupPlView( const QPoint & ) );
609 CONNECT( iconView, activated( const QModelIndex & ),
610 this, activate( const QModelIndex & ) );
611 iconView->installEventFilter( this );
612 iconView->viewport()->installEventFilter( this );
613 viewStack->addWidget( iconView );
616 void StandardPLPanel::createListView()
618 listView = new PlListView( model, this );
619 listView->setContextMenuPolicy( Qt::CustomContextMenu );
620 CONNECT( listView, customContextMenuRequested( const QPoint & ),
621 this, popupPlView( const QPoint & ) );
622 CONNECT( listView, activated( const QModelIndex & ),
623 this, activate( const QModelIndex & ) );
624 listView->installEventFilter( this );
625 listView->viewport()->installEventFilter( this );
626 viewStack->addWidget( listView );
629 void StandardPLPanel::createCoverView()
631 picFlowView = new PicFlowView( model, this );
632 picFlowView->setContextMenuPolicy( Qt::CustomContextMenu );
633 CONNECT( picFlowView, customContextMenuRequested( const QPoint & ),
634 this, popupPlView( const QPoint & ) );
635 CONNECT( picFlowView, activated( const QModelIndex & ),
636 this, activate( const QModelIndex & ) );
637 viewStack->addWidget( picFlowView );
638 picFlowView->installEventFilter( this );
641 void StandardPLPanel::createTreeView()
643 /* Create and configure the QTreeView */
644 treeView = new PlTreeView( model, this );
646 /* setModel after setSortingEnabled(true), or the model will sort immediately! */
648 /* Connections for the TreeView */
649 CONNECT( treeView, activated( const QModelIndex& ),
650 this, activate( const QModelIndex& ) );
651 CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
652 this, popupSelectColumn( QPoint ) );
653 CONNECT( treeView, customContextMenuRequested( const QPoint & ),
654 this, popupPlView( const QPoint & ) );
655 treeView->installEventFilter( this );
656 treeView->viewport()->installEventFilter( this );
658 /* SignalMapper for columns */
659 selectColumnsSigMapper = new QSignalMapper( this );
660 CONNECT( selectColumnsSigMapper, mapped( int ),
661 this, toggleColumnShown( int ) );
663 viewStack->addWidget( treeView );
666 void StandardPLPanel::updateZoom( int i )
668 if ( i < 5 - QApplication::font().pointSize() ) return;
669 if ( i > 3 + QApplication::font().pointSize() ) return;
671 #define A_ZOOM( view ) \
673 qobject_cast<AbstractPlViewItemDelegate*>( view->itemDelegate() )->setZoom( i_zoom )
674 /* Can't iterate as picflow & tree aren't using custom delegate */
680 void StandardPLPanel::showView( int i_view )
682 bool b_treeViewCreated = false;
688 if( iconView == NULL )
690 currentView = iconView;
695 if( listView == NULL )
697 currentView = listView;
700 case PICTUREFLOW_VIEW:
702 if( picFlowView == NULL )
704 currentView = picFlowView;
710 if( treeView == NULL )
713 b_treeViewCreated = true;
715 currentView = treeView;
720 currentView->setModel( model );
722 /* Restoring the header Columns must come after changeModel */
723 if( b_treeViewCreated )
726 if( getSettings()->contains( "Playlist/headerStateV2" ) )
728 treeView->header()->restoreState(getSettings()
729 ->value( "Playlist/headerStateV2" ).toByteArray() );
730 /* if there is allready stuff in playlist, we don't sort it and we reset
732 if( model->rowCount() )
734 treeView->header()->setSortIndicator( -1 , Qt::AscendingOrder );
739 for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
741 treeView->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
742 if( m == COLUMN_TITLE ) treeView->header()->resizeSection( c, 200 );
743 else if( m == COLUMN_DURATION ) treeView->header()->resizeSection( c, 80 );
748 updateZoom( i_zoom );
749 viewStack->setCurrentWidget( currentView );
754 void StandardPLPanel::setWaiting( bool b )
758 spinnerAnimation->setLoopCount( 20 ); /* Trick until SD emits an event */
759 spinnerAnimation->start();
762 spinnerAnimation->stop();
765 void StandardPLPanel::updateViewport()
767 /* A single update on parent widget won't work */
768 currentView->viewport()->repaint();
771 int StandardPLPanel::currentViewIndex() const
773 if( currentView == treeView )
775 else if( currentView == iconView )
777 else if( currentView == listView )
780 return PICTUREFLOW_VIEW;
783 void StandardPLPanel::cycleViews()
785 if( currentView == iconView )
786 showView( TREE_VIEW );
787 else if( currentView == treeView )
788 showView( LIST_VIEW );
789 else if( currentView == listView )
791 showView( PICTUREFLOW_VIEW );
792 else if( currentView == picFlowView )
794 showView( ICON_VIEW );
799 void StandardPLPanel::activate( const QModelIndex &index )
801 if( currentView->model() == model )
803 /* If we are not a leaf node */
804 if( !index.data( VLCModelSubInterface::IsLeafNodeRole ).toBool() )
806 if( currentView != treeView )
811 playlist_Lock( THEPL );
812 playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index, PLAYLIST_ID ) );
815 p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
816 lastActivatedPLItemId = p_item->i_id;
818 playlist_Unlock( THEPL );
819 if ( p_item && index.isValid() )
820 model->activateItem( index );
825 void StandardPLPanel::browseInto( int i_pl_item_id )
827 if( i_pl_item_id != lastActivatedPLItemId ) return;
829 QModelIndex index = model->indexByPLID( i_pl_item_id, 0 );
831 if( currentView == treeView )
832 treeView->setExpanded( index, true );
836 lastActivatedPLItemId = -1;