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/customwidgets.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 );
228 ADD_MENU_ENTRY( QIcon( ":/buttons/playlist/playlist_remove" ), qtr(I_POP_DEL),
229 VLCModelSubInterface::ACTION_REMOVE );
231 ADD_MENU_ENTRY( QIcon( ":/toolbar/clear" ), qtr("Clear the playlist"),
232 VLCModelSubInterface::ACTION_CLEAR );
236 /* Playlist sorting */
237 if ( model->isSupportedAction( VLCModelSubInterface::ACTION_SORT, index ) )
239 QMenu *sortingMenu = new QMenu( qtr( "Sort by" ) );
240 /* Choose what columns to show in sorting menu, not sure if this should be configurable*/
241 QList<int> sortingColumns;
242 sortingColumns << COLUMN_TITLE << COLUMN_ARTIST << COLUMN_ALBUM << COLUMN_TRACK_NUMBER << COLUMN_URI;
243 container.action = VLCModelSubInterface::ACTION_SORT;
244 foreach( int Column, sortingColumns )
246 action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Ascending") );
247 container.column = model->columnFromMeta(Column) + 1;
248 action->setData( QVariant::fromValue( container ) );
250 action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Descending") );
251 container.column = -1 * (model->columnFromMeta(Column)+1);
252 action->setData( QVariant::fromValue( container ) );
254 menu.addMenu( sortingMenu );
258 QMenu *zoomMenu = new QMenu( qtr( "Display size" ) );
259 zoomMenu->addAction( qtr( "Increase" ), this, SLOT( increaseZoom() ) );
260 zoomMenu->addAction( qtr( "Decrease" ), this, SLOT( decreaseZoom() ) );
261 menu.addMenu( zoomMenu );
263 CONNECT( &menu, triggered( QAction * ), this, popupAction( QAction * ) );
265 menu.addMenu( StandardPLPanel::viewSelectionMenu( this ) );
267 /* Display and forward the result */
268 if( !menu.isEmpty() )
270 menu.exec( point ); return true;
274 #undef ADD_MENU_ENTRY
277 void StandardPLPanel::popupAction( QAction *action )
279 VLCProxyModel *model = qobject_cast<VLCProxyModel *>(currentView->model());
280 VLCModelSubInterface::actionsContainerType a =
281 action->data().value<VLCModelSubInterface::actionsContainerType>();
282 QModelIndexList list = currentView->selectionModel()->selectedRows();
283 QModelIndex index = popupIndex( currentView );
290 /* first try to complete actions requiring missing parameters thru UI dialogs */
293 case VLCModelSubInterface::ACTION_INFO:
294 /* locally handled only */
295 if( index.isValid() )
297 input_item_t* p_input = model->getInputItem( index );
298 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
299 mid->setParent( PlaylistDialog::getInstance( p_intf ),
305 case VLCModelSubInterface::ACTION_EXPLORE:
306 /* locally handled only */
307 temp = model->getURI( index );
308 if( ! temp.isEmpty() ) path = make_path( temp.toLatin1().constData() );
309 if( path == NULL ) return;
310 QDesktopServices::openUrl(
311 QUrl::fromLocalFile( QFileInfo( qfu( path ) ).absolutePath() ) );
315 case VLCModelSubInterface::ACTION_STREAM:
316 /* locally handled only */
317 temp = model->getURI( index );
318 if ( ! temp.isEmpty() )
319 THEDP->streamingDialog( NULL, temp, false );
322 case VLCModelSubInterface::ACTION_SAVE:
323 /* locally handled only */
324 temp = model->getURI( index );
325 if ( ! temp.isEmpty() )
326 THEDP->streamingDialog( NULL, temp );
329 case VLCModelSubInterface::ACTION_CREATENODE:
330 temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
331 qtr( I_NEW_DIR ), qtr( I_NEW_DIR_NAME ),
332 QLineEdit::Normal, QString(), &ok);
334 model->createNode( index, temp );
337 case VLCModelSubInterface::ACTION_RENAMENODE:
338 temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
339 qtr( I_RENAME_DIR ), qtr( I_RENAME_DIR_NAME ),
340 QLineEdit::Normal, model->getTitle( index ), &ok);
342 model->renameNode( index, temp );
345 case VLCModelSubInterface::ACTION_ENQUEUEFILE:
346 uris = THEDP->showSimpleOpen();
347 if ( uris.isEmpty() ) return;
349 foreach( const QString &file, uris )
350 a.uris << qtu( toURI( toNativeSeparators( file ) ) );
351 action->setData( QVariant::fromValue( a ) );
352 if ( model->action( action, list ) )
353 foreach( const QString &file, a.uris )
354 RecentsMRL::getInstance( p_intf )->addRecent( file );
357 case VLCModelSubInterface::ACTION_ENQUEUEDIR:
358 temp = THEDP->getDirectoryDialog();
359 if ( temp.isEmpty() ) return;
361 action->setData( QVariant::fromValue( a ) );
362 model->action( action, list );
365 case VLCModelSubInterface::ACTION_ENQUEUEGENERIC:
366 dialog = OpenDialog::getInstance( this, p_intf, false, SELECT, true, true );
367 dialog->showTab( OPEN_FILE_TAB );
368 dialog->exec(); /* make it modal */
369 a.uris = dialog->getMRLs( false );
370 a.options = dialog->getOptions();
371 if ( a.uris.isEmpty() ) return;
372 action->setData( QVariant::fromValue( a ) );
373 if ( model->action( action, list ) )
374 foreach( const QString &file, a.uris )
375 RecentsMRL::getInstance( p_intf )->addRecent( file );
379 model->action( action, list );
383 QMenu* StandardPLPanel::viewSelectionMenu( StandardPLPanel *panel )
385 QMenu *viewMenu = new QMenu( qtr( "Playlist View Mode" ) );
386 QSignalMapper *viewSelectionMapper = new QSignalMapper( viewMenu );
387 CONNECT( viewSelectionMapper, mapped( int ), panel, showView( int ) );
389 QActionGroup *viewGroup = new QActionGroup( viewMenu );
390 # define MAX_VIEW StandardPLPanel::VIEW_COUNT
391 for( int i = 0; i < MAX_VIEW; i++ )
393 QAction *action = viewMenu->addAction( viewNames[i] );
394 action->setCheckable( true );
395 viewGroup->addAction( action );
396 viewSelectionMapper->setMapping( action, i );
397 CONNECT( action, triggered(), viewSelectionMapper, map() );
398 if( panel->currentViewIndex() == i )
399 action->setChecked( true );
404 inline QModelIndex popupIndex( QAbstractItemView *view )
406 QModelIndexList list = view->selectionModel()->selectedIndexes();
407 if ( list.isEmpty() )
408 return QModelIndex();
413 void StandardPLPanel::popupSelectColumn( QPoint )
418 /* We do not offer the option to hide index 0 column, or
419 * QTreeView will behave weird */
420 for( int i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
422 QAction* option = menu.addAction( qfu( psz_column_title( i ) ) );
423 option->setCheckable( true );
424 option->setChecked( !treeView->isColumnHidden( j ) );
425 selectColumnsSigMapper->setMapping( option, j );
426 CONNECT( option, triggered(), selectColumnsSigMapper, map() );
428 menu.exec( QCursor::pos() );
431 void StandardPLPanel::toggleColumnShown( int i )
433 treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
436 /* Search in the playlist */
437 void StandardPLPanel::search( const QString& searchText )
442 p_selector->getCurrentItemInfos( &type, &can_search, &name );
444 if( type != SD_TYPE || !can_search )
446 bool flat = ( currentView == iconView ||
447 currentView == listView ||
448 currentView == picFlowView );
449 model->filter( searchText,
450 flat ? currentView->rootIndex() : QModelIndex(),
455 void StandardPLPanel::searchDelayed( const QString& searchText )
460 p_selector->getCurrentItemInfos( &type, &can_search, &name );
462 if( type == SD_TYPE && can_search )
464 if( !name.isEmpty() && !searchText.isEmpty() )
465 playlist_ServicesDiscoveryControl( THEPL, qtu( name ), SD_CMD_SEARCH,
470 /* Set the root of the new Playlist */
471 /* This activated by the selector selection */
472 void StandardPLPanel::setRootItem( playlist_item_t *p_item, bool b )
474 #ifdef SQL_MEDIA_LIBRARY
477 msg_Dbg( p_intf, "Setting the SQL ML" );
478 if ( model->switchToModel( VLCProxyModel::SQLML_MODEL ) )
479 currentView->setModel( model );
486 if ( model->switchToModel( VLCProxyModel::PL_MODEL ) )
487 model->rebuild( p_item );
491 void StandardPLPanel::browseInto( const QModelIndex &index )
493 if( currentView == iconView || currentView == listView || currentView == picFlowView )
496 currentView->setRootIndex( index );
498 /* When going toward root in LocationBar, scroll to the item
499 that was previously as root */
500 QModelIndex newIndex = model->indexByPLID(currentRootIndexPLId,0);
501 while( newIndex.isValid() && (newIndex.parent() != index) )
502 newIndex = newIndex.parent();
503 if( newIndex.isValid() )
504 currentView->scrollTo( newIndex );
506 /* Store new rootindexid*/
507 currentRootIndexPLId = model->itemId( index, PLAYLIST_ID );
509 model->ensureArtRequested( index );
512 emit viewChanged( index );
515 void StandardPLPanel::browseInto()
517 browseInto( (currentRootIndexPLId != -1 && currentView != treeView) ?
518 model->indexByPLID( currentRootIndexPLId, 0 ) :
522 void StandardPLPanel::wheelEvent( QWheelEvent *e )
524 if( e->modifiers() & Qt::ControlModifier ) {
525 int numSteps = e->delta() / 8 / 15;
528 else if( numSteps < 0)
531 // Accept this event in order to prevent unwanted volume up/down changes
535 bool StandardPLPanel::eventFilter ( QObject *obj, QEvent * event )
537 if (event->type() == QEvent::KeyPress)
539 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
540 if( keyEvent->key() == Qt::Key_Delete ||
541 keyEvent->key() == Qt::Key_Backspace )
547 else if ( event->type() == QEvent::Paint )
548 {/* Warn! Don't filter events from anything else than views ! */
549 if ( model->rowCount() == 0 && p_selector->getCurrentItemCategory() == PL_ITEM_TYPE )
551 QWidget *viewport = qobject_cast<QWidget *>( obj );
552 QStylePainter painter( viewport );
553 QPixmap dropzone(":/dropzone");
554 QRect rect = viewport->geometry();
555 QSize size = rect.size() / 2 - dropzone.size() / 2;
556 rect.adjust( 0, size.height(), 0 , 0 );
557 painter.drawItemPixmap( rect, Qt::AlignHCenter, dropzone );
558 /* now select the zone just below the drop zone and let Qt center
559 the text by itself */
560 rect.adjust( 0, dropzone.size().height() + 10, 0, 0 );
561 rect.setRight( viewport->geometry().width() );
563 painter.drawItemText( rect,
567 qtr("Playlist is currently empty.\n"
568 "Drop a file here or select a "
569 "media source from the left."),
572 else if ( spinnerAnimation->state() == PixmapAnimator::Running )
574 if ( currentView->model()->rowCount() )
575 spinnerAnimation->stop(); /* Trick until SD emits events */
578 QWidget *viewport = qobject_cast<QWidget *>( obj );
579 QStylePainter painter( viewport );
580 QPixmap *spinner = spinnerAnimation->getPixmap();
581 QPoint point = viewport->geometry().center();
582 point -= QPoint( spinner->size().width() / 2, spinner->size().height() / 2 );
583 painter.drawPixmap( point, *spinner );
590 void StandardPLPanel::deleteSelection()
592 QModelIndexList list = currentView->selectionModel()->selectedIndexes();
593 model->doDelete( list );
596 void StandardPLPanel::createIconView()
598 iconView = new PlIconView( model, this );
599 iconView->setContextMenuPolicy( Qt::CustomContextMenu );
600 CONNECT( iconView, customContextMenuRequested( const QPoint & ),
601 this, popupPlView( const QPoint & ) );
602 CONNECT( iconView, activated( const QModelIndex & ),
603 this, activate( const QModelIndex & ) );
604 iconView->installEventFilter( this );
605 iconView->viewport()->installEventFilter( this );
606 viewStack->addWidget( iconView );
609 void StandardPLPanel::createListView()
611 listView = new PlListView( model, this );
612 listView->setContextMenuPolicy( Qt::CustomContextMenu );
613 CONNECT( listView, customContextMenuRequested( const QPoint & ),
614 this, popupPlView( const QPoint & ) );
615 CONNECT( listView, activated( const QModelIndex & ),
616 this, activate( const QModelIndex & ) );
617 listView->installEventFilter( this );
618 listView->viewport()->installEventFilter( this );
619 viewStack->addWidget( listView );
622 void StandardPLPanel::createCoverView()
624 picFlowView = new PicFlowView( model, this );
625 picFlowView->setContextMenuPolicy( Qt::CustomContextMenu );
626 CONNECT( picFlowView, customContextMenuRequested( const QPoint & ),
627 this, popupPlView( const QPoint & ) );
628 CONNECT( picFlowView, activated( const QModelIndex & ),
629 this, activate( const QModelIndex & ) );
630 viewStack->addWidget( picFlowView );
631 picFlowView->installEventFilter( this );
634 void StandardPLPanel::createTreeView()
636 /* Create and configure the QTreeView */
637 treeView = new PlTreeView( model, this );
639 /* setModel after setSortingEnabled(true), or the model will sort immediately! */
641 /* Connections for the TreeView */
642 CONNECT( treeView, activated( const QModelIndex& ),
643 this, activate( const QModelIndex& ) );
644 CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
645 this, popupSelectColumn( QPoint ) );
646 CONNECT( treeView, customContextMenuRequested( const QPoint & ),
647 this, popupPlView( const QPoint & ) );
648 treeView->installEventFilter( this );
649 treeView->viewport()->installEventFilter( this );
651 /* SignalMapper for columns */
652 selectColumnsSigMapper = new QSignalMapper( this );
653 CONNECT( selectColumnsSigMapper, mapped( int ),
654 this, toggleColumnShown( int ) );
656 viewStack->addWidget( treeView );
659 void StandardPLPanel::updateZoom( int i )
661 if ( i < 5 - QApplication::font().pointSize() ) return;
662 if ( i > 3 + QApplication::font().pointSize() ) return;
664 #define A_ZOOM( view ) \
666 qobject_cast<AbstractPlViewItemDelegate*>( view->itemDelegate() )->setZoom( i_zoom )
667 /* Can't iterate as picflow & tree aren't using custom delegate */
673 void StandardPLPanel::showView( int i_view )
675 bool b_treeViewCreated = false;
681 if( iconView == NULL )
683 currentView = iconView;
688 if( listView == NULL )
690 currentView = listView;
693 case PICTUREFLOW_VIEW:
695 if( picFlowView == NULL )
697 currentView = picFlowView;
703 if( treeView == NULL )
706 b_treeViewCreated = true;
708 currentView = treeView;
713 currentView->setModel( model );
715 /* Restoring the header Columns must come after changeModel */
716 if( b_treeViewCreated )
719 if( getSettings()->contains( "Playlist/headerStateV2" ) )
721 treeView->header()->restoreState(getSettings()
722 ->value( "Playlist/headerStateV2" ).toByteArray() );
723 /* if there is allready stuff in playlist, we don't sort it and we reset
725 if( model->rowCount() )
727 treeView->header()->setSortIndicator( -1 , Qt::AscendingOrder );
732 for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
734 treeView->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
735 if( m == COLUMN_TITLE ) treeView->header()->resizeSection( c, 200 );
736 else if( m == COLUMN_DURATION ) treeView->header()->resizeSection( c, 80 );
741 updateZoom( i_zoom );
742 viewStack->setCurrentWidget( currentView );
747 void StandardPLPanel::setWaiting( bool b )
751 spinnerAnimation->setLoopCount( 20 ); /* Trick until SD emits an event */
752 spinnerAnimation->start();
755 spinnerAnimation->stop();
758 void StandardPLPanel::updateViewport()
760 /* A single update on parent widget won't work */
761 currentView->viewport()->repaint();
764 int StandardPLPanel::currentViewIndex() const
766 if( currentView == treeView )
768 else if( currentView == iconView )
770 else if( currentView == listView )
773 return PICTUREFLOW_VIEW;
776 void StandardPLPanel::cycleViews()
778 if( currentView == iconView )
779 showView( TREE_VIEW );
780 else if( currentView == treeView )
781 showView( LIST_VIEW );
782 else if( currentView == listView )
784 showView( PICTUREFLOW_VIEW );
785 else if( currentView == picFlowView )
787 showView( ICON_VIEW );
792 void StandardPLPanel::activate( const QModelIndex &index )
794 if( currentView->model() == model )
796 /* If we are not a leaf node */
797 if( !index.data( VLCModelSubInterface::IsLeafNodeRole ).toBool() )
799 if( currentView != treeView )
804 playlist_Lock( THEPL );
805 playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index, PLAYLIST_ID ) );
808 p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
809 lastActivatedPLItemId = p_item->i_id;
811 playlist_Unlock( THEPL );
812 if ( p_item && index.isValid() )
813 model->activateItem( index );
818 void StandardPLPanel::browseInto( int i_pl_item_id )
820 if( i_pl_item_id != lastActivatedPLItemId ) return;
822 QModelIndex index = model->indexByPLID( i_pl_item_id, 0 );
824 if( currentView == treeView )
825 treeView->setExpanded( index, true );
829 lastActivatedPLItemId = -1;