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 *****************************************************************************/
23 #define PLI_NAME( p ) p ? p->p_input->psz_name : "null"
29 #include <QApplication>
32 #include "playlist_model.hpp"
33 #include "dialogs/mediainfo.hpp"
34 #include <vlc_intf_strings.h>
36 #include "pixmaps/type_unknown.xpm"
37 #include "pixmaps/type_afile.xpm"
38 #include "pixmaps/type_vfile.xpm"
39 #include "pixmaps/type_net.xpm"
40 #include "pixmaps/type_card.xpm"
41 #include "pixmaps/type_disc.xpm"
42 #include "pixmaps/type_cdda.xpm"
43 #include "pixmaps/type_directory.xpm"
44 #include "pixmaps/type_playlist.xpm"
45 #include "pixmaps/type_node.xpm"
47 QIcon PLModel::icons[ITEM_TYPE_NUMBER];
49 static int PlaylistChanged( vlc_object_t *, const char *,
50 vlc_value_t, vlc_value_t, void * );
51 static int PlaylistNext( vlc_object_t *, const char *,
52 vlc_value_t, vlc_value_t, void * );
53 static int ItemChanged( vlc_object_t *, const char *,
54 vlc_value_t, vlc_value_t, void * );
55 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
56 vlc_value_t oval, vlc_value_t nval, void *param );
57 static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
58 vlc_value_t oval, vlc_value_t nval, void *param );
60 /*************************************************************************
61 * Playlist item implementation
62 *************************************************************************/
71 void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m)
74 i_id = _i_id; i_input_id = _i_input_id;
82 PLItem::PLItem( int _i_id, int _i_input_id, PLItem *parent, PLModel *m)
84 init( _i_id, _i_input_id, parent, m );
87 PLItem::PLItem( playlist_item_t * p_item, PLItem *parent, PLModel *m )
89 init( p_item->i_id, p_item->p_input->i_id, parent, m );
98 void PLItem::insertChild( PLItem *item, int i_pos, bool signal )
102 model->beginInsertRows( model->index( this , 0 ), i_pos, i_pos );
103 children.insert( i_pos, item );
105 model->endInsertRows();
108 void PLItem::remove( PLItem *removed )
110 assert( model && parentItem );
111 int i_index = parentItem->children.indexOf( removed );
112 model->beginRemoveRows( model->index( parentItem, 0 ), i_index, i_index );
113 parentItem->children.removeAt( i_index );
114 model->endRemoveRows();
117 int PLItem::row() const
120 return parentItem->children.indexOf(const_cast<PLItem*>(this));
124 void PLItem::update( playlist_item_t *p_item, bool iscurrent )
126 char psz_duration[MSTRTIME_MAX_SIZE];
127 assert( p_item->p_input->i_id == i_input_id );
128 strings[0] = QString::fromUtf8( p_item->p_input->psz_name );
129 if( p_item->p_input->p_meta )
131 strings[1] = QString::fromUtf8( p_item->p_input->p_meta->psz_artist );
133 secstotimestr( psz_duration, p_item->p_input->i_duration / 1000000 );
134 strings[2] = QString( psz_duration );
135 type = p_item->p_input->i_type;
138 if( current && p_item->p_input->p_meta &&
139 p_item->p_input->p_meta->psz_arturl &&
140 !strncmp( p_item->p_input->p_meta->psz_arturl, "file://", 7 ) )
141 model->sendArt( qfu( p_item->p_input->p_meta->psz_arturl ) );
146 /*************************************************************************
147 * Playlist model implementation
148 *************************************************************************/
150 PLModel::PLModel( playlist_t *_p_playlist, intf_thread_t *_p_intf,
151 playlist_item_t * p_root, int _i_depth, QObject *parent)
152 : QAbstractItemModel(parent)
155 assert( i_depth == 1 || i_depth == -1 );
157 p_playlist= _p_playlist;
158 i_items_to_append = 0;
159 b_need_update = false;
161 i_cached_input_id = -1;
162 i_popup_item = i_popup_parent = -1;
164 #define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( QPixmap( type_##x##_xpm ) );
165 ADD_ICON( UNKNOWN , unknown );
166 ADD_ICON( AFILE,afile );
167 ADD_ICON( VFILE, vfile );
168 ADD_ICON( DIRECTORY, directory );
169 ADD_ICON( DISC, disc );
170 ADD_ICON( CDDA, cdda );
171 ADD_ICON( CARD, card );
172 ADD_ICON( NET, net );
173 ADD_ICON( PLAYLIST, playlist );
174 ADD_ICON( NODE, node );
188 Qt::DropActions PLModel::supportedDropActions() const
190 return Qt::CopyAction;
193 Qt::ItemFlags PLModel::flags(const QModelIndex &index) const
195 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
196 if( index.isValid() )
197 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
199 return Qt::ItemIsDropEnabled | defaultFlags;
202 QStringList PLModel::mimeTypes() const
205 types << "vlc/playlist-item-id";
209 QMimeData *PLModel::mimeData(const QModelIndexList &indexes) const
211 QMimeData *mimeData = new QMimeData();
212 QByteArray encodedData;
213 QDataStream stream(&encodedData, QIODevice::WriteOnly);
215 foreach (QModelIndex index, indexes) {
216 if (index.isValid() && index.column() == 0 )
217 stream << itemId(index);
219 mimeData->setData("vlc/playlist-item-id", encodedData);
223 bool PLModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
224 int row, int column, const QModelIndex &target)
226 if ( data->hasFormat("vlc/playlist-item-id") )
228 if (action == Qt::IgnoreAction)
232 if( target.isValid() )
233 targetItem = static_cast<PLItem*>( target.internalPointer() );
235 targetItem = rootItem;
237 QByteArray encodedData = data->data("vlc/playlist-item-id");
238 QDataStream stream(&encodedData, QIODevice::ReadOnly);
240 PLItem *newParentItem;
241 while (!stream.atEnd())
248 playlist_item_t *p_target =
249 playlist_ItemGetById( p_playlist, targetItem->i_id,
251 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId,
254 if( !p_target || !p_src )
259 if( p_target->i_children == -1 ) /* A leaf */
261 PLItem *parentItem = targetItem->parent();
262 assert( parentItem );
263 playlist_item_t *p_parent =
264 playlist_ItemGetById( p_playlist, parentItem->i_id,
271 for( i = 0 ; i< p_parent->i_children ; i++ )
272 if( p_parent->pp_children[i] == p_target ) break;
273 playlist_TreeMove( p_playlist, p_src, p_parent, i );
274 newParentItem = parentItem;
278 /* \todo: if we drop on a top-level node, use copy instead ? */
279 playlist_TreeMove( p_playlist, p_src, p_target, 0 );
281 newParentItem = targetItem;
283 /* Remove from source */
284 PLItem *srcItem = FindById( rootItem, p_src->i_id );
285 // We dropped on the source selector. Ask the dialog to forward
289 emit shouldRemove( p_src->i_id );
292 srcItem->remove( srcItem );
294 /* Display at new destination */
295 PLItem *newItem = new PLItem( p_src, newParentItem, this );
296 newParentItem->insertChild( newItem, i, true );
297 UpdateTreeItem( p_src, newItem, true );
298 if( p_src->i_children != -1 )
299 UpdateNodeChildren( newItem );
306 void PLModel::removeItem( int i_id )
308 PLItem *item = FindById( rootItem,i_id );
309 if( item ) item->remove( item );
312 void PLModel::addCallbacks()
314 /* Some global changes happened -> Rebuild all */
315 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
316 /* We went to the next item */
317 var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );
318 /* One item has been updated */
319 var_AddCallback( p_playlist, "item-change", ItemChanged, this );
320 var_AddCallback( p_playlist, "item-append", ItemAppended, this );
321 var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
324 void PLModel::delCallbacks()
326 var_DelCallback( p_playlist, "item-change", ItemChanged, this );
327 var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
328 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
329 var_DelCallback( p_playlist, "item-append", ItemAppended, this );
330 var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
333 void PLModel::activateItem( const QModelIndex &index )
335 assert( index.isValid() );
336 PLItem *item = static_cast<PLItem*>(index.internalPointer());
339 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
341 activateItem( p_item );
344 /* Must be entered with lock */
345 void PLModel::activateItem( playlist_item_t *p_item )
347 if( !p_item ) return;
348 playlist_item_t *p_parent = p_item;
351 if( p_parent->i_id == rootItem->i_id ) break;
352 p_parent = p_parent->p_parent;
355 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_parent, p_item );
358 /****************** Base model mandatory implementations *****************/
359 QVariant PLModel::data(const QModelIndex &index, int role) const
361 if(!index.isValid() ) return QVariant();
362 PLItem *item = static_cast<PLItem*>(index.internalPointer());
363 if( role == Qt::DisplayRole )
365 return QVariant( item->columnString( index.column() ) );
367 else if( role == Qt::DecorationRole && index.column() == 0 )
369 if( item->type >= 0 )
370 return QVariant( PLModel::icons[item->type] );
372 else if( role == Qt::FontRole )
374 if( item->current == true )
376 QFont f; f.setBold( true ); return QVariant( f );
382 bool PLModel::isCurrent( const QModelIndex &index )
384 assert( index.isValid() );
385 return static_cast<PLItem*>(index.internalPointer())->current;
388 int PLModel::itemId( const QModelIndex &index ) const
390 assert( index.isValid() );
391 return static_cast<PLItem*>(index.internalPointer())->i_id;
394 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
397 if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
398 return QVariant( rootItem->columnString( section ) );
402 QModelIndex PLModel::index(int row, int column, const QModelIndex &parent)
406 if (!parent.isValid())
407 parentItem = rootItem;
409 parentItem = static_cast<PLItem*>(parent.internalPointer());
411 PLItem *childItem = parentItem->child(row);
413 return createIndex(row, column, childItem);
415 return QModelIndex();
418 /* Return the index of a given item */
419 QModelIndex PLModel::index( PLItem *item, int column ) const
421 if( !item ) return QModelIndex();
422 const PLItem *parent = item->parent();
424 return createIndex( parent->children.lastIndexOf( item ),
426 return QModelIndex();
429 QModelIndex PLModel::parent(const QModelIndex &index) const
431 if( !index.isValid() ) return QModelIndex();
433 PLItem *childItem = static_cast<PLItem*>(index.internalPointer());
434 if( !childItem ) { msg_Err( p_playlist, "NULL CHILD \n" ); return QModelIndex(); }
435 PLItem *parentItem = childItem->parent();
436 if( !parentItem || parentItem == rootItem ) return QModelIndex();
437 if( ! parentItem->parentItem )
439 msg_Err( p_playlist, "No parent parent, trying row 0 " );
440 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
441 return createIndex( 0, 0, parentItem );
443 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
447 int PLModel::columnCount( const QModelIndex &i) const
449 if( i_depth == 1 ) return 1;
453 int PLModel::childrenCount(const QModelIndex &parent) const
455 return rowCount( parent );
458 int PLModel::rowCount(const QModelIndex &parent) const
462 if (!parent.isValid())
463 parentItem = rootItem;
465 parentItem = static_cast<PLItem*>(parent.internalPointer());
467 return parentItem->childCount();
470 /************************* General playlist status ***********************/
472 bool PLModel::hasRandom()
474 if( var_GetBool( p_playlist, "random" ) ) return true;
477 bool PLModel::hasRepeat()
479 if( var_GetBool( p_playlist, "repeat" ) ) return true;
482 bool PLModel::hasLoop()
484 if( var_GetBool( p_playlist, "loop" ) ) return true;
487 void PLModel::setLoop( bool on )
489 var_SetBool( p_playlist, "loop", on ? VLC_TRUE:VLC_FALSE );
490 config_PutInt( p_playlist, "loop", on ? 1: 0 );
492 void PLModel::setRepeat( bool on )
494 var_SetBool( p_playlist, "repeat", on ? VLC_TRUE:VLC_FALSE );
495 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
497 void PLModel::setRandom( bool on )
499 var_SetBool( p_playlist, "random", on ? VLC_TRUE:VLC_FALSE );
500 config_PutInt( p_playlist, "random", on ? 1: 0 );
503 /************************* Lookups *****************************/
505 PLItem *PLModel::FindById( PLItem *root, int i_id )
507 return FindInner( root, i_id, false );
510 PLItem *PLModel::FindByInput( PLItem *root, int i_id )
512 return FindInner( root, i_id, true );
515 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
516 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
518 PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
520 if( ( !b_input && i_cached_id == i_id) ||
521 ( b_input && i_cached_input_id ==i_id ) )
523 return b_input ? p_cached_item_bi : p_cached_item;
526 if( !b_input && root->i_id == i_id )
531 else if( b_input && root->i_input_id == i_id )
533 ICACHE( i_id, root );
537 QList<PLItem *>::iterator it = root->children.begin();
538 while ( it != root->children.end() )
540 if( !b_input && (*it)->i_id == i_id )
542 CACHE( i_id, (*it) );
543 return p_cached_item;
545 else if( b_input && (*it)->i_input_id == i_id )
547 ICACHE( i_id, (*it) );
548 return p_cached_item_bi;
550 if( (*it)->children.size() )
552 PLItem *childFound = FindInner( (*it), i_id, b_input );
556 ICACHE( i_id, childFound )
558 CACHE( i_id, childFound )
570 /************************* Updates handling *****************************/
571 void PLModel::customEvent( QEvent *event )
573 int type = event->type();
574 if( type != ItemUpdate_Type && type != ItemAppend_Type &&
575 type != ItemDelete_Type && type != PLUpdate_Type )
578 PLEvent *ple = static_cast<PLEvent *>(event);
580 if( type == ItemUpdate_Type )
581 ProcessInputItemUpdate( ple->i_id );
582 else if( type == ItemAppend_Type )
583 ProcessItemAppend( ple->p_add );
584 else if( type == ItemDelete_Type )
585 ProcessItemRemoval( ple->i_id );
590 /**** Events processing ****/
591 void PLModel::ProcessInputItemUpdate( int i_input_id )
593 if( i_input_id <= 0 ) return;
594 PLItem *item = FindByInput( rootItem, i_input_id );
596 UpdateTreeItem( item, true );
599 void PLModel::ProcessItemRemoval( int i_id )
601 if( i_id <= 0 ) return;
602 if( i_id == i_cached_id ) i_cached_id = -1;
603 i_cached_input_id = -1;
604 PLItem *item = FindById( rootItem, i_id );
606 item->remove( item );
609 void PLModel::ProcessItemAppend( playlist_add_t *p_add )
611 playlist_item_t *p_item = NULL;
612 PLItem *newItem = NULL;
614 if( b_need_update ) return;
616 PLItem *nodeItem = FindById( rootItem, p_add->i_node );
618 if( !nodeItem ) goto end;
620 p_item = playlist_ItemGetById( p_playlist, p_add->i_item, VLC_TRUE );
621 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
622 if( i_depth == 1 && p_item->p_parent &&
623 p_item->p_parent->i_id != rootItem->i_id )
626 newItem = new PLItem( p_item, nodeItem, this );
627 nodeItem->appendChild( newItem );
628 UpdateTreeItem( p_item, newItem, true );
635 void PLModel::rebuild()
640 void PLModel::rebuild( playlist_item_t *p_root )
642 /* Remove callbacks before locking to avoid deadlocks */
644 /* Invalidate cache */
645 i_cached_id = i_cached_input_id = -1;
651 beginRemoveRows( index( rootItem, 0 ), 0,
652 rootItem->children.size() -1 );
653 qDeleteAll( rootItem->children );
654 rootItem->children.clear();
659 //if( rootItem ) delete rootItem;
660 rootItem = new PLItem( p_root, NULL, this );
661 rootItem->strings[0] = qtr("Name");
662 rootItem->strings[1] = qtr("Artist");
663 rootItem->strings[2] = qtr("Duration");
666 /* Recreate from root */
667 UpdateNodeChildren( rootItem );
668 if( p_playlist->status.p_item )
670 PLItem *currentItem = FindByInput( rootItem,
671 p_playlist->status.p_item->p_input->i_id );
674 UpdateTreeItem( p_playlist->status.p_item, currentItem,
680 /* And signal the view */
681 emit layoutChanged();
685 /* This function must be entered WITH the playlist lock */
686 void PLModel::UpdateNodeChildren( PLItem *root )
688 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id,
690 UpdateNodeChildren( p_node, root );
693 /* This function must be entered WITH the playlist lock */
694 void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
696 for( int i = 0; i < p_node->i_children ; i++ )
698 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
699 PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
700 root->appendChild( newItem, false );
701 UpdateTreeItem( newItem, false, true );
702 if( i_depth != 1 && p_node->pp_children[i]->i_children != -1 )
703 UpdateNodeChildren( p_node->pp_children[i], newItem );
707 /* This function must be entered WITH the playlist lock */
708 void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
710 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
712 UpdateTreeItem( p_item, item, signal, force );
715 /* This function must be entered WITH the playlist lock */
716 void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
717 bool signal, bool force )
719 if( !force && i_depth == 1 && p_item->p_parent &&
720 p_item->p_parent->i_id != rootItem->i_id )
722 item->update( p_item, p_item == p_playlist->status.p_item );
724 emit dataChanged( index( item, 0 ) , index( item, 1 ) );
727 /************************* Actions ******************************/
729 void PLModel::sendArt( QString url )
731 QString arturl = url.replace( "file://",QString("" ) );
732 emit artSet( arturl );
735 void PLModel::removeArt()
737 emit artSet( QString() );
741 * Deletion, here we have to do a ugly slow hack as we retrieve the full
742 * list of indexes to delete at once: when we delete a node and all of
743 * its children, we need to update the list.
744 * Todo: investigate whethere we can use ranges to be sure to delete all items?
746 void PLModel::doDelete( QModelIndexList selected )
748 for( int i = selected.size() -1 ; i >= 0; i-- )
750 QModelIndex index = selected[i];
751 if( index.column() != 0 ) continue;
752 PLItem *item = static_cast<PLItem*>(index.internalPointer());
755 if( item->children.size() )
756 recurseDelete( item->children, &selected );
757 doDeleteItem( item, &selected );
762 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList)
764 for( int i = children.size() - 1; i >= 0 ; i-- )
766 PLItem *item = children[i];
767 if( item->children.size() )
768 recurseDelete( item->children, fullList );
769 doDeleteItem( item, fullList );
773 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
775 QModelIndex deleteIndex = index( item, 0 );
776 fullList->removeAll( deleteIndex );
779 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
785 if( p_item->i_children == -1 )
786 playlist_DeleteFromInput( p_playlist, item->i_input_id, VLC_TRUE );
788 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
789 /* And finally, remove it from the tree */
790 item->remove( item );
794 /******* Volume III: Sorting and searching ********/
795 void PLModel::sort( int column, Qt::SortOrder order )
799 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
805 case 0: i_mode = SORT_TITLE_NODES_FIRST;break;
806 case 1: i_mode = SORT_ARTIST;break;
807 case 2: i_mode = SORT_DURATION; break;
808 default: i_mode = SORT_TITLE_NODES_FIRST; break;
811 playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
812 order == Qt::AscendingOrder ?
813 ORDER_NORMAL : ORDER_REVERSE );
819 void PLModel::search( QString search_text )
821 /** \todo Fire the search with a small delay ? */
824 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
828 char *psz_name = search_text.toUtf8().data();
829 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
835 /*********** Popup *********/
836 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
838 assert( index.isValid() );
840 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
841 itemId( index ), VLC_TRUE );
844 i_popup_item = p_item->i_id;
845 i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
847 current_selection = list;
848 QMenu *menu = new QMenu;
849 menu->addAction( qfu(I_POP_PLAY), this, SLOT( popupPlay() ) );
850 menu->addAction( qfu(I_POP_DEL), this, SLOT( popupDel() ) );
851 menu->addSeparator();
852 menu->addAction( qfu(I_POP_STREAM), this, SLOT( popupStream() ) );
853 menu->addAction( qfu(I_POP_SAVE), this, SLOT( popupSave() ) );
854 menu->addSeparator();
855 menu->addAction( qfu(I_POP_INFO), this, SLOT( popupInfo() ) );
856 if( p_item->i_children > -1 )
858 menu->addSeparator();
859 menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) );
860 menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) );
862 menu->popup( point );
868 void PLModel::popupDel()
870 doDelete( current_selection );
872 void PLModel::popupPlay()
876 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
877 i_popup_item,VLC_TRUE );
878 activateItem( p_item );
883 void PLModel::popupInfo()
885 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
886 i_popup_item,VLC_TRUE );
889 MediaInfoDialog *mid = new MediaInfoDialog( p_intf );
890 mid->setInput( p_item->p_input );
895 void PLModel::popupStream()
897 fprintf( stderr, "Stream not implemented\n" );
899 void PLModel::popupSave()
901 fprintf( stderr, "Save not implemented\n" );
904 /**********************************************************************
906 **********************************************************************/
907 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
908 vlc_value_t oval, vlc_value_t nval, void *param )
910 PLModel *p_model = (PLModel *) param;
911 PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
912 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) );
929 static int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
930 vlc_value_t oval, vlc_value_t nval, void *param )
932 PLModel *p_model = (PLModel *) param;
933 PLEvent *event = new PLEvent( ItemUpdate_Type, nval.i_int );
934 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
939 static int ItemDeleted( 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( ItemDelete_Type, nval.i_int );
944 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
949 static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
950 vlc_value_t oval, vlc_value_t nval, void *param )
952 PLModel *p_model = (PLModel *) param;
953 playlist_add_t *p_add = (playlist_add_t *)malloc( sizeof( playlist_add_t));
954 memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
956 if( ++p_model->i_items_to_append >= 50 )
958 // p_model->b_need_update = VLC_TRUE;
959 // return VLC_SUCCESS;
961 PLEvent *event = new PLEvent( p_add );
962 QApplication::postEvent( p_model, static_cast<QEvent*>(event) );