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 ItemChanged( vlc_object_t *, const char *,
53 vlc_value_t, vlc_value_t, void * );
54 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
55 vlc_value_t oval, vlc_value_t nval, void *param );
56 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
57 vlc_value_t oval, vlc_value_t nval, void *param );
59 /*************************************************************************
60 * Playlist model implementation
61 *************************************************************************/
64 This model is called two times, for the selector and the standard panel
66 PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
67 intf_thread_t *_p_intf, /* main Qt p_intf */
68 playlist_item_t * p_root,
69 /*playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
70 and THEPL->p_root_category for SelectPL */
71 int _i_depth, /* -1 for StandPL, 1 for SelectPL */
72 QObject *parent ) /* Basic Qt parent */
73 : QAbstractItemModel( parent )
76 assert( i_depth == DEPTH_SEL || i_depth == DEPTH_PL );
78 p_playlist = _p_playlist;
80 i_cached_input_id = -1;
81 i_popup_item = i_popup_parent = -1;
83 rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
85 /* Icons initialization */
86 #define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( QPixmap( x ) )
87 ADD_ICON( UNKNOWN , type_unknown_xpm );
88 ADD_ICON( FILE, ":/type_file" );
89 ADD_ICON( DIRECTORY, ":/type_directory" );
90 ADD_ICON( DISC, ":/disc" );
91 ADD_ICON( CDDA, ":/cdda" );
92 ADD_ICON( CARD, ":/capture-card" );
93 ADD_ICON( NET, ":/type_net" );
94 ADD_ICON( PLAYLIST, ":/type_playlist" );
95 ADD_ICON( NODE, ":/type_node" );
99 CONNECT( THEMIM->getIM(), metaChanged( int ),
100 this, ProcessInputItemUpdate( int ) );
101 CONNECT( THEMIM, inputChanged( input_thread_t * ),
102 this, ProcessInputItemUpdate( input_thread_t* ) );
107 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
112 Qt::DropActions PLModel::supportedDropActions() const
114 return Qt::CopyAction; /* Why not Qt::MoveAction */
117 Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
119 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
120 if( index.isValid() )
121 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
123 return Qt::ItemIsDropEnabled | defaultFlags;
126 /* A list of model indexes are a playlist */
127 QStringList PLModel::mimeTypes() const
130 types << "vlc/playlist-item-id";
134 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
136 QMimeData *mimeData = new QMimeData();
137 QByteArray encodedData;
138 QDataStream stream( &encodedData, QIODevice::WriteOnly );
140 foreach( const QModelIndex &index, indexes ) {
141 if( index.isValid() && index.column() == 0 )
142 stream << itemId( index );
144 mimeData->setData( "vlc/playlist-item-id", encodedData );
149 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
150 int row, int column, const QModelIndex &target )
152 if( data->hasFormat( "vlc/playlist-item-id" ) )
154 if( action == Qt::IgnoreAction )
157 if( !target.isValid() )
158 /* We don't want to move on an invalid position */
161 PLItem *targetItem = static_cast<PLItem*>( target.internalPointer() );
163 QByteArray encodedData = data->data( "vlc/playlist-item-id" );
164 QDataStream stream( &encodedData, QIODevice::ReadOnly );
166 PLItem *newParentItem;
167 while( !stream.atEnd() )
174 playlist_item_t *p_target =
175 playlist_ItemGetById( p_playlist, targetItem->i_id );
176 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId );
178 if( !p_target || !p_src )
183 if( p_target->i_children == -1 ) /* A leaf */
185 PLItem *parentItem = targetItem->parent();
186 assert( parentItem );
187 playlist_item_t *p_parent =
188 playlist_ItemGetById( p_playlist, parentItem->i_id );
194 for( i = 0 ; i< p_parent->i_children ; i++ )
195 if( p_parent->pp_children[i] == p_target ) break;
196 // Move the item to the element after i
197 playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
198 newParentItem = parentItem;
202 /* \todo: if we drop on a top-level node, use copy instead ? */
203 playlist_TreeMove( p_playlist, p_src, p_target, 0 );
205 newParentItem = targetItem;
209 /*TODO: That's not a good idea to rebuild the playlist */
215 /* remove item with its id */
216 void PLModel::removeItem( int i_id )
218 PLItem *item = FindById( rootItem, i_id );
219 if( item ) item->remove( item );
222 /* callbacks and slots */
223 void PLModel::addCallbacks()
225 /* Some global changes happened -> Rebuild all */
226 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
227 /* We went to the next item
228 var_AddCallback( p_playlist, "item-current", PlaylistNext, this );
230 /* One item has been updated */
231 var_AddCallback( p_playlist, "playlist-item-append", ItemAppended, this );
232 var_AddCallback( p_playlist, "playlist-item-deleted", ItemDeleted, this );
235 void PLModel::delCallbacks()
237 var_DelCallback( p_playlist, "item-change", ItemChanged, this );
239 var_DelCallback( p_playlist, "item-current", PlaylistNext, this );
241 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
242 var_DelCallback( p_playlist, "playlist-item-append", ItemAppended, this );
243 var_DelCallback( p_playlist, "playlist-item-deleted", ItemDeleted, this );
246 void PLModel::activateItem( const QModelIndex &index )
248 assert( index.isValid() );
249 PLItem *item = static_cast<PLItem*>(index.internalPointer());
252 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
253 activateItem( p_item );
257 /* Must be entered with lock */
258 void PLModel::activateItem( playlist_item_t *p_item )
260 if( !p_item ) return;
261 playlist_item_t *p_parent = p_item;
264 if( p_parent->i_id == rootItem->i_id ) break;
265 p_parent = p_parent->p_parent;
268 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
272 /****************** Base model mandatory implementations *****************/
273 QVariant PLModel::data( const QModelIndex &index, int role ) const
275 if( !index.isValid() ) return QVariant();
276 PLItem *item = static_cast<PLItem*>(index.internalPointer());
277 if( role == Qt::DisplayRole )
279 return QVariant( item->columnString( index.column() ) );
281 else if( role == Qt::DecorationRole && index.column() == 0 )
283 /* Use to segfault here because i_type wasn't always initialized */
284 if( item->i_type >= 0 )
285 return QVariant( PLModel::icons[item->i_type] );
287 else if( role == Qt::FontRole )
289 if( item->b_current == true )
291 QFont f; f.setBold( true ); return QVariant( f );
297 bool PLModel::isCurrent( const QModelIndex &index )
299 assert( index.isValid() );
300 return static_cast<PLItem*>(index.internalPointer())->b_current;
303 int PLModel::itemId( const QModelIndex &index ) const
305 assert( index.isValid() );
306 return static_cast<PLItem*>(index.internalPointer())->i_id;
309 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
312 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
313 return QVariant( rootItem->columnString( section ) );
317 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
321 if( !parent.isValid() )
322 parentItem = rootItem;
324 parentItem = static_cast<PLItem*>(parent.internalPointer());
326 PLItem *childItem = parentItem->child( row );
328 return createIndex( row, column, childItem );
330 return QModelIndex();
333 /* Return the index of a given item */
334 QModelIndex PLModel::index( PLItem *item, int column ) const
336 if( !item ) return QModelIndex();
337 const PLItem *parent = item->parent();
339 return createIndex( parent->children.lastIndexOf( item ),
341 return QModelIndex();
344 QModelIndex PLModel::parent( const QModelIndex &index ) const
346 if( !index.isValid() ) return QModelIndex();
348 PLItem *childItem = static_cast<PLItem*>(index.internalPointer());
351 msg_Err( p_playlist, "NULL CHILD" );
352 return QModelIndex();
355 PLItem *parentItem = childItem->parent();
356 if( !parentItem || parentItem == rootItem ) return QModelIndex();
357 if( !parentItem->parentItem )
359 msg_Err( p_playlist, "No parent parent, trying row 0 " );
360 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
361 return createIndex( 0, 0, parentItem );
363 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
367 int PLModel::columnCount( const QModelIndex &i) const
369 return rootItem->item_col_strings.count();
372 int PLModel::childrenCount( const QModelIndex &parent ) const
374 return rowCount( parent );
377 int PLModel::rowCount( const QModelIndex &parent ) const
381 if( !parent.isValid() )
382 parentItem = rootItem;
384 parentItem = static_cast<PLItem*>(parent.internalPointer());
386 return parentItem->childCount();
389 QStringList PLModel::selectedURIs()
392 for( int i = 0; i < current_selection.size(); i++ )
395 PLItem *item = static_cast<PLItem*>
396 (current_selection[i].internalPointer());
399 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
402 char *psz = input_item_GetURI( p_item->p_input );
415 /************************* General playlist status ***********************/
417 bool PLModel::hasRandom()
419 return var_GetBool( p_playlist, "random" );
421 bool PLModel::hasRepeat()
423 return var_GetBool( p_playlist, "repeat" );
425 bool PLModel::hasLoop()
427 return var_GetBool( p_playlist, "loop" );
429 void PLModel::setLoop( bool on )
431 var_SetBool( p_playlist, "loop", on ? true:false );
432 config_PutInt( p_playlist, "loop", on ? 1: 0 );
434 void PLModel::setRepeat( bool on )
436 var_SetBool( p_playlist, "repeat", on ? true:false );
437 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
439 void PLModel::setRandom( bool on )
441 var_SetBool( p_playlist, "random", on ? true:false );
442 config_PutInt( p_playlist, "random", on ? 1: 0 );
445 /************************* Lookups *****************************/
447 PLItem *PLModel::FindById( PLItem *root, int i_id )
449 return FindInner( root, i_id, false );
452 PLItem *PLModel::FindByInput( PLItem *root, int i_id )
454 return FindInner( root, i_id, true );
457 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
458 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
460 PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
462 if( ( !b_input && i_cached_id == i_id) ||
463 ( b_input && i_cached_input_id ==i_id ) )
465 return b_input ? p_cached_item_bi : p_cached_item;
468 if( !b_input && root->i_id == i_id )
473 else if( b_input && root->i_input_id == i_id )
475 ICACHE( i_id, root );
479 QList<PLItem *>::iterator it = root->children.begin();
480 while ( it != root->children.end() )
482 if( !b_input && (*it)->i_id == i_id )
484 CACHE( i_id, (*it) );
485 return p_cached_item;
487 else if( b_input && (*it)->i_input_id == i_id )
489 ICACHE( i_id, (*it) );
490 return p_cached_item_bi;
492 if( (*it)->children.size() )
494 PLItem *childFound = FindInner( (*it), i_id, b_input );
498 ICACHE( i_id, childFound )
500 CACHE( i_id, childFound )
512 /************************* Updates handling *****************************/
513 void PLModel::customEvent( QEvent *event )
515 int type = event->type();
516 if( type != ItemAppend_Type &&
517 type != ItemDelete_Type && type != PLUpdate_Type )
520 PLEvent *ple = static_cast<PLEvent *>(event);
522 if( type == ItemAppend_Type )
523 ProcessItemAppend( &ple->add );
524 else if( type == ItemDelete_Type )
525 ProcessItemRemoval( ple->i_id );
530 /**** Events processing ****/
531 void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
533 if( !p_input ) return;
534 ProcessInputItemUpdate( input_GetItem( p_input )->i_id );
536 void PLModel::ProcessInputItemUpdate( int i_input_id )
538 if( i_input_id <= 0 ) return;
539 PLItem *item = FindByInput( rootItem, i_input_id );
543 UpdateTreeItem( item, true );
548 void PLModel::ProcessItemRemoval( int i_id )
550 if( i_id <= 0 ) return;
551 if( i_id == i_cached_id ) i_cached_id = -1;
552 i_cached_input_id = -1;
557 void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
559 playlist_item_t *p_item = NULL;
560 PLItem *newItem = NULL;
562 PLItem *nodeItem = FindById( rootItem, p_add->i_node );
564 if( !nodeItem ) goto end;
566 p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
567 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
568 if( i_depth == DEPTH_SEL && p_item->p_parent &&
569 p_item->p_parent->i_id != rootItem->i_id )
572 newItem = new PLItem( p_item, nodeItem, this );
573 nodeItem->appendChild( newItem );
574 UpdateTreeItem( p_item, newItem, true );
581 void PLModel::rebuild()
586 void PLModel::rebuild( playlist_item_t *p_root )
588 playlist_item_t* p_item;
589 /* Remove callbacks before locking to avoid deadlocks */
591 /* Invalidate cache */
592 i_cached_id = i_cached_input_id = -1;
598 if( rootItem->children.size() )
600 beginRemoveRows( index( rootItem, 0 ), 0,
601 rootItem->children.size() -1 );
602 qDeleteAll( rootItem->children );
603 rootItem->children.clear();
610 rootItem = new PLItem( p_root, getSettings(), this );
613 /* Recreate from root */
614 UpdateNodeChildren( rootItem );
615 if( (p_item = playlist_CurrentPlayingItem(p_playlist)) )
617 PLItem *currentItem = FindByInput( rootItem,
618 p_item->p_input->i_id );
621 UpdateTreeItem( p_item, currentItem,
627 /* And signal the view */
628 emit layoutChanged();
632 /* This function must be entered WITH the playlist lock */
633 void PLModel::UpdateNodeChildren( PLItem *root )
635 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
636 UpdateNodeChildren( p_node, root );
639 /* This function must be entered WITH the playlist lock */
640 void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
642 for( int i = 0; i < p_node->i_children ; i++ )
644 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
645 PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
646 root->appendChild( newItem, false );
647 UpdateTreeItem( newItem, false, true );
648 if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
649 UpdateNodeChildren( p_node->pp_children[i], newItem );
653 /* This function must be entered WITH the playlist lock */
654 void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
656 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
657 UpdateTreeItem( p_item, item, signal, force );
660 /* This function must be entered WITH the playlist lock */
661 void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
662 bool signal, bool force )
666 if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
667 p_item->p_parent->i_id != rootItem->i_id )
669 item->update( p_item, p_item == playlist_CurrentPlayingItem( p_playlist ) );
671 emit dataChanged( index( item, 0 ) , index( item, 1 ) );
674 /************************* Actions ******************************/
677 * Deletion, here we have to do a ugly slow hack as we retrieve the full
678 * list of indexes to delete at once: when we delete a node and all of
679 * its children, we need to update the list.
680 * Todo: investigate whethere we can use ranges to be sure to delete all items?
682 void PLModel::doDelete( QModelIndexList selected )
684 for( int i = selected.size() -1 ; i >= 0; i-- )
686 QModelIndex index = selected[i];
687 if( index.column() != 0 ) continue;
688 PLItem *item = static_cast<PLItem*>(index.internalPointer());
691 if( item->children.size() )
692 recurseDelete( item->children, &selected );
693 doDeleteItem( item, &selected );
698 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
700 for( int i = children.size() - 1; i >= 0 ; i-- )
702 PLItem *item = children[i];
703 if( item->children.size() )
704 recurseDelete( item->children, fullList );
705 doDeleteItem( item, fullList );
709 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
711 QModelIndex deleteIndex = index( item, 0 );
712 fullList->removeAll( deleteIndex );
715 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
721 if( p_item->i_children == -1 )
722 playlist_DeleteFromInput( p_playlist, item->i_input_id, pl_Locked );
724 playlist_NodeDelete( p_playlist, p_item, true, false );
725 /* And finally, remove it from the tree */
726 item->remove( item );
730 /******* Volume III: Sorting and searching ********/
731 void PLModel::sort( int column, Qt::SortOrder order )
737 for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
739 if( ( shownFlags() & i_column ) )
741 if( column == i_index )
752 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
754 if( p_root && i_flag )
756 playlist_RecursiveNodeSort( p_playlist, p_root,
757 i_column_sorting( i_flag ),
758 order == Qt::AscendingOrder ?
759 ORDER_NORMAL : ORDER_REVERSE );
766 void PLModel::search( const QString& search_text )
768 /** \todo Fire the search with a small delay ? */
771 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
774 const char *psz_name = search_text.toUtf8().data();
775 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
781 /*********** Popup *********/
782 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
784 assert( index.isValid() );
786 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, itemId( index ) );
789 i_popup_item = p_item->i_id;
790 i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
792 current_selection = list;
793 QMenu *menu = new QMenu;
794 menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
795 menu->addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
796 menu->addSeparator();
797 menu->addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
798 menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
799 menu->addSeparator();
800 menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
801 if( p_item->i_children > -1 )
803 menu->addSeparator();
804 menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
805 menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAdd() ) );
807 menu->addSeparator();
808 menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
809 menu->popup( point );
816 void PLModel::viewchanged( int meta )
829 /* UNUSED emit layoutAboutToBeChanged(); */
830 index = __MIN( index, rootItem->item_col_strings.count() );
831 QModelIndex parent = createIndex( 0, 0, rootItem );
833 if( rootItem->i_showflags & meta )
834 /* Removing columns */
836 beginRemoveColumns( parent, index, index+1 );
837 rootItem->i_showflags &= ~( meta );
838 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
839 rootItem->updateColumnHeaders();
845 beginInsertColumns( parent, index, index+1 );
846 rootItem->i_showflags |= meta;
847 getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
848 rootItem->updateColumnHeaders();
855 void PLModel::popupDel()
857 doDelete( current_selection );
860 void PLModel::popupPlay()
864 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
866 activateItem( p_item );
871 void PLModel::popupInfo()
874 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
878 input_item_t* p_input = p_item->p_input;
879 vlc_gc_incref( p_input );
881 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
882 vlc_gc_decref( p_input );
883 mid->setParent( PlaylistDialog::getInstance( p_intf ),
889 void PLModel::popupStream()
891 QStringList mrls = selectedURIs();
892 if( !mrls.isEmpty() )
893 THEDP->streamingDialog( NULL, mrls[0], false );
897 void PLModel::popupSave()
899 QStringList mrls = selectedURIs();
900 if( !mrls.isEmpty() )
901 THEDP->streamingDialog( NULL, mrls[0] );
906 #include <QDesktopServices>
907 void PLModel::popupExplore()
910 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
914 input_item_t *p_input = p_item->p_input;
915 char *psz_meta = input_item_GetURI( p_input );
919 const char *psz_access;
920 const char *psz_demux;
922 input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
924 if( EMPTY_STR( psz_access ) ||
925 !strncasecmp( psz_access, "file", 4 ) ||
926 !strncasecmp( psz_access, "dire", 4 ) )
928 QFileInfo info( qfu( psz_meta ) );
929 QDesktopServices::openUrl(
930 QUrl::fromLocalFile( info.absolutePath() ) );
939 /**********************************************************************
941 **********************************************************************/
942 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
943 vlc_value_t oval, vlc_value_t nval, void *param )
945 PLModel *p_model = (PLModel *) param;
946 PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
947 QApplication::postEvent( p_model, event );
951 static int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
952 vlc_value_t oval, vlc_value_t nval, void *param )
954 PLModel *p_model = (PLModel *) param;
955 PLEvent *event = new PLEvent( ItemUpdate_Type, oval.i_int );
956 QApplication::postEvent( p_model, event );
957 event = new PLEvent( ItemUpdate_Type, nval.i_int );
958 QApplication::postEvent( p_model, event );
962 static int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
963 vlc_value_t oval, vlc_value_t nval, void *param )
965 PLModel *p_model = (PLModel *) param;
966 PLEvent *event = new PLEvent( ItemUpdate_Type, nval.i_int );
967 QApplication::postEvent( p_model, event );
971 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
972 vlc_value_t oval, vlc_value_t nval, void *param )
974 PLModel *p_model = (PLModel *) param;
975 PLEvent *event = new PLEvent( ItemDelete_Type, nval.i_int );
976 QApplication::postEvent( p_model, event );
980 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
981 vlc_value_t oval, vlc_value_t nval, void *param )
983 PLModel *p_model = (PLModel *) param;
984 const playlist_add_t *p_add = (playlist_add_t *)nval.p_address;
985 PLEvent *event = new PLEvent( p_add );
986 QApplication::postEvent( p_model, event );