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/types/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, ":/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" );
101 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
106 Qt::DropActions PLModel::supportedDropActions() const
108 return Qt::CopyAction; /* Why not Qt::MoveAction */
111 Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
113 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
114 if( index.isValid() )
115 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
117 return Qt::ItemIsDropEnabled | defaultFlags;
120 /* A list of model indexes are a playlist */
121 QStringList PLModel::mimeTypes() const
124 types << "vlc/playlist-item-id";
128 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
130 QMimeData *mimeData = new QMimeData();
131 QByteArray encodedData;
132 QDataStream stream( &encodedData, QIODevice::WriteOnly );
134 foreach( QModelIndex index, indexes ) {
135 if( index.isValid() && index.column() == 0 )
136 stream << itemId( index );
138 mimeData->setData( "vlc/playlist-item-id", encodedData );
143 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
144 int row, int column, const QModelIndex &target )
146 if( data->hasFormat( "vlc/playlist-item-id" ) )
148 if( action == Qt::IgnoreAction )
152 if( target.isValid() )
153 targetItem = static_cast<PLItem*>( target.internalPointer() );
155 targetItem = rootItem;
157 QByteArray encodedData = data->data( "vlc/playlist-item-id" );
158 QDataStream stream( &encodedData, QIODevice::ReadOnly );
160 PLItem *newParentItem;
161 while( !stream.atEnd() )
168 playlist_item_t *p_target =
169 playlist_ItemGetById( p_playlist, targetItem->i_id,
171 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId,
174 if( !p_target || !p_src )
179 if( p_target->i_children == -1 ) /* A leaf */
181 PLItem *parentItem = targetItem->parent();
182 assert( parentItem );
183 playlist_item_t *p_parent =
184 playlist_ItemGetById( p_playlist, parentItem->i_id,
191 for( i = 0 ; i< p_parent->i_children ; i++ )
192 if( p_parent->pp_children[i] == p_target ) break;
193 playlist_TreeMove( p_playlist, p_src, p_parent, i );
194 newParentItem = parentItem;
198 /* \todo: if we drop on a top-level node, use copy instead ? */
199 playlist_TreeMove( p_playlist, p_src, p_target, 0 );
201 newParentItem = targetItem;
203 /* Remove from source */
204 PLItem *srcItem = FindById( rootItem, p_src->i_id );
205 // We dropped on the source selector. Ask the dialog to forward
209 emit shouldRemove( p_src->i_id );
212 srcItem->remove( srcItem );
214 /* Display at new destination */
215 PLItem *newItem = new PLItem( p_src, newParentItem, this );
216 newParentItem->insertChild( newItem, i, true );
217 UpdateTreeItem( p_src, newItem, true );
218 if( p_src->i_children != -1 )
219 UpdateNodeChildren( newItem );
226 /* remove item with its id */
227 void PLModel::removeItem( int i_id )
229 PLItem *item = FindById( rootItem, i_id );
230 if( item ) item->remove( item );
233 /* callbacks and slots */
234 void PLModel::addCallbacks()
236 /* Some global changes happened -> Rebuild all */
237 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
238 /* We went to the next item */
239 var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );
240 /* One item has been updated */
241 var_AddCallback( p_playlist, "item-change", ItemChanged, this );
242 var_AddCallback( p_playlist, "item-append", ItemAppended, this );
243 var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
246 void PLModel::delCallbacks()
248 var_DelCallback( p_playlist, "item-change", ItemChanged, this );
249 var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
250 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
251 var_DelCallback( p_playlist, "item-append", ItemAppended, this );
252 var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
255 void PLModel::activateItem( const QModelIndex &index )
257 assert( index.isValid() );
258 PLItem *item = static_cast<PLItem*>(index.internalPointer());
261 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
263 activateItem( p_item );
267 /* Must be entered with lock */
268 void PLModel::activateItem( playlist_item_t *p_item )
270 if( !p_item ) return;
271 playlist_item_t *p_parent = p_item;
274 if( p_parent->i_id == rootItem->i_id ) break;
275 p_parent = p_parent->p_parent;
278 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
282 /****************** Base model mandatory implementations *****************/
283 QVariant PLModel::data( const QModelIndex &index, int role ) const
285 if( !index.isValid() ) return QVariant();
286 PLItem *item = static_cast<PLItem*>(index.internalPointer());
287 if( role == Qt::DisplayRole )
289 return QVariant( item->columnString( index.column() ) );
291 else if( role == Qt::DecorationRole && index.column() == 0 )
293 /* Use to segfault here because i_type wasn't always initialized */
294 if( item->i_type >= 0 )
295 return QVariant( PLModel::icons[item->i_type] );
297 else if( role == Qt::FontRole )
299 if( item->b_current == true )
301 QFont f; f.setBold( true ); return QVariant( f );
307 bool PLModel::isCurrent( const QModelIndex &index )
309 assert( index.isValid() );
310 return static_cast<PLItem*>(index.internalPointer())->b_current;
313 int PLModel::itemId( const QModelIndex &index ) const
315 assert( index.isValid() );
316 return static_cast<PLItem*>(index.internalPointer())->i_id;
319 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
322 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
323 return QVariant( rootItem->columnString( section ) );
327 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
331 if( !parent.isValid() )
332 parentItem = rootItem;
334 parentItem = static_cast<PLItem*>(parent.internalPointer());
336 PLItem *childItem = parentItem->child( row );
338 return createIndex( row, column, childItem );
340 return QModelIndex();
343 /* Return the index of a given item */
344 QModelIndex PLModel::index( PLItem *item, int column ) const
346 if( !item ) return QModelIndex();
347 const PLItem *parent = item->parent();
349 return createIndex( parent->children.lastIndexOf( item ),
351 return QModelIndex();
354 QModelIndex PLModel::parent( const QModelIndex &index ) const
356 if( !index.isValid() ) return QModelIndex();
358 PLItem *childItem = static_cast<PLItem*>(index.internalPointer());
361 msg_Err( p_playlist, "NULL CHILD" );
362 return QModelIndex();
365 PLItem *parentItem = childItem->parent();
366 if( !parentItem || parentItem == rootItem ) return QModelIndex();
367 if( !parentItem->parentItem )
369 msg_Err( p_playlist, "No parent parent, trying row 0 " );
370 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
371 return createIndex( 0, 0, parentItem );
373 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
377 int PLModel::columnCount( const QModelIndex &i) const
379 return rootItem->item_col_strings.count();
382 int PLModel::childrenCount( const QModelIndex &parent ) const
384 return rowCount( parent );
387 int PLModel::rowCount( const QModelIndex &parent ) const
391 if( !parent.isValid() )
392 parentItem = rootItem;
394 parentItem = static_cast<PLItem*>(parent.internalPointer());
396 return parentItem->childCount();
399 /************************* General playlist status ***********************/
401 bool PLModel::hasRandom()
403 if( var_GetBool( p_playlist, "random" ) ) return true;
406 bool PLModel::hasRepeat()
408 if( var_GetBool( p_playlist, "repeat" ) ) return true;
411 bool PLModel::hasLoop()
413 if( var_GetBool( p_playlist, "loop" ) ) return true;
416 void PLModel::setLoop( bool on )
418 var_SetBool( p_playlist, "loop", on ? true:false );
419 config_PutInt( p_playlist, "loop", on ? 1: 0 );
421 void PLModel::setRepeat( bool on )
423 var_SetBool( p_playlist, "repeat", on ? true:false );
424 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
426 void PLModel::setRandom( bool on )
428 var_SetBool( p_playlist, "random", on ? true:false );
429 config_PutInt( p_playlist, "random", on ? 1: 0 );
432 /************************* Lookups *****************************/
434 PLItem *PLModel::FindById( PLItem *root, int i_id )
436 return FindInner( root, i_id, false );
439 PLItem *PLModel::FindByInput( PLItem *root, int i_id )
441 return FindInner( root, i_id, true );
444 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
445 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
447 PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
449 if( ( !b_input && i_cached_id == i_id) ||
450 ( b_input && i_cached_input_id ==i_id ) )
452 return b_input ? p_cached_item_bi : p_cached_item;
455 if( !b_input && root->i_id == i_id )
460 else if( b_input && root->i_input_id == i_id )
462 ICACHE( i_id, root );
466 QList<PLItem *>::iterator it = root->children.begin();
467 while ( it != root->children.end() )
469 if( !b_input && (*it)->i_id == i_id )
471 CACHE( i_id, (*it) );
472 return p_cached_item;
474 else if( b_input && (*it)->i_input_id == i_id )
476 ICACHE( i_id, (*it) );
477 return p_cached_item_bi;
479 if( (*it)->children.size() )
481 PLItem *childFound = FindInner( (*it), i_id, b_input );
485 ICACHE( i_id, childFound )
487 CACHE( i_id, childFound )
499 /************************* Updates handling *****************************/
500 void PLModel::customEvent( QEvent *event )
502 int type = event->type();
503 if( type != ItemUpdate_Type && type != ItemAppend_Type &&
504 type != ItemDelete_Type && type != PLUpdate_Type )
507 PLEvent *ple = static_cast<PLEvent *>(event);
509 if( type == ItemUpdate_Type )
510 ProcessInputItemUpdate( ple->i_id );
511 else if( type == ItemAppend_Type )
512 ProcessItemAppend( ple->p_add );
513 else if( type == ItemDelete_Type )
514 ProcessItemRemoval( ple->i_id );
519 /**** Events processing ****/
520 void PLModel::ProcessInputItemUpdate( int i_input_id )
522 if( i_input_id <= 0 ) return;
523 PLItem *item = FindByInput( rootItem, i_input_id );
527 UpdateTreeItem( item, true );
532 void PLModel::ProcessItemRemoval( int i_id )
534 if( i_id <= 0 ) return;
535 if( i_id == i_cached_id ) i_cached_id = -1;
536 i_cached_input_id = -1;
541 void PLModel::ProcessItemAppend( playlist_add_t *p_add )
543 playlist_item_t *p_item = NULL;
544 PLItem *newItem = NULL;
546 PLItem *nodeItem = FindById( rootItem, p_add->i_node );
548 if( !nodeItem ) goto end;
550 p_item = playlist_ItemGetById( p_playlist, p_add->i_item, pl_Locked );
551 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
552 if( i_depth == DEPTH_SEL && p_item->p_parent &&
553 p_item->p_parent->i_id != rootItem->i_id )
556 newItem = new PLItem( p_item, nodeItem, this );
557 nodeItem->appendChild( newItem );
558 UpdateTreeItem( p_item, newItem, true );
565 void PLModel::rebuild()
570 void PLModel::rebuild( playlist_item_t *p_root )
572 /* Remove callbacks before locking to avoid deadlocks */
574 /* Invalidate cache */
575 i_cached_id = i_cached_input_id = -1;
581 if( rootItem->children.size() )
583 beginRemoveRows( index( rootItem, 0 ), 0,
584 rootItem->children.size() -1 );
585 qDeleteAll( rootItem->children );
586 rootItem->children.clear();
593 rootItem = new PLItem( p_root, getSettings(), this );
596 /* Recreate from root */
597 UpdateNodeChildren( rootItem );
598 if( p_playlist->status.p_item )
600 PLItem *currentItem = FindByInput( rootItem,
601 p_playlist->status.p_item->p_input->i_id );
604 UpdateTreeItem( p_playlist->status.p_item, currentItem,
610 /* And signal the view */
611 emit layoutChanged();
615 /* This function must be entered WITH the playlist lock */
616 void PLModel::UpdateNodeChildren( PLItem *root )
618 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id,
620 UpdateNodeChildren( p_node, root );
623 /* This function must be entered WITH the playlist lock */
624 void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
626 for( int i = 0; i < p_node->i_children ; i++ )
628 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
629 PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
630 root->appendChild( newItem, false );
631 UpdateTreeItem( newItem, false, true );
632 if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
633 UpdateNodeChildren( p_node->pp_children[i], newItem );
637 /* This function must be entered WITH the playlist lock */
638 void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
640 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
642 UpdateTreeItem( p_item, item, signal, force );
645 /* This function must be entered WITH the playlist lock */
646 void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
647 bool signal, bool force )
651 if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
652 p_item->p_parent->i_id != rootItem->i_id )
654 item->update( p_item, p_item == p_playlist->status.p_item );
656 emit dataChanged( index( item, 0 ) , index( item, 1 ) );
659 /************************* Actions ******************************/
662 * Deletion, here we have to do a ugly slow hack as we retrieve the full
663 * list of indexes to delete at once: when we delete a node and all of
664 * its children, we need to update the list.
665 * Todo: investigate whethere we can use ranges to be sure to delete all items?
667 void PLModel::doDelete( QModelIndexList selected )
669 for( int i = selected.size() -1 ; i >= 0; i-- )
671 QModelIndex index = selected[i];
672 if( index.column() != 0 ) continue;
673 PLItem *item = static_cast<PLItem*>(index.internalPointer());
676 if( item->children.size() )
677 recurseDelete( item->children, &selected );
678 doDeleteItem( item, &selected );
683 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
685 for( int i = children.size() - 1; i >= 0 ; i-- )
687 PLItem *item = children[i];
688 if( item->children.size() )
689 recurseDelete( item->children, fullList );
690 doDeleteItem( item, fullList );
694 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
696 QModelIndex deleteIndex = index( item, 0 );
697 fullList->removeAll( deleteIndex );
700 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
706 if( p_item->i_children == -1 )
707 playlist_DeleteFromInput( p_playlist, item->i_input_id, pl_Locked );
709 playlist_NodeDelete( p_playlist, p_item, true, false );
710 /* And finally, remove it from the tree */
711 item->remove( item );
715 /******* Volume III: Sorting and searching ********/
716 void PLModel::sort( int column, Qt::SortOrder order )
721 // FIXME: Disable sorting on startup by ignoring
722 // first call of sorting caused by showing dialog
723 // see: standardpanel.cpp:65
724 static bool b_first_time = true;
727 b_first_time = false;
731 #define CHECK_COLUMN( meta ) \
733 if( ( shownFlags() & meta ) ) \
735 if( column == i_index ) \
742 CHECK_COLUMN( COLUMN_NUMBER );
743 CHECK_COLUMN( COLUMN_TITLE );
744 CHECK_COLUMN( COLUMN_DURATION );
745 CHECK_COLUMN( COLUMN_ARTIST );
746 CHECK_COLUMN( COLUMN_GENRE );
747 CHECK_COLUMN( COLUMN_ALBUM );
748 CHECK_COLUMN( COLUMN_TRACK_NUMBER );
749 CHECK_COLUMN( COLUMN_DESCRIPTION );
756 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
761 playlist_RecursiveNodeSort( p_playlist, p_root,
762 i_column_sorting( i_flag ),
763 order == Qt::AscendingOrder ?
764 ORDER_NORMAL : ORDER_REVERSE );
765 p_playlist->b_reset_currently_playing = true;
772 void PLModel::search( QString search_text )
774 /** \todo Fire the search with a small delay ? */
777 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
781 char *psz_name = search_text.toUtf8().data();
782 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
788 /*********** Popup *********/
789 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
791 assert( index.isValid() );
793 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
794 itemId( index ), pl_Locked );
797 i_popup_item = p_item->i_id;
798 i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
800 current_selection = list;
801 QMenu *menu = new QMenu;
802 menu->addAction( qfu(I_POP_PLAY), this, SLOT( popupPlay() ) );
803 menu->addAction( qfu(I_POP_DEL), this, SLOT( popupDel() ) );
804 menu->addSeparator();
805 menu->addAction( qfu(I_POP_STREAM), this, SLOT( popupStream() ) );
806 menu->addAction( qfu(I_POP_SAVE), this, SLOT( popupSave() ) );
807 menu->addSeparator();
808 menu->addAction( qfu(I_POP_INFO), this, SLOT( popupInfo() ) );
809 if( p_item->i_children > -1 )
811 menu->addSeparator();
812 menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) );
813 menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) );
816 menu->addSeparator();
817 menu->addAction( qfu( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
819 menu->popup( point );
826 void PLModel::viewchanged( int meta )
839 /* UNUSED emit layoutAboutToBeChanged(); */
840 index = __MIN( index, rootItem->item_col_strings.count() );
841 QModelIndex parent = createIndex( 0, 0, rootItem );
843 if( rootItem->i_showflags & meta )
844 /* Removing columns */
846 beginRemoveColumns( parent, index, index+1 );
847 rootItem->i_showflags &= ~( meta );
848 rootItem->updateColumnHeaders();
854 beginInsertColumns( parent, index, index+1 );
855 rootItem->i_showflags |= meta;
856 rootItem->updateColumnHeaders();
863 void PLModel::popupDel()
865 doDelete( current_selection );
867 void PLModel::popupPlay()
871 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
874 activateItem( p_item );
879 void PLModel::popupInfo()
881 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
886 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_item->p_input );
891 void PLModel::popupStream()
893 msg_Err( p_playlist, "Stream not implemented" );
896 void PLModel::popupSave()
898 msg_Err( p_playlist, "Save not implemented" );
902 #include <shellapi.h>
903 void PLModel::popupExplore()
905 ShellExecute( NULL, "explore", "C:\\", NULL, NULL, SW_SHOWNORMAL );
909 /**********************************************************************
911 **********************************************************************/
912 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
913 vlc_value_t oval, vlc_value_t nval, void *param )
915 PLModel *p_model = (PLModel *) param;
916 PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
917 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
921 static int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
922 vlc_value_t oval, vlc_value_t nval, void *param )
924 PLModel *p_model = (PLModel *) param;
925 PLEvent *event = new PLEvent( ItemUpdate_Type, oval.i_int );
926 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
927 event = new PLEvent( ItemUpdate_Type, nval.i_int );
928 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
932 static int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
933 vlc_value_t oval, vlc_value_t nval, void *param )
935 PLModel *p_model = (PLModel *) param;
936 PLEvent *event = new PLEvent( ItemUpdate_Type, nval.i_int );
937 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
941 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
942 vlc_value_t oval, vlc_value_t nval, void *param )
944 PLModel *p_model = (PLModel *) param;
945 PLEvent *event = new PLEvent( ItemDelete_Type, nval.i_int );
946 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
950 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
951 vlc_value_t oval, vlc_value_t nval, void *param )
953 PLModel *p_model = (PLModel *) param;
954 playlist_add_t *p_add = (playlist_add_t *)malloc( sizeof( playlist_add_t));
955 memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
957 PLEvent *event = new PLEvent( p_add );
958 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );