1 /*****************************************************************************
2 * playlist_model.cpp : Manage playlist model
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
29 #include "dialogs_provider.hpp"
30 #include "components/playlist/playlist_model.hpp"
31 #include "dialogs/mediainfo.hpp"
32 #include "dialogs/playlist.hpp"
33 #include <vlc_intf_strings.h>
35 #include "pixmaps/types/type_unknown.xpm"
41 #include <QApplication>
46 QIcon PLModel::icons[ITEM_TYPE_NUMBER];
48 static int PlaylistChanged( vlc_object_t *, const char *,
49 vlc_value_t, vlc_value_t, void * );
50 static int PlaylistNext( vlc_object_t *, const char *,
51 vlc_value_t, vlc_value_t, void * );
52 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
53 vlc_value_t oval, vlc_value_t nval, void *param );
54 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
55 vlc_value_t oval, vlc_value_t nval, void *param );
57 /*************************************************************************
58 * Playlist model implementation
59 *************************************************************************/
62 This model is called two times, for the selector and the standard panel
64 PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
65 intf_thread_t *_p_intf, /* main Qt p_intf */
66 playlist_item_t * p_root,
67 /*playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
68 and THEPL->p_root_category for SelectPL */
69 int _i_depth, /* -1 for StandPL, 1 for SelectPL */
70 QObject *parent ) /* Basic Qt parent */
71 : QAbstractItemModel( parent )
74 assert( i_depth == DEPTH_SEL || i_depth == DEPTH_PL );
76 p_playlist = _p_playlist;
78 i_cached_input_id = -1;
79 i_popup_item = i_popup_parent = -1;
81 rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
83 /* Icons initialization */
84 #define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( QPixmap( x ) )
85 ADD_ICON( UNKNOWN , type_unknown_xpm );
86 ADD_ICON( FILE, ":/type/file" );
87 ADD_ICON( DIRECTORY, ":/type/directory" );
88 ADD_ICON( DISC, ":/type/disc" );
89 ADD_ICON( CDDA, ":/type/cdda" );
90 ADD_ICON( CARD, ":/type/capture-card" );
91 ADD_ICON( NET, ":/type/net" );
92 ADD_ICON( PLAYLIST, ":/type/playlist" );
93 ADD_ICON( NODE, ":/type/node" );
97 CONNECT( THEMIM->getIM(), metaChanged( int ),
98 this, ProcessInputItemUpdate( int ) );
99 CONNECT( THEMIM, inputChanged( input_thread_t * ),
100 this, ProcessInputItemUpdate( input_thread_t* ) );
106 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
111 Qt::DropActions PLModel::supportedDropActions() const
113 return Qt::CopyAction; /* Why not Qt::MoveAction */
116 Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
118 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
119 if( index.isValid() )
120 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
122 return Qt::ItemIsDropEnabled | defaultFlags;
125 /* A list of model indexes are a playlist */
126 QStringList PLModel::mimeTypes() const
129 types << "vlc/playlist-item-id";
133 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
135 QMimeData *mimeData = new QMimeData();
136 QByteArray encodedData;
137 QDataStream stream( &encodedData, QIODevice::WriteOnly );
138 QModelIndexList list;
140 foreach( const QModelIndex &index, indexes ) {
141 if( index.isValid() && index.column() == 0 )
147 foreach( const QModelIndex &index, list ) {
148 stream << itemId( index );
150 mimeData->setData( "vlc/playlist-item-id", encodedData );
155 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
156 int row, int column, const QModelIndex &parent )
158 if( data->hasFormat( "vlc/playlist-item-id" ) )
160 if( action == Qt::IgnoreAction )
165 playlist_item_t *p_parent;
167 if( !parent.isValid())
171 // dropped into top node
172 p_parent = playlist_ItemGetById( p_playlist, rootItem->i_id );
176 // dropped outside any item
183 // dropped into/onto an item (depends on (row = -1) or (row > -1))
184 p_parent = playlist_ItemGetById( p_playlist, itemId ( parent ) );
186 if( !p_parent || p_parent->i_children == -1 )
192 QByteArray encodedData = data->data( "vlc/playlist-item-id" );
193 QDataStream stream( &encodedData, QIODevice::ReadOnly );
195 /* easiest way to never miss the right index to move to is to
196 track the previously moved item */
197 playlist_item_t *p_target = NULL;
199 while( !stream.atEnd() )
203 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, src_id );
214 playlist_TreeMove( p_playlist, p_src, p_parent, 0 );
217 playlist_TreeMove( p_playlist, p_src, p_parent, row );
223 for( i = 0 ; i< p_parent->i_children ; i++ )
224 if( p_parent->pp_children[i] == p_target ) break;
225 playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
230 /*TODO: That's not a good idea to rebuild the playlist */
236 /* remove item with its id */
237 void PLModel::removeItem( int i_id )
239 PLItem *item = FindById( rootItem, i_id );
240 if( item ) item->remove( item );
243 /* callbacks and slots */
244 void PLModel::addCallbacks()
246 /* Some global changes happened -> Rebuild all */
247 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
248 /* We went to the next item
249 var_AddCallback( p_playlist, "item-current", PlaylistNext, this );
251 /* One item has been updated */
252 var_AddCallback( p_playlist, "playlist-item-append", ItemAppended, this );
253 var_AddCallback( p_playlist, "playlist-item-deleted", ItemDeleted, this );
256 void PLModel::delCallbacks()
259 var_DelCallback( p_playlist, "item-current", PlaylistNext, this );
261 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
262 var_DelCallback( p_playlist, "playlist-item-append", ItemAppended, this );
263 var_DelCallback( p_playlist, "playlist-item-deleted", ItemDeleted, this );
266 void PLModel::activateItem( const QModelIndex &index )
268 assert( index.isValid() );
269 PLItem *item = static_cast<PLItem*>(index.internalPointer());
272 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
273 activateItem( p_item );
277 /* Must be entered with lock */
278 void PLModel::activateItem( playlist_item_t *p_item )
280 if( !p_item ) return;
281 playlist_item_t *p_parent = p_item;
284 if( p_parent->i_id == rootItem->i_id ) break;
285 p_parent = p_parent->p_parent;
288 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
292 /****************** Base model mandatory implementations *****************/
293 QVariant PLModel::data( const QModelIndex &index, int role ) const
295 if( !index.isValid() ) return QVariant();
296 PLItem *item = static_cast<PLItem*>(index.internalPointer());
297 if( role == Qt::DisplayRole )
299 return QVariant( item->columnString( index.column() ) );
301 else if( role == Qt::DecorationRole && index.column() == 0 )
303 /* Use to segfault here because i_type wasn't always initialized */
304 if( item->i_type >= 0 )
305 return QVariant( PLModel::icons[item->i_type] );
307 else if( role == Qt::FontRole )
309 if( item->b_current == true )
311 QFont f; f.setBold( true ); return QVariant( f );
317 bool PLModel::isCurrent( const QModelIndex &index )
319 assert( index.isValid() );
320 return static_cast<PLItem*>(index.internalPointer())->b_current;
323 int PLModel::itemId( const QModelIndex &index ) const
325 assert( index.isValid() );
326 return static_cast<PLItem*>(index.internalPointer())->i_id;
329 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
332 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
333 return QVariant( rootItem->columnString( section ) );
337 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
341 if( !parent.isValid() )
342 parentItem = rootItem;
344 parentItem = static_cast<PLItem*>(parent.internalPointer());
346 PLItem *childItem = parentItem->child( row );
348 return createIndex( row, column, childItem );
350 return QModelIndex();
353 /* Return the index of a given item */
354 QModelIndex PLModel::index( PLItem *item, int column ) const
356 if( !item ) return QModelIndex();
357 const PLItem *parent = item->parent();
359 return createIndex( parent->children.lastIndexOf( item ),
361 return QModelIndex();
364 QModelIndex PLModel::parent( const QModelIndex &index ) const
366 if( !index.isValid() ) return QModelIndex();
368 PLItem *childItem = static_cast<PLItem*>(index.internalPointer());
371 msg_Err( p_playlist, "NULL CHILD" );
372 return QModelIndex();
375 PLItem *parentItem = childItem->parent();
376 if( !parentItem || parentItem == rootItem ) return QModelIndex();
377 if( !parentItem->parentItem )
379 msg_Err( p_playlist, "No parent parent, trying row 0 " );
380 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
381 return createIndex( 0, 0, parentItem );
383 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
387 int PLModel::columnCount( const QModelIndex &i) const
389 return rootItem->item_col_strings.count();
392 int PLModel::childrenCount( const QModelIndex &parent ) const
394 return rowCount( parent );
397 int PLModel::rowCount( const QModelIndex &parent ) const
401 if( !parent.isValid() )
402 parentItem = rootItem;
404 parentItem = static_cast<PLItem*>(parent.internalPointer());
406 return parentItem->childCount();
409 QStringList PLModel::selectedURIs()
412 for( int i = 0; i < current_selection.size(); i++ )
415 PLItem *item = static_cast<PLItem*>
416 (current_selection[i].internalPointer());
419 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
422 char *psz = input_item_GetURI( p_item->p_input );
435 /************************* General playlist status ***********************/
437 bool PLModel::hasRandom()
439 return var_GetBool( p_playlist, "random" );
441 bool PLModel::hasRepeat()
443 return var_GetBool( p_playlist, "repeat" );
445 bool PLModel::hasLoop()
447 return var_GetBool( p_playlist, "loop" );
449 void PLModel::setLoop( bool on )
451 var_SetBool( p_playlist, "loop", on ? true:false );
452 config_PutInt( p_playlist, "loop", on ? 1: 0 );
454 void PLModel::setRepeat( bool on )
456 var_SetBool( p_playlist, "repeat", on ? true:false );
457 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
459 void PLModel::setRandom( bool on )
461 var_SetBool( p_playlist, "random", on ? true:false );
462 config_PutInt( p_playlist, "random", on ? 1: 0 );
465 /************************* Lookups *****************************/
467 PLItem *PLModel::FindById( PLItem *root, int i_id )
469 return FindInner( root, i_id, false );
472 PLItem *PLModel::FindByInput( PLItem *root, int i_id )
474 return FindInner( root, i_id, true );
477 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
478 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
480 PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
482 if( ( !b_input && i_cached_id == i_id) ||
483 ( b_input && i_cached_input_id ==i_id ) )
485 return b_input ? p_cached_item_bi : p_cached_item;
488 if( !b_input && root->i_id == i_id )
493 else if( b_input && root->i_input_id == i_id )
495 ICACHE( i_id, root );
499 QList<PLItem *>::iterator it = root->children.begin();
500 while ( it != root->children.end() )
502 if( !b_input && (*it)->i_id == i_id )
504 CACHE( i_id, (*it) );
505 return p_cached_item;
507 else if( b_input && (*it)->i_input_id == i_id )
509 ICACHE( i_id, (*it) );
510 return p_cached_item_bi;
512 if( (*it)->children.size() )
514 PLItem *childFound = FindInner( (*it), i_id, b_input );
518 ICACHE( i_id, childFound )
520 CACHE( i_id, childFound )
532 /************************* Updates handling *****************************/
533 void PLModel::customEvent( QEvent *event )
535 int type = event->type();
536 if( type != ItemAppend_Type &&
537 type != ItemDelete_Type && type != PLUpdate_Type )
540 PLEvent *ple = static_cast<PLEvent *>(event);
542 if( type == ItemAppend_Type )
543 ProcessItemAppend( &ple->add );
544 else if( type == ItemDelete_Type )
545 ProcessItemRemoval( ple->i_id );
550 /**** Events processing ****/
551 void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
553 if( !p_input ) return;
554 ProcessInputItemUpdate( input_GetItem( p_input )->i_id );
555 if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
557 PLItem *item = FindByInput( rootItem, input_GetItem( p_input )->i_id );
558 emit currentChanged( index( item, 0 ) );
561 void PLModel::ProcessInputItemUpdate( int i_input_id )
563 if( i_input_id <= 0 ) return;
564 PLItem *item = FindByInput( rootItem, i_input_id );
568 UpdateTreeItem( item, true );
573 void PLModel::ProcessItemRemoval( int i_id )
575 if( i_id <= 0 ) return;
576 if( i_id == i_cached_id ) i_cached_id = -1;
577 i_cached_input_id = -1;
582 void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
584 playlist_item_t *p_item = NULL;
585 PLItem *newItem = NULL;
587 PLItem *nodeItem = FindById( rootItem, p_add->i_node );
589 if( !nodeItem ) goto end;
591 p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
592 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
593 if( i_depth == DEPTH_SEL && p_item->p_parent &&
594 p_item->p_parent->i_id != rootItem->i_id )
597 newItem = new PLItem( p_item, nodeItem, this );
598 nodeItem->appendChild( newItem );
599 UpdateTreeItem( p_item, newItem, true );
606 void PLModel::rebuild()
611 void PLModel::rebuild( playlist_item_t *p_root )
613 playlist_item_t* p_item;
614 /* Remove callbacks before locking to avoid deadlocks */
616 /* Invalidate cache */
617 i_cached_id = i_cached_input_id = -1;
623 if( rootItem->children.size() )
625 beginRemoveRows( index( rootItem, 0 ), 0,
626 rootItem->children.size() -1 );
627 qDeleteAll( rootItem->children );
628 rootItem->children.clear();
635 rootItem = new PLItem( p_root, getSettings(), this );
638 /* Recreate from root */
639 UpdateNodeChildren( rootItem );
640 if( (p_item = playlist_CurrentPlayingItem(p_playlist)) )
642 PLItem *currentItem = FindByInput( rootItem,
643 p_item->p_input->i_id );
646 UpdateTreeItem( p_item, currentItem,
652 /* And signal the view */
653 emit layoutChanged();
657 /* This function must be entered WITH the playlist lock */
658 void PLModel::UpdateNodeChildren( PLItem *root )
660 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
661 UpdateNodeChildren( p_node, root );
664 /* This function must be entered WITH the playlist lock */
665 void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
667 for( int i = 0; i < p_node->i_children ; i++ )
669 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
670 PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
671 root->appendChild( newItem, false );
672 UpdateTreeItem( newItem, false, true );
673 if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
674 UpdateNodeChildren( p_node->pp_children[i], newItem );
678 /* This function must be entered WITH the playlist lock */
679 void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
681 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
682 UpdateTreeItem( p_item, item, signal, force );
685 /* This function must be entered WITH the playlist lock */
686 void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
687 bool signal, bool force )
691 if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
692 p_item->p_parent->i_id != rootItem->i_id )
694 item->update( p_item, p_item == playlist_CurrentPlayingItem( p_playlist ) );
696 emit dataChanged( index( item, 0 ) , index( item, 1 ) );
699 /************************* Actions ******************************/
702 * Deletion, here we have to do a ugly slow hack as we retrieve the full
703 * list of indexes to delete at once: when we delete a node and all of
704 * its children, we need to update the list.
705 * Todo: investigate whethere we can use ranges to be sure to delete all items?
707 void PLModel::doDelete( QModelIndexList selected )
709 for( int i = selected.size() -1 ; i >= 0; i-- )
711 QModelIndex index = selected[i];
712 if( index.column() != 0 ) continue;
713 PLItem *item = static_cast<PLItem*>(index.internalPointer());
716 if( item->children.size() )
717 recurseDelete( item->children, &selected );
718 doDeleteItem( item, &selected );
723 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
725 for( int i = children.size() - 1; i >= 0 ; i-- )
727 PLItem *item = children[i];
728 if( item->children.size() )
729 recurseDelete( item->children, fullList );
730 doDeleteItem( item, fullList );
734 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
736 QModelIndex deleteIndex = index( item, 0 );
737 fullList->removeAll( deleteIndex );
740 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
746 if( p_item->i_children == -1 )
747 playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
749 playlist_NodeDelete( p_playlist, p_item, true, false );
750 /* And finally, remove it from the tree */
751 item->remove( item );
755 /******* Volume III: Sorting and searching ********/
756 void PLModel::sort( int column, Qt::SortOrder order )
762 for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
764 if( ( shownFlags() & i_column ) )
766 if( column == i_index )
777 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
779 if( p_root && i_flag )
781 playlist_RecursiveNodeSort( p_playlist, p_root,
782 i_column_sorting( i_flag ),
783 order == Qt::AscendingOrder ?
784 ORDER_NORMAL : ORDER_REVERSE );
791 void PLModel::search( const QString& search_text )
793 /** \todo Fire the search with a small delay ? */
796 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
799 const char *psz_name = search_text.toUtf8().data();
800 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
806 /*********** Popup *********/
807 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
809 assert( index.isValid() );
811 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, itemId( index ) );
814 i_popup_item = p_item->i_id;
815 i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
817 current_selection = list;
818 QMenu *menu = new QMenu;
819 menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
820 menu->addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
821 menu->addSeparator();
822 menu->addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
823 menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
824 menu->addSeparator();
825 menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
826 if( p_item->i_children > -1 )
828 menu->addSeparator();
829 menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
830 menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAdd() ) );
832 menu->addSeparator();
833 menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
834 menu->popup( point );
841 void PLModel::viewchanged( int meta )
854 /* UNUSED emit layoutAboutToBeChanged(); */
855 index = __MIN( index, rootItem->item_col_strings.count() );
856 QModelIndex parent = createIndex( 0, 0, rootItem );
858 if( rootItem->i_showflags & meta )
859 /* Removing columns */
861 beginRemoveColumns( parent, index, index+1 );
862 rootItem->i_showflags &= ~( meta );
863 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
864 rootItem->updateColumnHeaders();
870 beginInsertColumns( parent, index, index+1 );
871 rootItem->i_showflags |= meta;
872 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
873 rootItem->updateColumnHeaders();
876 emit columnsChanged( meta );
881 void PLModel::popupDel()
883 doDelete( current_selection );
886 void PLModel::popupPlay()
890 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
892 activateItem( p_item );
897 void PLModel::popupInfo()
900 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
904 input_item_t* p_input = p_item->p_input;
905 vlc_gc_incref( p_input );
907 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
908 vlc_gc_decref( p_input );
909 mid->setParent( PlaylistDialog::getInstance( p_intf ),
915 void PLModel::popupStream()
917 QStringList mrls = selectedURIs();
918 if( !mrls.isEmpty() )
919 THEDP->streamingDialog( NULL, mrls[0], false );
923 void PLModel::popupSave()
925 QStringList mrls = selectedURIs();
926 if( !mrls.isEmpty() )
927 THEDP->streamingDialog( NULL, mrls[0] );
932 #include <QDesktopServices>
933 void PLModel::popupExplore()
936 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
940 input_item_t *p_input = p_item->p_input;
941 char *psz_meta = input_item_GetURI( p_input );
945 const char *psz_access;
946 const char *psz_demux;
948 input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
950 if( EMPTY_STR( psz_access ) ||
951 !strncasecmp( psz_access, "file", 4 ) ||
952 !strncasecmp( psz_access, "dire", 4 ) )
954 QFileInfo info( qfu( psz_meta ) );
955 QDesktopServices::openUrl(
956 QUrl::fromLocalFile( info.absolutePath() ) );
965 /**********************************************************************
967 **********************************************************************/
968 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
969 vlc_value_t oval, vlc_value_t nval, void *param )
971 PLModel *p_model = (PLModel *) param;
972 PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
973 QApplication::postEvent( p_model, event );
977 static int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
978 vlc_value_t oval, vlc_value_t nval, void *param )
980 PLModel *p_model = (PLModel *) param;
981 PLEvent *event = new PLEvent( ItemUpdate_Type, oval.i_int );
982 QApplication::postEvent( p_model, event );
983 event = new PLEvent( ItemUpdate_Type, nval.i_int );
984 QApplication::postEvent( p_model, event );
988 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
989 vlc_value_t oval, vlc_value_t nval, void *param )
991 PLModel *p_model = (PLModel *) param;
992 PLEvent *event = new PLEvent( ItemDelete_Type, nval.i_int );
993 QApplication::postEvent( p_model, event );
997 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
998 vlc_value_t oval, vlc_value_t nval, void *param )
1000 PLModel *p_model = (PLModel *) param;
1001 const playlist_add_t *p_add = (playlist_add_t *)nval.p_address;
1002 PLEvent *event = new PLEvent( p_add );
1003 QApplication::postEvent( p_model, event );