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/views.hpp" /* 3 views */
34 #include "components/playlist/selector.hpp" /* PLSelector */
35 #include "util/animators.hpp" /* PixmapAnimator */
36 #include "menus.hpp" /* Popup */
37 #include "input_manager.hpp" /* THEMIM */
38 #include "dialogs_provider.hpp" /* THEDP */
39 #include "recents.hpp" /* RecentMRL */
40 #include "dialogs/playlist.hpp" /* Playlist Dialog */
41 #include "dialogs/mediainfo.hpp" /* MediaInfoDialog */
42 #include "util/qt_dirs.hpp"
44 #include <vlc_services_discovery.h> /* SD_CMD_SEARCH */
45 #include <vlc_intf_strings.h> /* POP_ */
48 I_DIR_OR_FOLDER( N_("Create Directory"), N_( "Create Folder" ) )
49 #define I_NEW_DIR_NAME \
50 I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
51 N_( "Enter name for new folder:" ) )
53 #define I_RENAME_DIR \
54 I_DIR_OR_FOLDER( N_("Rename Directory"), N_( "Rename Folder" ) )
55 #define I_RENAME_DIR_NAME \
56 I_DIR_OR_FOLDER( N_( "Enter a new name for the directory:" ), \
57 N_( "Enter a new name for the folder:" ) )
59 #include <QHeaderView>
62 #include <QWheelEvent>
63 #include <QStackedLayout>
64 #include <QSignalMapper>
66 #include <QStylePainter>
67 #include <QInputDialog>
68 #include <QDesktopServices>
75 inline QModelIndex popupIndex( QAbstractItemView *view );
77 StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
78 intf_thread_t *_p_intf,
79 playlist_item_t *p_root,
80 PLSelector *_p_selector,
85 p_selector( _p_selector )
87 viewStack = new QStackedLayout( this );
88 viewStack->setSpacing( 0 ); viewStack->setMargin( 0 );
89 setMinimumWidth( 300 );
96 currentRootIndexPLId = -1;
97 lastActivatedPLItemId = -1;
99 QList<QString> frames;
100 frames << ":/util/wait1";
101 frames << ":/util/wait2";
102 frames << ":/util/wait3";
103 frames << ":/util/wait4";
104 spinnerAnimation = new PixmapAnimator( this, frames );
105 CONNECT( spinnerAnimation, pixmapReady( const QPixmap & ), this, updateViewport() );
108 int i_savedViewMode = getSettings()->value( "Playlist/view-mode", TREE_VIEW ).toInt();
109 i_zoom = getSettings()->value( "Playlist/zoom", 0 ).toInt();
111 showView( i_savedViewMode );
113 DCONNECT( THEMIM, leafBecameParent( int ),
114 this, browseInto( int ) );
116 CONNECT( model, currentIndexChanged( const QModelIndex& ),
117 this, handleExpansion( const QModelIndex& ) );
118 CONNECT( model, rootIndexChanged(), this, browseInto() );
120 setRootItem( p_root, false );
123 StandardPLPanel::~StandardPLPanel()
125 getSettings()->beginGroup("Playlist");
127 getSettings()->setValue( "headerStateV2", treeView->header()->saveState() );
128 getSettings()->setValue( "view-mode", currentViewIndex() );
129 getSettings()->setValue( "zoom", i_zoom );
130 getSettings()->endGroup();
133 /* Unused anymore, but might be useful, like in right-click menu */
134 void StandardPLPanel::gotoPlayingItem()
136 currentView->scrollTo( model->currentIndex() );
139 void StandardPLPanel::handleExpansion( const QModelIndex& index )
141 assert( currentView );
142 if( currentRootIndexPLId != -1 && currentRootIndexPLId != model->itemId( index.parent(), PLAYLIST_ID ) )
143 browseInto( index.parent() );
144 currentView->scrollTo( index );
147 void StandardPLPanel::popupPlView( const QPoint &point )
149 QPoint globalPoint = currentView->viewport()->mapToGlobal( point );
150 QModelIndex index = currentView->indexAt( point );
151 if ( !index.isValid() )
153 currentView->clearSelection();
155 else if ( ! currentView->selectionModel()->selectedIndexes().contains( index ) )
157 currentView->selectionModel()->select( index, QItemSelectionModel::Select );
160 if( !popup( globalPoint ) ) THEDP->setPopupMenu();
163 /*********** Popup *********/
164 bool StandardPLPanel::popup( const QPoint &point )
166 QModelIndex index = popupIndex( currentView ); /* index for menu logic only. Do not store.*/
167 VLCModel *model = qobject_cast<VLCModel *>(currentView->model());
169 #define ADD_MENU_ENTRY( icon, title, act ) \
170 if ( model->isSupportedAction( act, index ) )\
172 action = menu.addAction( icon, title ); \
173 container.action = act; \
174 action->setData( QVariant::fromValue( container ) );\
180 VLCModelSubInterface::actionsContainerType container;
182 /* Play/Stream/Info static actions */
184 ADD_MENU_ENTRY( QIcon( ":/menu/play" ), qtr(I_POP_PLAY),
185 VLCModelSubInterface::ACTION_PLAY )
187 ADD_MENU_ENTRY( QIcon( ":/menu/stream" ), qtr(I_POP_STREAM),
188 VLCModelSubInterface::ACTION_STREAM )
190 ADD_MENU_ENTRY( QIcon(), qtr(I_POP_SAVE),
191 VLCModelSubInterface::ACTION_SAVE );
193 ADD_MENU_ENTRY( QIcon( ":/menu/info" ), qtr(I_POP_INFO),
194 VLCModelSubInterface::ACTION_INFO );
198 ADD_MENU_ENTRY( QIcon( ":/type/folder-grey" ), qtr(I_POP_EXPLORE),
199 VLCModelSubInterface::ACTION_EXPLORE );
201 QIcon addIcon( ":/buttons/playlist/playlist_add" );
203 ADD_MENU_ENTRY( addIcon, qtr(I_POP_NEWFOLDER),
204 VLCModelSubInterface::ACTION_CREATENODE )
206 ADD_MENU_ENTRY( QIcon(), qtr(I_POP_RENAMEFOLDER),
207 VLCModelSubInterface::ACTION_RENAMENODE )
210 /* In PL or ML, allow to add a file/folder */
211 ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDF),
212 VLCModelSubInterface::ACTION_ENQUEUEFILE )
214 ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDDIR),
215 VLCModelSubInterface::ACTION_ENQUEUEDIR )
217 ADD_MENU_ENTRY( addIcon, qtr(I_OP_ADVOP),
218 VLCModelSubInterface::ACTION_ENQUEUEGENERIC )
220 ADD_MENU_ENTRY( QIcon(), qtr(I_PL_ADDPL),
221 VLCModelSubInterface::ACTION_ADDTOPLAYLIST );
224 ADD_MENU_ENTRY( QIcon(), qtr( I_PL_SAVE ),
225 VLCModelSubInterface::ACTION_SAVETOPLAYLIST );
231 ADD_MENU_ENTRY( QIcon( ":/buttons/playlist/playlist_remove" ), qtr(I_POP_DEL),
232 VLCModelSubInterface::ACTION_REMOVE );
234 ADD_MENU_ENTRY( QIcon( ":/toolbar/clear" ), qtr("Clear the playlist"),
235 VLCModelSubInterface::ACTION_CLEAR );
239 /* Playlist sorting */
240 if ( model->isSupportedAction( VLCModelSubInterface::ACTION_SORT, index ) )
242 QMenu *sortingMenu = new QMenu( qtr( "Sort by" ) );
243 /* Choose what columns to show in sorting menu, not sure if this should be configurable*/
244 QList<int> sortingColumns;
245 sortingColumns << COLUMN_TITLE << COLUMN_ARTIST << COLUMN_ALBUM << COLUMN_TRACK_NUMBER << COLUMN_URI;
246 container.action = VLCModelSubInterface::ACTION_SORT;
247 foreach( int Column, sortingColumns )
249 action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Ascending") );
250 container.column = model->columnFromMeta(Column) + 1;
251 action->setData( QVariant::fromValue( container ) );
253 action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Descending") );
254 container.column = -1 * (model->columnFromMeta(Column)+1);
255 action->setData( QVariant::fromValue( container ) );
257 menu.addMenu( sortingMenu );
261 QMenu *zoomMenu = new QMenu( qtr( "Display size" ) );
262 zoomMenu->addAction( qtr( "Increase" ), this, SLOT( increaseZoom() ) );
263 zoomMenu->addAction( qtr( "Decrease" ), this, SLOT( decreaseZoom() ) );
264 menu.addMenu( zoomMenu );
266 CONNECT( &menu, triggered( QAction * ), this, popupAction( QAction * ) );
268 menu.addMenu( StandardPLPanel::viewSelectionMenu( this ) );
270 /* Display and forward the result */
271 if( !menu.isEmpty() )
273 menu.exec( point ); return true;
277 #undef ADD_MENU_ENTRY
280 void StandardPLPanel::popupAction( QAction *action )
282 VLCModel *model = qobject_cast<VLCModel *>(currentView->model());
283 VLCModelSubInterface::actionsContainerType a =
284 action->data().value<VLCModelSubInterface::actionsContainerType>();
285 QModelIndexList list = currentView->selectionModel()->selectedRows();
286 QModelIndex index = popupIndex( currentView );
293 /* first try to complete actions requiring missing parameters thru UI dialogs */
296 case VLCModelSubInterface::ACTION_INFO:
297 /* locally handled only */
298 if( index.isValid() )
300 input_item_t* p_input = model->getInputItem( index );
301 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
302 mid->setParent( PlaylistDialog::getInstance( p_intf ),
308 case VLCModelSubInterface::ACTION_EXPLORE:
309 /* locally handled only */
310 temp = model->getURI( index );
311 if( ! temp.isEmpty() ) path = make_path( temp.toLatin1().constData() );
312 if( path == NULL ) return;
313 QDesktopServices::openUrl(
314 QUrl::fromLocalFile( QFileInfo( qfu( path ) ).absolutePath() ) );
318 case VLCModelSubInterface::ACTION_STREAM:
319 /* locally handled only */
320 temp = model->getURI( index );
321 if ( ! temp.isEmpty() )
323 QStringList tempList;
324 tempList.append(temp);
325 THEDP->streamingDialog( NULL, tempList, false );
329 case VLCModelSubInterface::ACTION_SAVE:
330 /* locally handled only */
331 temp = model->getURI( index );
332 if ( ! temp.isEmpty() )
334 QStringList tempList;
335 tempList.append(temp);
336 THEDP->streamingDialog( NULL, tempList );
340 case VLCModelSubInterface::ACTION_CREATENODE:
341 temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
342 qtr( I_NEW_DIR ), qtr( I_NEW_DIR_NAME ),
343 QLineEdit::Normal, QString(), &ok);
345 model->createNode( index, temp );
348 case VLCModelSubInterface::ACTION_RENAMENODE:
349 temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
350 qtr( I_RENAME_DIR ), qtr( I_RENAME_DIR_NAME ),
351 QLineEdit::Normal, model->getTitle( index ), &ok);
353 model->renameNode( index, temp );
356 case VLCModelSubInterface::ACTION_ENQUEUEFILE:
357 uris = THEDP->showSimpleOpen();
358 if ( uris.isEmpty() ) return;
360 foreach( const QString &file, uris )
361 a.uris << qtu( toURI( toNativeSeparators( file ) ) );
362 action->setData( QVariant::fromValue( a ) );
363 if ( model->action( action, list ) )
364 foreach( const QString &file, a.uris )
365 RecentsMRL::getInstance( p_intf )->addRecent( file );
368 case VLCModelSubInterface::ACTION_ENQUEUEDIR:
369 temp = DialogsProvider::getDirectoryDialog( p_intf );
370 if ( temp.isEmpty() ) return;
372 action->setData( QVariant::fromValue( a ) );
373 model->action( action, list );
376 case VLCModelSubInterface::ACTION_ENQUEUEGENERIC:
377 dialog = OpenDialog::getInstance( this, p_intf, false, SELECT, true, true );
378 dialog->showTab( OPEN_FILE_TAB );
379 dialog->exec(); /* make it modal */
380 a.uris = dialog->getMRLs( false );
381 a.options = dialog->getOptions();
382 if ( a.uris.isEmpty() ) return;
383 action->setData( QVariant::fromValue( a ) );
384 if ( model->action( action, list ) )
385 foreach( const QString &file, a.uris )
386 RecentsMRL::getInstance( p_intf )->addRecent( file );
389 case VLCModelSubInterface::ACTION_SAVETOPLAYLIST:
390 THEDP->savePlayingToPlaylist();
393 model->action( action, list );
397 QMenu* StandardPLPanel::viewSelectionMenu( StandardPLPanel *panel )
399 QMenu *viewMenu = new QMenu( qtr( "Playlist View Mode" ) );
400 QSignalMapper *viewSelectionMapper = new QSignalMapper( viewMenu );
401 CONNECT( viewSelectionMapper, mapped( int ), panel, showView( int ) );
403 QActionGroup *viewGroup = new QActionGroup( viewMenu );
404 # define MAX_VIEW StandardPLPanel::VIEW_COUNT
405 for( int i = 0; i < MAX_VIEW; i++ )
407 QAction *action = viewMenu->addAction( viewNames[i] );
408 action->setCheckable( true );
409 viewGroup->addAction( action );
410 viewSelectionMapper->setMapping( action, i );
411 CONNECT( action, triggered(), viewSelectionMapper, map() );
412 if( panel->currentViewIndex() == i )
413 action->setChecked( true );
418 inline QModelIndex popupIndex( QAbstractItemView *view )
420 QModelIndexList list = view->selectionModel()->selectedIndexes();
421 if ( list.isEmpty() )
422 return QModelIndex();
427 void StandardPLPanel::popupSelectColumn( QPoint )
432 /* We do not offer the option to hide index 0 column, or
433 * QTreeView will behave weird */
434 for( int i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
436 QAction* option = menu.addAction( qfu( psz_column_title( i ) ) );
437 option->setCheckable( true );
438 option->setChecked( !treeView->isColumnHidden( j ) );
439 selectColumnsSigMapper->setMapping( option, j );
440 CONNECT( option, triggered(), selectColumnsSigMapper, map() );
442 menu.exec( QCursor::pos() );
445 void StandardPLPanel::toggleColumnShown( int i )
447 treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
450 /* Search in the playlist */
451 void StandardPLPanel::search( const QString& searchText )
456 p_selector->getCurrentItemInfos( &type, &can_search, &name );
458 if( type != SD_TYPE || !can_search )
460 bool flat = ( currentView == iconView ||
461 currentView == listView ||
462 currentView == picFlowView );
463 model->filter( searchText,
464 flat ? currentView->rootIndex() : QModelIndex(),
469 void StandardPLPanel::searchDelayed( const QString& searchText )
474 p_selector->getCurrentItemInfos( &type, &can_search, &name );
476 if( type == SD_TYPE && can_search )
478 if( !name.isEmpty() && !searchText.isEmpty() )
479 playlist_ServicesDiscoveryControl( THEPL, qtu( name ), SD_CMD_SEARCH,
484 /* Set the root of the new Playlist */
485 /* This activated by the selector selection */
486 void StandardPLPanel::setRootItem( playlist_item_t *p_item, bool b )
489 model->rebuild( p_item );
492 void StandardPLPanel::browseInto( const QModelIndex &index )
494 if( currentView == iconView || currentView == listView || currentView == picFlowView )
497 currentView->setRootIndex( index );
499 /* When going toward root in LocationBar, scroll to the item
500 that was previously as root */
501 QModelIndex newIndex = model->indexByPLID(currentRootIndexPLId,0);
502 while( newIndex.isValid() && (newIndex.parent() != index) )
503 newIndex = newIndex.parent();
504 if( newIndex.isValid() )
505 currentView->scrollTo( newIndex );
507 /* Store new rootindexid*/
508 currentRootIndexPLId = model->itemId( index, PLAYLIST_ID );
510 model->ensureArtRequested( index );
513 emit viewChanged( index );
516 void StandardPLPanel::browseInto()
518 browseInto( (currentRootIndexPLId != -1 && currentView != treeView) ?
519 model->indexByPLID( currentRootIndexPLId, 0 ) :
523 void StandardPLPanel::wheelEvent( QWheelEvent *e )
525 if( e->modifiers() & Qt::ControlModifier ) {
526 int numSteps = e->delta() / 8 / 15;
529 else if( numSteps < 0)
532 // Accept this event in order to prevent unwanted volume up/down changes
536 bool StandardPLPanel::eventFilter ( QObject *obj, QEvent * event )
538 if (event->type() == QEvent::KeyPress)
540 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
541 if( keyEvent->key() == Qt::Key_Delete ||
542 keyEvent->key() == Qt::Key_Backspace )
548 else if ( event->type() == QEvent::Paint )
549 {/* Warn! Don't filter events from anything else than views ! */
550 if ( model->rowCount() == 0 && p_selector->getCurrentItemCategory() == PL_ITEM_TYPE )
552 QWidget *viewport = qobject_cast<QWidget *>( obj );
553 QStylePainter painter( viewport );
554 QPixmap dropzone(":/dropzone");
555 QRect rect = viewport->geometry();
556 QSize size = rect.size() / 2 - dropzone.size() / 2;
557 rect.adjust( 0, size.height(), 0 , 0 );
558 painter.drawItemPixmap( rect, Qt::AlignHCenter, dropzone );
559 /* now select the zone just below the drop zone and let Qt center
560 the text by itself */
561 rect.adjust( 0, dropzone.size().height() + 10, 0, 0 );
562 rect.setRight( viewport->geometry().width() );
564 painter.drawItemText( rect,
568 qtr("Playlist is currently empty.\n"
569 "Drop a file here or select a "
570 "media source from the left."),
573 else if ( spinnerAnimation->state() == PixmapAnimator::Running )
575 if ( currentView->model()->rowCount() )
576 spinnerAnimation->stop(); /* Trick until SD emits events */
579 QWidget *viewport = qobject_cast<QWidget *>( obj );
580 QStylePainter painter( viewport );
581 QPixmap *spinner = spinnerAnimation->getPixmap();
582 QPoint point = viewport->geometry().center();
583 point -= QPoint( spinner->size().width() / 2, spinner->size().height() / 2 );
584 painter.drawPixmap( point, *spinner );
591 void StandardPLPanel::deleteSelection()
593 QModelIndexList list = currentView->selectionModel()->selectedIndexes();
594 model->doDelete( list );
597 void StandardPLPanel::createIconView()
599 iconView = new PlIconView( model, this );
600 iconView->setContextMenuPolicy( Qt::CustomContextMenu );
601 CONNECT( iconView, customContextMenuRequested( const QPoint & ),
602 this, popupPlView( const QPoint & ) );
603 CONNECT( iconView, activated( const QModelIndex & ),
604 this, activate( const QModelIndex & ) );
605 iconView->installEventFilter( this );
606 iconView->viewport()->installEventFilter( this );
607 viewStack->addWidget( iconView );
610 void StandardPLPanel::createListView()
612 listView = new PlListView( model, this );
613 listView->setContextMenuPolicy( Qt::CustomContextMenu );
614 CONNECT( listView, customContextMenuRequested( const QPoint & ),
615 this, popupPlView( const QPoint & ) );
616 CONNECT( listView, activated( const QModelIndex & ),
617 this, activate( const QModelIndex & ) );
618 listView->installEventFilter( this );
619 listView->viewport()->installEventFilter( this );
620 viewStack->addWidget( listView );
623 void StandardPLPanel::createCoverView()
625 picFlowView = new PicFlowView( model, this );
626 picFlowView->setContextMenuPolicy( Qt::CustomContextMenu );
627 CONNECT( picFlowView, customContextMenuRequested( const QPoint & ),
628 this, popupPlView( const QPoint & ) );
629 CONNECT( picFlowView, activated( const QModelIndex & ),
630 this, activate( const QModelIndex & ) );
631 viewStack->addWidget( picFlowView );
632 picFlowView->installEventFilter( this );
635 void StandardPLPanel::createTreeView()
637 /* Create and configure the QTreeView */
638 treeView = new PlTreeView( model, this );
640 /* setModel after setSortingEnabled(true), or the model will sort immediately! */
642 /* Connections for the TreeView */
643 CONNECT( treeView, activated( const QModelIndex& ),
644 this, activate( const QModelIndex& ) );
645 CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
646 this, popupSelectColumn( QPoint ) );
647 CONNECT( treeView, customContextMenuRequested( const QPoint & ),
648 this, popupPlView( const QPoint & ) );
649 treeView->installEventFilter( this );
650 treeView->viewport()->installEventFilter( this );
652 /* SignalMapper for columns */
653 selectColumnsSigMapper = new QSignalMapper( this );
654 CONNECT( selectColumnsSigMapper, mapped( int ),
655 this, toggleColumnShown( int ) );
657 viewStack->addWidget( treeView );
660 void StandardPLPanel::updateZoom( int i )
662 if ( i < 5 - QApplication::font().pointSize() ) return;
663 if ( i > 3 + QApplication::font().pointSize() ) return;
665 #define A_ZOOM( view ) \
667 qobject_cast<AbstractPlViewItemDelegate*>( view->itemDelegate() )->setZoom( i_zoom )
668 /* Can't iterate as picflow & tree aren't using custom delegate */
674 void StandardPLPanel::showView( int i_view )
676 bool b_treeViewCreated = false;
682 if( iconView == NULL )
684 currentView = iconView;
689 if( listView == NULL )
691 currentView = listView;
694 case PICTUREFLOW_VIEW:
696 if( picFlowView == NULL )
698 currentView = picFlowView;
704 if( treeView == NULL )
707 b_treeViewCreated = true;
709 currentView = treeView;
714 currentView->setModel( model );
716 /* Restoring the header Columns must come after changeModel */
717 if( b_treeViewCreated )
720 if( getSettings()->contains( "Playlist/headerStateV2" ) )
722 treeView->header()->restoreState(getSettings()
723 ->value( "Playlist/headerStateV2" ).toByteArray() );
724 /* if there is allready stuff in playlist, we don't sort it and we reset
726 if( model->rowCount() )
728 treeView->header()->setSortIndicator( -1 , Qt::AscendingOrder );
733 for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
735 treeView->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
736 if( m == COLUMN_TITLE ) treeView->header()->resizeSection( c, 200 );
737 else if( m == COLUMN_DURATION ) treeView->header()->resizeSection( c, 80 );
742 updateZoom( i_zoom );
743 viewStack->setCurrentWidget( currentView );
748 void StandardPLPanel::setWaiting( bool b )
752 spinnerAnimation->setLoopCount( 20 ); /* Trick until SD emits an event */
753 spinnerAnimation->start();
756 spinnerAnimation->stop();
759 void StandardPLPanel::updateViewport()
761 /* A single update on parent widget won't work */
762 currentView->viewport()->repaint();
765 int StandardPLPanel::currentViewIndex() const
767 if( currentView == treeView )
769 else if( currentView == iconView )
771 else if( currentView == listView )
774 return PICTUREFLOW_VIEW;
777 void StandardPLPanel::cycleViews()
779 if( currentView == iconView )
780 showView( TREE_VIEW );
781 else if( currentView == treeView )
782 showView( LIST_VIEW );
783 else if( currentView == listView )
785 showView( PICTUREFLOW_VIEW );
786 else if( currentView == picFlowView )
788 showView( ICON_VIEW );
793 void StandardPLPanel::activate( const QModelIndex &index )
795 if( currentView->model() == model )
797 /* If we are not a leaf node */
798 if( !index.data( VLCModelSubInterface::IsLeafNodeRole ).toBool() )
800 if( currentView != treeView )
805 playlist_Lock( THEPL );
806 playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index, PLAYLIST_ID ) );
809 p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
810 lastActivatedPLItemId = p_item->i_id;
812 playlist_Unlock( THEPL );
813 if ( p_item && index.isValid() )
814 model->activateItem( index );
819 void StandardPLPanel::browseInto( int i_pl_item_id )
821 if( i_pl_item_id != lastActivatedPLItemId ) return;
823 QModelIndex index = model->indexByPLID( i_pl_item_id, 0 );
825 if( currentView == treeView )
826 treeView->setExpanded( index, true );
830 lastActivatedPLItemId = -1;