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, ":/disc" );
89 ADD_ICON( CDDA, ":/cdda" );
90 ADD_ICON( CARD, ":/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* ) );
105 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
110 Qt::DropActions PLModel::supportedDropActions() const
112 return Qt::CopyAction; /* Why not Qt::MoveAction */
115 Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
117 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
118 if( index.isValid() )
119 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
121 return Qt::ItemIsDropEnabled | defaultFlags;
124 /* A list of model indexes are a playlist */
125 QStringList PLModel::mimeTypes() const
128 types << "vlc/playlist-item-id";
132 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
134 QMimeData *mimeData = new QMimeData();
135 QByteArray encodedData;
136 QDataStream stream( &encodedData, QIODevice::WriteOnly );
138 foreach( const QModelIndex &index, indexes ) {
139 if( index.isValid() && index.column() == 0 )
140 stream << itemId( index );
142 mimeData->setData( "vlc/playlist-item-id", encodedData );
147 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
148 int row, int column, const QModelIndex &target )
150 if( data->hasFormat( "vlc/playlist-item-id" ) )
152 if( action == Qt::IgnoreAction )
155 if( !target.isValid() )
156 /* We don't want to move on an invalid position */
159 PLItem *targetItem = static_cast<PLItem*>( target.internalPointer() );
161 QByteArray encodedData = data->data( "vlc/playlist-item-id" );
162 QDataStream stream( &encodedData, QIODevice::ReadOnly );
164 PLItem *newParentItem;
165 while( !stream.atEnd() )
172 playlist_item_t *p_target =
173 playlist_ItemGetById( p_playlist, targetItem->i_id );
174 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId );
176 if( !p_target || !p_src )
181 if( p_target->i_children == -1 ) /* A leaf */
183 PLItem *parentItem = targetItem->parent();
184 assert( parentItem );
185 playlist_item_t *p_parent =
186 playlist_ItemGetById( p_playlist, parentItem->i_id );
192 for( i = 0 ; i< p_parent->i_children ; i++ )
193 if( p_parent->pp_children[i] == p_target ) break;
194 // Move the item to the element after i
195 playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
196 newParentItem = parentItem;
200 /* \todo: if we drop on a top-level node, use copy instead ? */
201 playlist_TreeMove( p_playlist, p_src, p_target, 0 );
203 newParentItem = targetItem;
207 /*TODO: That's not a good idea to rebuild the playlist */
213 /* remove item with its id */
214 void PLModel::removeItem( int i_id )
216 PLItem *item = FindById( rootItem, i_id );
217 if( item ) item->remove( item );
220 /* callbacks and slots */
221 void PLModel::addCallbacks()
223 /* Some global changes happened -> Rebuild all */
224 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
225 /* We went to the next item
226 var_AddCallback( p_playlist, "item-current", PlaylistNext, this );
228 /* One item has been updated */
229 var_AddCallback( p_playlist, "playlist-item-append", ItemAppended, this );
230 var_AddCallback( p_playlist, "playlist-item-deleted", ItemDeleted, this );
233 void PLModel::delCallbacks()
236 var_DelCallback( p_playlist, "item-current", PlaylistNext, this );
238 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
239 var_DelCallback( p_playlist, "playlist-item-append", ItemAppended, this );
240 var_DelCallback( p_playlist, "playlist-item-deleted", ItemDeleted, this );
243 void PLModel::activateItem( const QModelIndex &index )
245 assert( index.isValid() );
246 PLItem *item = static_cast<PLItem*>(index.internalPointer());
249 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
250 activateItem( p_item );
254 /* Must be entered with lock */
255 void PLModel::activateItem( playlist_item_t *p_item )
257 if( !p_item ) return;
258 playlist_item_t *p_parent = p_item;
261 if( p_parent->i_id == rootItem->i_id ) break;
262 p_parent = p_parent->p_parent;
265 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
269 /****************** Base model mandatory implementations *****************/
270 QVariant PLModel::data( const QModelIndex &index, int role ) const
272 if( !index.isValid() ) return QVariant();
273 PLItem *item = static_cast<PLItem*>(index.internalPointer());
274 if( role == Qt::DisplayRole )
276 return QVariant( item->columnString( index.column() ) );
278 else if( role == Qt::DecorationRole && index.column() == 0 )
280 /* Use to segfault here because i_type wasn't always initialized */
281 if( item->i_type >= 0 )
282 return QVariant( PLModel::icons[item->i_type] );
284 else if( role == Qt::FontRole )
286 if( item->b_current == true )
288 QFont f; f.setBold( true ); return QVariant( f );
294 bool PLModel::isCurrent( const QModelIndex &index )
296 assert( index.isValid() );
297 return static_cast<PLItem*>(index.internalPointer())->b_current;
300 int PLModel::itemId( const QModelIndex &index ) const
302 assert( index.isValid() );
303 return static_cast<PLItem*>(index.internalPointer())->i_id;
306 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
309 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
310 return QVariant( rootItem->columnString( section ) );
314 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
318 if( !parent.isValid() )
319 parentItem = rootItem;
321 parentItem = static_cast<PLItem*>(parent.internalPointer());
323 PLItem *childItem = parentItem->child( row );
325 return createIndex( row, column, childItem );
327 return QModelIndex();
330 /* Return the index of a given item */
331 QModelIndex PLModel::index( PLItem *item, int column ) const
333 if( !item ) return QModelIndex();
334 const PLItem *parent = item->parent();
336 return createIndex( parent->children.lastIndexOf( item ),
338 return QModelIndex();
341 QModelIndex PLModel::parent( const QModelIndex &index ) const
343 if( !index.isValid() ) return QModelIndex();
345 PLItem *childItem = static_cast<PLItem*>(index.internalPointer());
348 msg_Err( p_playlist, "NULL CHILD" );
349 return QModelIndex();
352 PLItem *parentItem = childItem->parent();
353 if( !parentItem || parentItem == rootItem ) return QModelIndex();
354 if( !parentItem->parentItem )
356 msg_Err( p_playlist, "No parent parent, trying row 0 " );
357 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
358 return createIndex( 0, 0, parentItem );
360 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
364 int PLModel::columnCount( const QModelIndex &i) const
366 return rootItem->item_col_strings.count();
369 int PLModel::childrenCount( const QModelIndex &parent ) const
371 return rowCount( parent );
374 int PLModel::rowCount( const QModelIndex &parent ) const
378 if( !parent.isValid() )
379 parentItem = rootItem;
381 parentItem = static_cast<PLItem*>(parent.internalPointer());
383 return parentItem->childCount();
386 QStringList PLModel::selectedURIs()
389 for( int i = 0; i < current_selection.size(); i++ )
392 PLItem *item = static_cast<PLItem*>
393 (current_selection[i].internalPointer());
396 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
399 char *psz = input_item_GetURI( p_item->p_input );
412 /************************* General playlist status ***********************/
414 bool PLModel::hasRandom()
416 return var_GetBool( p_playlist, "random" );
418 bool PLModel::hasRepeat()
420 return var_GetBool( p_playlist, "repeat" );
422 bool PLModel::hasLoop()
424 return var_GetBool( p_playlist, "loop" );
426 void PLModel::setLoop( bool on )
428 var_SetBool( p_playlist, "loop", on ? true:false );
429 config_PutInt( p_playlist, "loop", on ? 1: 0 );
431 void PLModel::setRepeat( bool on )
433 var_SetBool( p_playlist, "repeat", on ? true:false );
434 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
436 void PLModel::setRandom( bool on )
438 var_SetBool( p_playlist, "random", on ? true:false );
439 config_PutInt( p_playlist, "random", on ? 1: 0 );
442 /************************* Lookups *****************************/
444 PLItem *PLModel::FindById( PLItem *root, int i_id )
446 return FindInner( root, i_id, false );
449 PLItem *PLModel::FindByInput( PLItem *root, int i_id )
451 return FindInner( root, i_id, true );
454 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
455 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
457 PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
459 if( ( !b_input && i_cached_id == i_id) ||
460 ( b_input && i_cached_input_id ==i_id ) )
462 return b_input ? p_cached_item_bi : p_cached_item;
465 if( !b_input && root->i_id == i_id )
470 else if( b_input && root->i_input_id == i_id )
472 ICACHE( i_id, root );
476 QList<PLItem *>::iterator it = root->children.begin();
477 while ( it != root->children.end() )
479 if( !b_input && (*it)->i_id == i_id )
481 CACHE( i_id, (*it) );
482 return p_cached_item;
484 else if( b_input && (*it)->i_input_id == i_id )
486 ICACHE( i_id, (*it) );
487 return p_cached_item_bi;
489 if( (*it)->children.size() )
491 PLItem *childFound = FindInner( (*it), i_id, b_input );
495 ICACHE( i_id, childFound )
497 CACHE( i_id, childFound )
509 /************************* Updates handling *****************************/
510 void PLModel::customEvent( QEvent *event )
512 int type = event->type();
513 if( type != ItemAppend_Type &&
514 type != ItemDelete_Type && type != PLUpdate_Type )
517 PLEvent *ple = static_cast<PLEvent *>(event);
519 if( type == ItemAppend_Type )
520 ProcessItemAppend( &ple->add );
521 else if( type == ItemDelete_Type )
522 ProcessItemRemoval( ple->i_id );
527 /**** Events processing ****/
528 void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
530 if( !p_input ) return;
531 ProcessInputItemUpdate( input_GetItem( p_input )->i_id );
533 void PLModel::ProcessInputItemUpdate( int i_input_id )
535 if( i_input_id <= 0 ) return;
536 PLItem *item = FindByInput( rootItem, i_input_id );
540 UpdateTreeItem( item, true );
545 void PLModel::ProcessItemRemoval( int i_id )
547 if( i_id <= 0 ) return;
548 if( i_id == i_cached_id ) i_cached_id = -1;
549 i_cached_input_id = -1;
554 void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
556 playlist_item_t *p_item = NULL;
557 PLItem *newItem = NULL;
559 PLItem *nodeItem = FindById( rootItem, p_add->i_node );
561 if( !nodeItem ) goto end;
563 p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
564 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
565 if( i_depth == DEPTH_SEL && p_item->p_parent &&
566 p_item->p_parent->i_id != rootItem->i_id )
569 newItem = new PLItem( p_item, nodeItem, this );
570 nodeItem->appendChild( newItem );
571 UpdateTreeItem( p_item, newItem, true );
578 void PLModel::rebuild()
583 void PLModel::rebuild( playlist_item_t *p_root )
585 playlist_item_t* p_item;
586 /* Remove callbacks before locking to avoid deadlocks */
588 /* Invalidate cache */
589 i_cached_id = i_cached_input_id = -1;
595 if( rootItem->children.size() )
597 beginRemoveRows( index( rootItem, 0 ), 0,
598 rootItem->children.size() -1 );
599 qDeleteAll( rootItem->children );
600 rootItem->children.clear();
607 rootItem = new PLItem( p_root, getSettings(), this );
610 /* Recreate from root */
611 UpdateNodeChildren( rootItem );
612 if( (p_item = playlist_CurrentPlayingItem(p_playlist)) )
614 PLItem *currentItem = FindByInput( rootItem,
615 p_item->p_input->i_id );
618 UpdateTreeItem( p_item, currentItem,
624 /* And signal the view */
625 emit layoutChanged();
629 /* This function must be entered WITH the playlist lock */
630 void PLModel::UpdateNodeChildren( PLItem *root )
632 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
633 UpdateNodeChildren( p_node, root );
636 /* This function must be entered WITH the playlist lock */
637 void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
639 for( int i = 0; i < p_node->i_children ; i++ )
641 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
642 PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
643 root->appendChild( newItem, false );
644 UpdateTreeItem( newItem, false, true );
645 if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
646 UpdateNodeChildren( p_node->pp_children[i], newItem );
650 /* This function must be entered WITH the playlist lock */
651 void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
653 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
654 UpdateTreeItem( p_item, item, signal, force );
657 /* This function must be entered WITH the playlist lock */
658 void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
659 bool signal, bool force )
663 if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
664 p_item->p_parent->i_id != rootItem->i_id )
666 item->update( p_item, p_item == playlist_CurrentPlayingItem( p_playlist ) );
668 emit dataChanged( index( item, 0 ) , index( item, 1 ) );
671 /************************* Actions ******************************/
674 * Deletion, here we have to do a ugly slow hack as we retrieve the full
675 * list of indexes to delete at once: when we delete a node and all of
676 * its children, we need to update the list.
677 * Todo: investigate whethere we can use ranges to be sure to delete all items?
679 void PLModel::doDelete( QModelIndexList selected )
681 for( int i = selected.size() -1 ; i >= 0; i-- )
683 QModelIndex index = selected[i];
684 if( index.column() != 0 ) continue;
685 PLItem *item = static_cast<PLItem*>(index.internalPointer());
688 if( item->children.size() )
689 recurseDelete( item->children, &selected );
690 doDeleteItem( item, &selected );
695 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
697 for( int i = children.size() - 1; i >= 0 ; i-- )
699 PLItem *item = children[i];
700 if( item->children.size() )
701 recurseDelete( item->children, fullList );
702 doDeleteItem( item, fullList );
706 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
708 QModelIndex deleteIndex = index( item, 0 );
709 fullList->removeAll( deleteIndex );
712 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
718 if( p_item->i_children == -1 )
719 playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
721 playlist_NodeDelete( p_playlist, p_item, true, false );
722 /* And finally, remove it from the tree */
723 item->remove( item );
727 /******* Volume III: Sorting and searching ********/
728 void PLModel::sort( int column, Qt::SortOrder order )
734 for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
736 if( ( shownFlags() & i_column ) )
738 if( column == i_index )
749 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
751 if( p_root && i_flag )
753 playlist_RecursiveNodeSort( p_playlist, p_root,
754 i_column_sorting( i_flag ),
755 order == Qt::AscendingOrder ?
756 ORDER_NORMAL : ORDER_REVERSE );
763 void PLModel::search( const QString& search_text )
765 /** \todo Fire the search with a small delay ? */
768 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
771 const char *psz_name = search_text.toUtf8().data();
772 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
778 /*********** Popup *********/
779 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
781 assert( index.isValid() );
783 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, itemId( index ) );
786 i_popup_item = p_item->i_id;
787 i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
789 current_selection = list;
790 QMenu *menu = new QMenu;
791 menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
792 menu->addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
793 menu->addSeparator();
794 menu->addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
795 menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
796 menu->addSeparator();
797 menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
798 if( p_item->i_children > -1 )
800 menu->addSeparator();
801 menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
802 menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAdd() ) );
804 menu->addSeparator();
805 menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
806 menu->popup( point );
813 void PLModel::viewchanged( int meta )
826 /* UNUSED emit layoutAboutToBeChanged(); */
827 index = __MIN( index, rootItem->item_col_strings.count() );
828 QModelIndex parent = createIndex( 0, 0, rootItem );
830 if( rootItem->i_showflags & meta )
831 /* Removing columns */
833 beginRemoveColumns( parent, index, index+1 );
834 rootItem->i_showflags &= ~( meta );
835 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
836 rootItem->updateColumnHeaders();
842 beginInsertColumns( parent, index, index+1 );
843 rootItem->i_showflags |= meta;
844 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
845 rootItem->updateColumnHeaders();
852 void PLModel::popupDel()
854 doDelete( current_selection );
857 void PLModel::popupPlay()
861 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
863 activateItem( p_item );
868 void PLModel::popupInfo()
871 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
875 input_item_t* p_input = p_item->p_input;
876 vlc_gc_incref( p_input );
878 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
879 vlc_gc_decref( p_input );
880 mid->setParent( PlaylistDialog::getInstance( p_intf ),
886 void PLModel::popupStream()
888 QStringList mrls = selectedURIs();
889 if( !mrls.isEmpty() )
890 THEDP->streamingDialog( NULL, mrls[0], false );
894 void PLModel::popupSave()
896 QStringList mrls = selectedURIs();
897 if( !mrls.isEmpty() )
898 THEDP->streamingDialog( NULL, mrls[0] );
903 #include <QDesktopServices>
904 void PLModel::popupExplore()
907 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
911 input_item_t *p_input = p_item->p_input;
912 char *psz_meta = input_item_GetURI( p_input );
916 const char *psz_access;
917 const char *psz_demux;
919 input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
921 if( EMPTY_STR( psz_access ) ||
922 !strncasecmp( psz_access, "file", 4 ) ||
923 !strncasecmp( psz_access, "dire", 4 ) )
925 QFileInfo info( qfu( psz_meta ) );
926 QDesktopServices::openUrl(
927 QUrl::fromLocalFile( info.absolutePath() ) );
936 /**********************************************************************
938 **********************************************************************/
939 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
940 vlc_value_t oval, vlc_value_t nval, void *param )
942 PLModel *p_model = (PLModel *) param;
943 PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
944 QApplication::postEvent( p_model, event );
948 static int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
949 vlc_value_t oval, vlc_value_t nval, void *param )
951 PLModel *p_model = (PLModel *) param;
952 PLEvent *event = new PLEvent( ItemUpdate_Type, oval.i_int );
953 QApplication::postEvent( p_model, event );
954 event = new PLEvent( ItemUpdate_Type, nval.i_int );
955 QApplication::postEvent( p_model, event );
959 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
960 vlc_value_t oval, vlc_value_t nval, void *param )
962 PLModel *p_model = (PLModel *) param;
963 PLEvent *event = new PLEvent( ItemDelete_Type, nval.i_int );
964 QApplication::postEvent( p_model, event );
968 static int ItemAppended( 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 const playlist_add_t *p_add = (playlist_add_t *)nval.p_address;
973 PLEvent *event = new PLEvent( p_add );
974 QApplication::postEvent( p_model, event );