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 "components/playlist/playlist_model.hpp"
30 #include "dialogs/mediainfo.hpp"
31 #include <vlc_intf_strings.h>
33 #include "pixmaps/type_unknown.xpm"
39 #include <QApplication>
44 QIcon PLModel::icons[ITEM_TYPE_NUMBER];
46 static int PlaylistChanged( vlc_object_t *, const char *,
47 vlc_value_t, vlc_value_t, void * );
48 static int PlaylistNext( vlc_object_t *, const char *,
49 vlc_value_t, vlc_value_t, void * );
50 static int ItemChanged( 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, ":/pixmaps/type_file.png" );
87 ADD_ICON( DIRECTORY, ":/pixmaps/type_directory.png" );
88 ADD_ICON( DISC, ":/pixmaps/disc_16px.png" );
89 ADD_ICON( CDDA, ":/pixmaps/cdda_16px.png" );
90 ADD_ICON( CARD, ":/pixmaps/capture-card_16px.png" );
91 ADD_ICON( NET, ":/pixmaps/type_net.png" );
92 ADD_ICON( PLAYLIST, ":/pixmaps/type_playlist.png" );
93 ADD_ICON( NODE, ":/pixmaps/type_node.png" );
101 QSettings settings( "vlc", "vlc-qt-interface" );
102 settings.setValue( "qt-pl-showflags", rootItem->i_showflags );
107 Qt::DropActions PLModel::supportedDropActions() const
109 return Qt::CopyAction; /* Why not Qt::MoveAction */
112 Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
114 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
115 if( index.isValid() )
116 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
118 return Qt::ItemIsDropEnabled | defaultFlags;
121 /* A list of model indexes are a playlist */
122 QStringList PLModel::mimeTypes() const
125 types << "vlc/playlist-item-id";
129 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
131 QMimeData *mimeData = new QMimeData();
132 QByteArray encodedData;
133 QDataStream stream( &encodedData, QIODevice::WriteOnly );
135 foreach( QModelIndex index, indexes ) {
136 if( index.isValid() && index.column() == 0 )
137 stream << itemId( index );
139 mimeData->setData( "vlc/playlist-item-id", encodedData );
144 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
145 int row, int column, const QModelIndex &target )
147 if( data->hasFormat( "vlc/playlist-item-id" ) )
149 if( action == Qt::IgnoreAction )
153 if( target.isValid() )
154 targetItem = static_cast<PLItem*>( target.internalPointer() );
156 targetItem = rootItem;
158 QByteArray encodedData = data->data( "vlc/playlist-item-id" );
159 QDataStream stream( &encodedData, QIODevice::ReadOnly );
161 PLItem *newParentItem;
162 while( !stream.atEnd() )
169 playlist_item_t *p_target =
170 playlist_ItemGetById( p_playlist, targetItem->i_id,
172 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId,
175 if( !p_target || !p_src )
180 if( p_target->i_children == -1 ) /* A leaf */
182 PLItem *parentItem = targetItem->parent();
183 assert( parentItem );
184 playlist_item_t *p_parent =
185 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 playlist_TreeMove( p_playlist, p_src, p_parent, i );
195 newParentItem = parentItem;
199 /* \todo: if we drop on a top-level node, use copy instead ? */
200 playlist_TreeMove( p_playlist, p_src, p_target, 0 );
202 newParentItem = targetItem;
204 /* Remove from source */
205 PLItem *srcItem = FindById( rootItem, p_src->i_id );
206 // We dropped on the source selector. Ask the dialog to forward
210 emit shouldRemove( p_src->i_id );
213 srcItem->remove( srcItem );
215 /* Display at new destination */
216 PLItem *newItem = new PLItem( p_src, newParentItem, this );
217 newParentItem->insertChild( newItem, i, true );
218 UpdateTreeItem( p_src, newItem, true );
219 if( p_src->i_children != -1 )
220 UpdateNodeChildren( newItem );
227 /* remove item with its id */
228 void PLModel::removeItem( int i_id )
230 PLItem *item = FindById( rootItem, i_id );
231 if( item ) item->remove( item );
234 /* callbacks and slots */
235 void PLModel::addCallbacks()
237 /* Some global changes happened -> Rebuild all */
238 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
239 /* We went to the next item */
240 var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );
241 /* One item has been updated */
242 var_AddCallback( p_playlist, "item-change", ItemChanged, this );
243 var_AddCallback( p_playlist, "item-append", ItemAppended, this );
244 var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
247 void PLModel::delCallbacks()
249 var_DelCallback( p_playlist, "item-change", ItemChanged, this );
250 var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
251 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
252 var_DelCallback( p_playlist, "item-append", ItemAppended, this );
253 var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
256 void PLModel::activateItem( const QModelIndex &index )
258 assert( index.isValid() );
259 PLItem *item = static_cast<PLItem*>(index.internalPointer());
262 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
264 activateItem( p_item );
268 /* Must be entered with lock */
269 void PLModel::activateItem( playlist_item_t *p_item )
271 if( !p_item ) return;
272 playlist_item_t *p_parent = p_item;
275 if( p_parent->i_id == rootItem->i_id ) break;
276 p_parent = p_parent->p_parent;
279 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true,
283 /****************** Base model mandatory implementations *****************/
284 QVariant PLModel::data( const QModelIndex &index, int role ) const
286 if( !index.isValid() ) return QVariant();
287 PLItem *item = static_cast<PLItem*>(index.internalPointer());
288 if( role == Qt::DisplayRole )
290 return QVariant( item->columnString( index.column() ) );
292 else if( role == Qt::DecorationRole && index.column() == 0 )
294 /* Use to segfault here because i_type wasn't always initialized */
295 if( item->i_type >= 0 )
296 return QVariant( PLModel::icons[item->i_type] );
298 else if( role == Qt::FontRole )
300 if( item->b_current == true )
302 QFont f; f.setBold( true ); return QVariant( f );
308 bool PLModel::isCurrent( const QModelIndex &index )
310 assert( index.isValid() );
311 return static_cast<PLItem*>(index.internalPointer())->b_current;
314 int PLModel::itemId( const QModelIndex &index ) const
316 assert( index.isValid() );
317 return static_cast<PLItem*>(index.internalPointer())->i_id;
320 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
323 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
324 return QVariant( rootItem->columnString( section ) );
328 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
332 if( !parent.isValid() )
333 parentItem = rootItem;
335 parentItem = static_cast<PLItem*>(parent.internalPointer());
337 PLItem *childItem = parentItem->child( row );
339 return createIndex( row, column, childItem );
341 return QModelIndex();
344 /* Return the index of a given item */
345 QModelIndex PLModel::index( PLItem *item, int column ) const
347 if( !item ) return QModelIndex();
348 const PLItem *parent = item->parent();
350 return createIndex( parent->children.lastIndexOf( item ),
352 return QModelIndex();
355 QModelIndex PLModel::parent( const QModelIndex &index ) const
357 if( !index.isValid() ) return QModelIndex();
359 PLItem *childItem = static_cast<PLItem*>(index.internalPointer());
362 msg_Err( p_playlist, "NULL CHILD" );
363 return QModelIndex();
366 PLItem *parentItem = childItem->parent();
367 if( !parentItem || parentItem == rootItem ) return QModelIndex();
368 if( !parentItem->parentItem )
370 msg_Err( p_playlist, "No parent parent, trying row 0 " );
371 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
372 return createIndex( 0, 0, parentItem );
374 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
378 int PLModel::columnCount( const QModelIndex &i) const
380 return rootItem->item_col_strings.count();
383 int PLModel::childrenCount( const QModelIndex &parent ) const
385 return rowCount( parent );
388 int PLModel::rowCount( const QModelIndex &parent ) const
392 if( !parent.isValid() )
393 parentItem = rootItem;
395 parentItem = static_cast<PLItem*>(parent.internalPointer());
397 return parentItem->childCount();
400 /************************* General playlist status ***********************/
402 bool PLModel::hasRandom()
404 if( var_GetBool( p_playlist, "random" ) ) return true;
407 bool PLModel::hasRepeat()
409 if( var_GetBool( p_playlist, "repeat" ) ) return true;
412 bool PLModel::hasLoop()
414 if( var_GetBool( p_playlist, "loop" ) ) return true;
417 void PLModel::setLoop( bool on )
419 var_SetBool( p_playlist, "loop", on ? true:false );
420 config_PutInt( p_playlist, "loop", on ? 1: 0 );
422 void PLModel::setRepeat( bool on )
424 var_SetBool( p_playlist, "repeat", on ? true:false );
425 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
427 void PLModel::setRandom( bool on )
429 var_SetBool( p_playlist, "random", on ? true:false );
430 config_PutInt( p_playlist, "random", on ? 1: 0 );
433 /************************* Lookups *****************************/
435 PLItem *PLModel::FindById( PLItem *root, int i_id )
437 return FindInner( root, i_id, false );
440 PLItem *PLModel::FindByInput( PLItem *root, int i_id )
442 return FindInner( root, i_id, true );
445 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
446 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
448 PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
450 if( ( !b_input && i_cached_id == i_id) ||
451 ( b_input && i_cached_input_id ==i_id ) )
453 return b_input ? p_cached_item_bi : p_cached_item;
456 if( !b_input && root->i_id == i_id )
461 else if( b_input && root->i_input_id == i_id )
463 ICACHE( i_id, root );
467 QList<PLItem *>::iterator it = root->children.begin();
468 while ( it != root->children.end() )
470 if( !b_input && (*it)->i_id == i_id )
472 CACHE( i_id, (*it) );
473 return p_cached_item;
475 else if( b_input && (*it)->i_input_id == i_id )
477 ICACHE( i_id, (*it) );
478 return p_cached_item_bi;
480 if( (*it)->children.size() )
482 PLItem *childFound = FindInner( (*it), i_id, b_input );
486 ICACHE( i_id, childFound )
488 CACHE( i_id, childFound )
500 /************************* Updates handling *****************************/
501 void PLModel::customEvent( QEvent *event )
503 int type = event->type();
504 if( type != ItemUpdate_Type && type != ItemAppend_Type &&
505 type != ItemDelete_Type && type != PLUpdate_Type )
508 PLEvent *ple = static_cast<PLEvent *>(event);
510 if( type == ItemUpdate_Type )
511 ProcessInputItemUpdate( ple->i_id );
512 else if( type == ItemAppend_Type )
513 ProcessItemAppend( ple->p_add );
514 else if( type == ItemDelete_Type )
515 ProcessItemRemoval( ple->i_id );
520 /**** Events processing ****/
521 void PLModel::ProcessInputItemUpdate( int i_input_id )
523 if( i_input_id <= 0 ) return;
524 PLItem *item = FindByInput( rootItem, i_input_id );
526 UpdateTreeItem( item, true );
529 void PLModel::ProcessItemRemoval( int i_id )
531 if( i_id <= 0 ) return;
532 if( i_id == i_cached_id ) i_cached_id = -1;
533 i_cached_input_id = -1;
538 void PLModel::ProcessItemAppend( playlist_add_t *p_add )
540 playlist_item_t *p_item = NULL;
541 PLItem *newItem = NULL;
543 PLItem *nodeItem = FindById( rootItem, p_add->i_node );
545 if( !nodeItem ) goto end;
547 p_item = playlist_ItemGetById( p_playlist, p_add->i_item, true );
548 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
549 if( i_depth == DEPTH_SEL && p_item->p_parent &&
550 p_item->p_parent->i_id != rootItem->i_id )
553 newItem = new PLItem( p_item, nodeItem, this );
554 nodeItem->appendChild( newItem );
555 UpdateTreeItem( p_item, newItem, true );
562 void PLModel::rebuild()
567 void PLModel::rebuild( playlist_item_t *p_root )
569 /* Remove callbacks before locking to avoid deadlocks */
571 /* Invalidate cache */
572 i_cached_id = i_cached_input_id = -1;
578 if( rootItem->children.size() )
580 beginRemoveRows( index( rootItem, 0 ), 0,
581 rootItem->children.size() -1 );
582 qDeleteAll( rootItem->children );
583 rootItem->children.clear();
590 rootItem = new PLItem( p_root, NULL, this );
593 /* Recreate from root */
594 UpdateNodeChildren( rootItem );
595 if( p_playlist->status.p_item )
597 PLItem *currentItem = FindByInput( rootItem,
598 p_playlist->status.p_item->p_input->i_id );
601 UpdateTreeItem( p_playlist->status.p_item, currentItem,
607 /* And signal the view */
608 emit layoutChanged();
612 /* This function must be entered WITH the playlist lock */
613 void PLModel::UpdateNodeChildren( PLItem *root )
615 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id,
617 UpdateNodeChildren( p_node, root );
620 /* This function must be entered WITH the playlist lock */
621 void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
623 for( int i = 0; i < p_node->i_children ; i++ )
625 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
626 PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
627 root->appendChild( newItem, false );
628 UpdateTreeItem( newItem, false, true );
629 if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
630 UpdateNodeChildren( p_node->pp_children[i], newItem );
634 /* This function must be entered WITH the playlist lock */
635 void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
637 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
639 UpdateTreeItem( p_item, item, signal, force );
642 /* This function must be entered WITH the playlist lock */
643 void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
644 bool signal, bool force )
648 if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
649 p_item->p_parent->i_id != rootItem->i_id )
651 item->update( p_item, p_item == p_playlist->status.p_item );
653 emit dataChanged( index( item, 0 ) , index( item, 1 ) );
656 /************************* Actions ******************************/
659 * Deletion, here we have to do a ugly slow hack as we retrieve the full
660 * list of indexes to delete at once: when we delete a node and all of
661 * its children, we need to update the list.
662 * Todo: investigate whethere we can use ranges to be sure to delete all items?
664 void PLModel::doDelete( QModelIndexList selected )
666 for( int i = selected.size() -1 ; i >= 0; i-- )
668 QModelIndex index = selected[i];
669 if( index.column() != 0 ) continue;
670 PLItem *item = static_cast<PLItem*>(index.internalPointer());
673 if( item->children.size() )
674 recurseDelete( item->children, &selected );
675 doDeleteItem( item, &selected );
680 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
682 for( int i = children.size() - 1; i >= 0 ; i-- )
684 PLItem *item = children[i];
685 if( item->children.size() )
686 recurseDelete( item->children, fullList );
687 doDeleteItem( item, fullList );
691 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
693 QModelIndex deleteIndex = index( item, 0 );
694 fullList->removeAll( deleteIndex );
697 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
703 if( p_item->i_children == -1 )
704 playlist_DeleteFromInput( p_playlist, item->i_input_id, true );
706 playlist_NodeDelete( p_playlist, p_item, true, false );
707 /* And finally, remove it from the tree */
708 item->remove( item );
712 /******* Volume III: Sorting and searching ********/
713 void PLModel::sort( int column, Qt::SortOrder order )
718 // FIXME: Disable sorting on startup by ignoring
719 // first call of sorting caused by showing dialog
720 // see: standardpanel.cpp:65
721 static bool b_first_time = true;
724 b_first_time = false;
728 #define CHECK_COLUMN( meta ) \
730 if( ( shownFlags() & meta ) ) \
732 if( column == i_index ) \
739 CHECK_COLUMN( COLUMN_NUMBER );
740 CHECK_COLUMN( COLUMN_TITLE );
741 CHECK_COLUMN( COLUMN_DURATION );
742 CHECK_COLUMN( COLUMN_ARTIST );
743 CHECK_COLUMN( COLUMN_GENRE );
744 CHECK_COLUMN( COLUMN_ALBUM );
745 CHECK_COLUMN( COLUMN_TRACK_NUMBER );
746 CHECK_COLUMN( COLUMN_DESCRIPTION );
753 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
758 playlist_RecursiveNodeSort( p_playlist, p_root,
759 i_column_sorting( i_flag ),
760 order == Qt::AscendingOrder ?
761 ORDER_NORMAL : ORDER_REVERSE );
762 p_playlist->b_reset_currently_playing = true;
769 void PLModel::search( QString search_text )
771 /** \todo Fire the search with a small delay ? */
774 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
778 char *psz_name = search_text.toUtf8().data();
779 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
785 /*********** Popup *********/
786 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
788 assert( index.isValid() );
790 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
791 itemId( index ), true );
794 i_popup_item = p_item->i_id;
795 i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
797 current_selection = list;
798 QMenu *menu = new QMenu;
799 menu->addAction( qfu(I_POP_PLAY), this, SLOT( popupPlay() ) );
800 menu->addAction( qfu(I_POP_DEL), this, SLOT( popupDel() ) );
801 menu->addSeparator();
802 menu->addAction( qfu(I_POP_STREAM), this, SLOT( popupStream() ) );
803 menu->addAction( qfu(I_POP_SAVE), this, SLOT( popupSave() ) );
804 menu->addSeparator();
805 menu->addAction( qfu(I_POP_INFO), this, SLOT( popupInfo() ) );
806 if( p_item->i_children > -1 )
808 menu->addSeparator();
809 menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) );
810 menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) );
813 menu->addSeparator();
814 menu->addAction( qfu( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
816 menu->popup( point );
823 void PLModel::viewchanged( int meta )
836 /* UNUSED emit layoutAboutToBeChanged(); */
837 index = __MIN( index, rootItem->item_col_strings.count() );
838 QModelIndex parent = createIndex( 0, 0, rootItem );
840 if( rootItem->i_showflags & meta )
841 /* Removing columns */
843 beginRemoveColumns( parent, index, index+1 );
844 rootItem->i_showflags &= ~( meta );
845 rootItem->updateColumnHeaders();
851 beginInsertColumns( parent, index, index+1 );
852 rootItem->i_showflags |= meta;
853 rootItem->updateColumnHeaders();
860 void PLModel::popupDel()
862 doDelete( current_selection );
864 void PLModel::popupPlay()
868 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
870 activateItem( p_item );
875 void PLModel::popupInfo()
877 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
882 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_item->p_input );
887 void PLModel::popupStream()
889 msg_Err( p_playlist, "Stream not implemented" );
892 void PLModel::popupSave()
894 msg_Err( p_playlist, "Save not implemented" );
898 #include <shellapi.h>
899 void PLModel::popupExplore()
901 ShellExecute( NULL, "explore", "C:\\", NULL, NULL, SW_SHOWNORMAL );
905 /**********************************************************************
907 **********************************************************************/
908 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
909 vlc_value_t oval, vlc_value_t nval, void *param )
911 PLModel *p_model = (PLModel *) param;
912 PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
913 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
917 static int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
918 vlc_value_t oval, vlc_value_t nval, void *param )
920 PLModel *p_model = (PLModel *) param;
921 PLEvent *event = new PLEvent( ItemUpdate_Type, oval.i_int );
922 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
923 event = new PLEvent( ItemUpdate_Type, nval.i_int );
924 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
928 static int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
929 vlc_value_t oval, vlc_value_t nval, void *param )
931 PLModel *p_model = (PLModel *) param;
932 PLEvent *event = new PLEvent( ItemUpdate_Type, nval.i_int );
933 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
937 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
938 vlc_value_t oval, vlc_value_t nval, void *param )
940 PLModel *p_model = (PLModel *) param;
941 PLEvent *event = new PLEvent( ItemDelete_Type, nval.i_int );
942 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
946 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
947 vlc_value_t oval, vlc_value_t nval, void *param )
949 PLModel *p_model = (PLModel *) param;
950 playlist_add_t *p_add = (playlist_add_t *)malloc( sizeof( playlist_add_t));
951 memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
953 PLEvent *event = new PLEvent( p_add );
954 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );