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>
8 * Ilkka Ollakkka <ileoo (at) videolan dot org>
9 * Jakob Leben <jleben@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
31 #include "dialogs_provider.hpp"
32 #include "components/playlist/playlist_model.hpp"
33 #include "dialogs/mediainfo.hpp"
34 #include "dialogs/playlist.hpp"
35 #include <vlc_intf_strings.h>
37 #include "pixmaps/types/type_unknown.xpm"
43 #include <QApplication>
47 #include <QDesktopServices>
48 #include <QInputDialog>
53 I_DIR_OR_FOLDER( N_("Create Directory"), N_( "Create Folder" ) )
54 #define I_NEW_DIR_NAME \
55 I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
56 N_( "Enter name for new folder:" ) )
58 QIcon PLModel::icons[ITEM_TYPE_NUMBER];
60 /*************************************************************************
61 * Playlist model implementation
62 *************************************************************************/
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 QObject *parent ) /* Basic Qt parent */
68 : QAbstractItemModel( parent )
71 p_playlist = _p_playlist;
73 i_cached_input_id = -1;
74 i_popup_item = i_popup_parent = -1;
76 rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
78 /* Icons initialization */
79 #define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( x )
80 ADD_ICON( UNKNOWN , type_unknown_xpm );
81 ADD_ICON( FILE, ":/type/file" );
82 ADD_ICON( DIRECTORY, ":/type/directory" );
83 ADD_ICON( DISC, ":/type/disc" );
84 ADD_ICON( CDDA, ":/type/cdda" );
85 ADD_ICON( CARD, ":/type/capture-card" );
86 ADD_ICON( NET, ":/type/net" );
87 ADD_ICON( PLAYLIST, ":/type/playlist" );
88 ADD_ICON( NODE, ":/type/node" );
92 CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
93 this, processInputItemUpdate( input_item_t *) );
94 CONNECT( THEMIM, inputChanged( input_thread_t * ),
95 this, processInputItemUpdate( input_thread_t* ) );
96 CONNECT( THEMIM, playlistItemAppended( int, int ),
97 this, processItemAppend( int, int ) );
98 CONNECT( THEMIM, playlistItemRemoved( int ),
99 this, processItemRemoval( int ) );
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 flags = QAbstractItemModel::flags( index );
116 PLItem *item = index.isValid() ? getItem( index ) : rootItem;
121 playlist_item_t *plItem =
122 playlist_ItemGetById( p_playlist, item->i_id );
124 if ( plItem && ( plItem->i_children > -1 ) )
125 flags |= Qt::ItemIsDropEnabled;
130 flags |= Qt::ItemIsDragEnabled;
135 QStringList PLModel::mimeTypes() const
138 types << "vlc/qt-playlist-item";
142 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
144 QMimeData *mimeData = new QMimeData();
145 QByteArray encodedData;
146 QDataStream stream( &encodedData, QIODevice::WriteOnly );
147 QModelIndexList list;
149 foreach( const QModelIndex &index, indexes ) {
150 if( index.isValid() && index.column() == 0 )
156 foreach( const QModelIndex &index, list ) {
157 PLItem *item = getItem( index );
158 stream.writeRawData( (char*) &item, sizeof( PLItem* ) );
160 mimeData->setData( "vlc/qt-playlist-item", encodedData );
165 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
166 int row, int column, const QModelIndex &parent )
168 if( data->hasFormat( "vlc/qt-playlist-item" ) )
170 if( action == Qt::IgnoreAction )
173 PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
176 playlist_item_t *p_parent =
177 playlist_ItemGetById( p_playlist, parentItem->i_id );
178 if( !p_parent || p_parent->i_children == -1 )
185 playlist_item_t *p_pl = p_playlist->p_playing;
186 playlist_item_t *p_ml = p_playlist->p_media_library;
190 ( p_pl && p_parent == p_pl ) ||
191 ( p_ml && p_parent == p_ml ) )
196 QByteArray encodedData = data->data( "vlc/qt-playlist-item" );
198 dropAppendCopy( encodedData, parentItem );
200 dropMove( encodedData, parentItem, row );
205 void PLModel::dropAppendCopy( QByteArray& data, PLItem *target )
207 QDataStream stream( &data, QIODevice::ReadOnly );
210 playlist_item_t *p_parent =
211 playlist_ItemGetById( p_playlist, target->i_id );
212 while( !stream.atEnd() )
215 stream.readRawData( (char*)&item, sizeof(PLItem*) );
216 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
217 if( !p_item ) continue;
218 input_item_t *p_input = p_item->p_input;
219 playlist_AddExt ( p_playlist,
220 p_input->psz_uri, p_input->psz_name,
221 PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
223 p_input->i_options, p_input->ppsz_options, p_input->optflagc,
224 p_parent == p_playlist->p_playing,
230 void PLModel::dropMove( QByteArray& data, PLItem *target, int row )
232 QDataStream stream( &data, QIODevice::ReadOnly );
233 QList<PLItem*> model_items;
235 int new_pos = row == -1 ? target->children.size() : row;
236 int model_pos = new_pos;
237 while( !stream.atEnd() )
240 stream.readRawData( (char*)&item, sizeof(PLItem*) );
242 /* better not try to move a node into itself: */
243 PLItem *climber = target;
246 if( climber == item ) break;
247 climber = climber->parentItem;
249 if( climber ) continue;
251 if( item->parentItem == target &&
252 target->children.indexOf( item ) < model_pos )
255 ids.append( item->i_id );
256 model_items.append( item );
260 int count = ids.size();
263 playlist_item_t *pp_items[count];
266 for( int i = 0; i < count; i++ )
268 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, ids[i] );
274 pp_items[i] = p_item;
276 playlist_item_t *p_parent =
277 playlist_ItemGetById( p_playlist, target->i_id );
278 playlist_TreeMoveMany( p_playlist, count, pp_items, p_parent,
282 insertChildren( target, model_items, model_pos );
286 /* remove item with its id */
287 void PLModel::removeItem( int i_id )
289 PLItem *item = findById( rootItem, i_id );
293 void PLModel::activateItem( const QModelIndex &index )
295 assert( index.isValid() );
296 PLItem *item = getItem( index );
299 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
300 activateItem( p_item );
304 /* Must be entered with lock */
305 void PLModel::activateItem( playlist_item_t *p_item )
307 if( !p_item ) return;
308 playlist_item_t *p_parent = p_item;
311 if( p_parent->i_id == rootItem->i_id ) break;
312 p_parent = p_parent->p_parent;
315 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
319 /****************** Base model mandatory implementations *****************/
320 QVariant PLModel::data( const QModelIndex &index, int role ) const
322 if( !index.isValid() ) return QVariant();
323 PLItem *item = getItem( index );
324 if( role == Qt::DisplayRole )
326 int metadata = columnToMeta( index.column() );
327 if( metadata == COLUMN_END ) return QVariant();
330 if( metadata == COLUMN_NUMBER )
331 returninfo = QString::number( index.row() + 1 );
334 char *psz = psz_column_meta( item->p_input, metadata );
335 returninfo = qfu( psz );
338 return QVariant( returninfo );
340 else if( role == Qt::DecorationRole && index.column() == 0 )
342 /* Used to segfault here because i_type wasn't always initialized */
343 return QVariant( PLModel::icons[item->p_input->i_type] );
345 else if( role == Qt::FontRole )
347 if( isCurrent( index ) )
349 QFont f; f.setBold( true ); return QVariant( f );
352 else if( role == Qt::BackgroundRole && isCurrent( index ) )
354 return QVariant( QBrush( Qt::gray ) );
356 else if( role == IsCurrentRole ) return QVariant( isCurrent( index ) );
361 bool PLModel::isCurrent( const QModelIndex &index ) const
363 return getItem( index )->p_input == THEMIM->currentInputItem();
366 int PLModel::itemId( const QModelIndex &index ) const
368 return getItem( index )->i_id;
371 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
374 if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
377 int meta_col = columnToMeta( section );
379 if( meta_col == COLUMN_END ) return QVariant();
381 return QVariant( qfu( psz_column_title( meta_col ) ) );
384 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
387 PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
389 PLItem *childItem = parentItem->child( row );
391 return createIndex( row, column, childItem );
393 return QModelIndex();
396 QModelIndex PLModel::index( int i_id, int c )
398 return index( findById( rootItem, i_id ), c );
401 /* Return the index of a given item */
402 QModelIndex PLModel::index( PLItem *item, int column ) const
404 if( !item ) return QModelIndex();
405 const PLItem *parent = item->parent();
407 return createIndex( parent->children.lastIndexOf( item ),
409 return QModelIndex();
412 QModelIndex PLModel::currentIndex()
414 input_thread_t *p_input_thread = THEMIM->getInput();
415 if( !p_input_thread ) return QModelIndex();
416 PLItem *item = findByInput( rootItem, input_GetItem( p_input_thread )->i_id );
417 return index( item, 0 );
420 QModelIndex PLModel::parent( const QModelIndex &index ) const
422 if( !index.isValid() ) return QModelIndex();
424 PLItem *childItem = getItem( index );
427 msg_Err( p_playlist, "NULL CHILD" );
428 return QModelIndex();
431 PLItem *parentItem = childItem->parent();
432 if( !parentItem || parentItem == rootItem ) return QModelIndex();
433 if( !parentItem->parentItem )
435 msg_Err( p_playlist, "No parent parent, trying row 0 " );
436 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
437 return createIndex( 0, 0, parentItem );
439 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
443 int PLModel::columnCount( const QModelIndex &i) const
445 return columnFromMeta( COLUMN_END );
448 int PLModel::rowCount( const QModelIndex &parent ) const
450 PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
451 return parentItem->childCount();
454 QStringList PLModel::selectedURIs()
457 for( int i = 0; i < current_selection.size(); i++ )
459 PLItem *item = getItem( current_selection[i] );
463 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
466 char *psz = input_item_GetURI( p_item->p_input );
469 lst.append( qfu(psz) );
480 /************************* Lookups *****************************/
482 PLItem *PLModel::findById( PLItem *root, int i_id )
484 return findInner( root, i_id, false );
487 PLItem *PLModel::findByInput( PLItem *root, int i_id )
489 PLItem *result = findInner( root, i_id, true );
493 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
494 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
496 PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
498 if( !root ) return NULL;
499 if( ( !b_input && i_cached_id == i_id) ||
500 ( b_input && i_cached_input_id ==i_id ) )
502 return b_input ? p_cached_item_bi : p_cached_item;
505 if( !b_input && root->i_id == i_id )
510 else if( b_input && root->p_input->i_id == i_id )
512 ICACHE( i_id, root );
516 QList<PLItem *>::iterator it = root->children.begin();
517 while ( it != root->children.end() )
519 if( !b_input && (*it)->i_id == i_id )
521 CACHE( i_id, (*it) );
522 return p_cached_item;
524 else if( b_input && (*it)->p_input->i_id == i_id )
526 ICACHE( i_id, (*it) );
527 return p_cached_item_bi;
529 if( (*it)->children.size() )
531 PLItem *childFound = findInner( (*it), i_id, b_input );
535 ICACHE( i_id, childFound )
537 CACHE( i_id, childFound )
548 int PLModel::columnToMeta( int _column )
553 while( column != _column && meta != COLUMN_END )
562 int PLModel::columnFromMeta( int meta_col )
567 while( meta != meta_col && meta != COLUMN_END )
576 bool PLModel::canEdit() const
581 rootItem->p_input == p_playlist->p_playing->p_input ||
583 p_playlist->p_media_library &&
584 rootItem->p_input == p_playlist->p_media_library->p_input
589 /************************* Updates handling *****************************/
591 /**** Events processing ****/
592 void PLModel::processInputItemUpdate( input_thread_t *p_input )
594 if( !p_input ) return;
595 if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
597 PLItem *item = findByInput( rootItem, input_GetItem( p_input )->i_id );
598 if( item ) emit currentChanged( index( item, 0 ) );
600 processInputItemUpdate( input_GetItem( p_input ) );
603 void PLModel::processInputItemUpdate( input_item_t *p_item )
605 if( !p_item || p_item->i_id <= 0 ) return;
606 PLItem *item = findByInput( rootItem, p_item->i_id );
608 updateTreeItem( item );
611 void PLModel::processItemRemoval( int i_id )
613 if( i_id <= 0 ) return;
617 void PLModel::processItemAppend( int i_item, int i_parent )
619 playlist_item_t *p_item = NULL;
620 PLItem *newItem = NULL;
621 input_thread_t *currentInputThread;
624 PLItem *nodeItem = findById( rootItem, i_parent );
625 if( !nodeItem ) return;
627 foreach( PLItem *existing, nodeItem->children )
628 if( existing->i_id == i_item ) return;
631 p_item = playlist_ItemGetById( p_playlist, i_item );
632 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG )
637 for( pos = 0; pos < p_item->p_parent->i_children; pos++ )
638 if( p_item->p_parent->pp_children[pos] == p_item ) break;
640 newItem = new PLItem( p_item, nodeItem );
643 beginInsertRows( index( nodeItem, 0 ), pos, pos );
644 nodeItem->insertChild( newItem, pos );
647 if( newItem->p_input == THEMIM->currentInputItem() )
648 emit currentChanged( index( newItem, 0 ) );
652 void PLModel::rebuild()
657 void PLModel::rebuild( playlist_item_t *p_root )
659 playlist_item_t* p_item;
661 /* Invalidate cache */
662 i_cached_id = i_cached_input_id = -1;
664 if( rootItem ) rootItem->removeChildren();
670 rootItem = new PLItem( p_root );
673 /* Recreate from root */
674 updateChildren( rootItem );
677 /* And signal the view */
680 if( p_root ) emit rootChanged();
683 void PLModel::takeItem( PLItem *item )
686 PLItem *parent = item->parentItem;
688 int i_index = parent->children.indexOf( item );
690 beginRemoveRows( index( parent, 0 ), i_index, i_index );
691 parent->takeChildAt( i_index );
695 void PLModel::insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
698 int count = items.size();
700 beginInsertRows( index( node, 0 ), i_pos, i_pos + count - 1 );
701 for( int i = 0; i < count; i++ )
703 node->children.insert( i_pos + i, items[i] );
704 items[i]->parentItem = node;
709 void PLModel::removeItem( PLItem *item )
713 if( item->i_id == i_cached_id ) i_cached_id = -1;
714 i_cached_input_id = -1;
716 if( item->parentItem ) {
717 int i = item->parentItem->children.indexOf( item );
718 beginRemoveRows( index( item->parentItem, 0), i, i );
719 item->parentItem->children.removeAt(i);
728 rebuild( p_playlist->p_playing );
732 /* This function must be entered WITH the playlist lock */
733 void PLModel::updateChildren( PLItem *root )
735 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
736 updateChildren( p_node, root );
739 /* This function must be entered WITH the playlist lock */
740 void PLModel::updateChildren( playlist_item_t *p_node, PLItem *root )
742 for( int i = 0; i < p_node->i_children ; i++ )
744 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
745 PLItem *newItem = new PLItem( p_node->pp_children[i], root );
746 root->appendChild( newItem );
747 if( p_node->pp_children[i]->i_children != -1 )
748 updateChildren( p_node->pp_children[i], newItem );
752 /* Function doesn't need playlist-lock, as we don't touch playlist_item_t stuff here*/
753 void PLModel::updateTreeItem( PLItem *item )
756 emit dataChanged( index( item, 0 ) , index( item, columnCount( QModelIndex() ) ) );
759 /************************* Actions ******************************/
762 * Deletion, here we have to do a ugly slow hack as we retrieve the full
763 * list of indexes to delete at once: when we delete a node and all of
764 * its children, we need to update the list.
765 * Todo: investigate whethere we can use ranges to be sure to delete all items?
767 void PLModel::doDelete( QModelIndexList selected )
769 if( !canEdit() ) return;
771 while( !selected.isEmpty() )
773 QModelIndex index = selected[0];
774 selected.removeAt( 0 );
776 if( index.column() != 0 ) continue;
778 PLItem *item = getItem( index );
779 if( item->children.size() )
780 recurseDelete( item->children, &selected );
783 playlist_DeleteFromInput( p_playlist, item->p_input, pl_Locked );
790 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
792 for( int i = children.size() - 1; i >= 0 ; i-- )
794 PLItem *item = children[i];
795 if( item->children.size() )
796 recurseDelete( item->children, fullList );
797 fullList->removeAll( index( item, 0 ) );
801 /******* Volume III: Sorting and searching ********/
802 void PLModel::sort( int column, Qt::SortOrder order )
804 sort( rootItem->i_id, column, order );
807 void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
809 msg_Dbg( p_intf, "Sorting by column %i, order %i", column, order );
811 int meta = columnToMeta( column );
812 if( meta == COLUMN_END ) return;
814 PLItem *item = findById( rootItem, i_root_id );
816 QModelIndex qIndex = index( item, 0 );
817 int count = item->children.size();
820 beginRemoveRows( qIndex, 0, count - 1 );
821 item->removeChildren();
827 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
831 playlist_RecursiveNodeSort( p_playlist, p_root,
832 i_column_sorting( meta ),
833 order == Qt::AscendingOrder ?
834 ORDER_NORMAL : ORDER_REVERSE );
838 i_cached_id = i_cached_input_id = -1;
842 beginInsertRows( qIndex, 0, count - 1 );
843 updateChildren( item );
849 void PLModel::search( const QString& search_text, const QModelIndex & idx, bool b_recursive )
851 /** \todo Fire the search with a small delay ? */
854 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
857 const char *psz_name = qtu( search_text );
858 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name, b_recursive );
862 PLItem *searchRoot = getItem( idx );
864 beginRemoveRows( idx, 0, searchRoot->children.size() - 1 );
865 searchRoot->removeChildren();
868 beginInsertRows( idx, 0, searchRoot->children.size() - 1 );
869 updateChildren( searchRoot );
880 /*********** Popup *********/
881 bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
883 int i_id = index.isValid() ? itemId( index ) : rootItem->i_id;
886 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
893 i_popup_item = index.isValid() ? p_item->i_id : -1;
894 i_popup_parent = index.isValid() ?
895 ( p_item->p_parent ? p_item->p_parent->i_id : -1 ) :
897 i_popup_column = index.column();
899 bool tree = ( rootItem && rootItem->i_id != p_playlist->p_playing->i_id ) ||
900 var_InheritBool( p_intf, "playlist-tree" );
904 current_selection = list;
907 if( i_popup_item > -1 )
909 menu.addAction( QIcon( ":/menu/play" ), qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
910 menu.addAction( QIcon( ":/buttons/playlist/playlist_remove" ),
911 qtr(I_POP_DEL), this, SLOT( popupDel() ) );
913 menu.addAction( QIcon( ":/menu/stream" ),
914 qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
915 menu.addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
917 menu.addAction( QIcon( ":/menu/info" ), qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
918 menu.addAction( QIcon( ":/type/folder-grey" ),
919 qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
923 QIcon addIcon( ":/buttons/playlist/playlist_add" );
925 if( tree ) menu.addAction( addIcon, qtr(I_POP_NEWFOLDER), this, SLOT( popupAddNode() ) );
926 if( rootItem->i_id == THEPL->p_playing->i_id )
928 menu.addAction( addIcon, qtr(I_PL_ADDF), THEDP, SLOT( simplePLAppendDialog()) );
929 menu.addAction( addIcon, qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) );
930 menu.addAction( addIcon, qtr(I_OP_ADVOP), THEDP, SLOT( PLAppendDialog()) );
932 else if( THEPL->p_media_library &&
933 rootItem->i_id == THEPL->p_media_library->i_id )
935 menu.addAction( addIcon, qtr(I_PL_ADDF), THEDP, SLOT( simpleMLAppendDialog()) );
936 menu.addAction( addIcon, qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
937 menu.addAction( addIcon, qtr(I_OP_ADVOP), THEDP, SLOT( MLAppendDialog() ) );
940 if( i_popup_item > -1 )
943 QMenu *sort_menu = menu.addMenu( qtr( "Sort by" ) + QString(" ") +
944 qfu( psz_column_title( columnToMeta( index.column() ) ) ) );
945 sort_menu->addAction( qtr( "Ascending" ),
946 this, SLOT( popupSortAsc() ) );
947 sort_menu->addAction( qtr( "Descending" ),
948 this, SLOT( popupSortDesc() ) );
950 if( !menu.isEmpty() )
952 menu.exec( point ); return true;
957 void PLModel::popupDel()
959 doDelete( current_selection );
962 void PLModel::popupPlay()
966 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
968 activateItem( p_item );
973 void PLModel::popupInfo()
976 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
980 input_item_t* p_input = p_item->p_input;
981 vlc_gc_incref( p_input );
983 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
984 vlc_gc_decref( p_input );
985 mid->setParent( PlaylistDialog::getInstance( p_intf ),
992 void PLModel::popupStream()
994 QStringList mrls = selectedURIs();
995 if( !mrls.isEmpty() )
996 THEDP->streamingDialog( NULL, mrls[0], false );
1000 void PLModel::popupSave()
1002 QStringList mrls = selectedURIs();
1003 if( !mrls.isEmpty() )
1004 THEDP->streamingDialog( NULL, mrls[0] );
1007 void PLModel::popupExplore()
1010 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
1014 input_item_t *p_input = p_item->p_input;
1015 char *psz_meta = input_item_GetURI( p_input );
1019 const char *psz_access;
1020 const char *psz_demux;
1022 input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
1024 if( !EMPTY_STR( psz_access ) && (
1025 !strncasecmp( psz_access, "file", 4 ) ||
1026 !strncasecmp( psz_access, "dire", 4 ) ))
1028 QFileInfo info( qfu( psz_path ) );
1029 QDesktopServices::openUrl(
1030 QUrl::fromLocalFile( info.absolutePath() ) );
1039 void PLModel::popupAddNode()
1042 QString name = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
1043 qtr( I_NEW_DIR ), qtr( I_NEW_DIR_NAME ),
1044 QLineEdit::Normal, QString(), &ok);
1045 if( !ok || name.isEmpty() ) return;
1047 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
1051 playlist_NodeCreate( p_playlist, qtu( name ), p_item, 0, NULL );
1056 void PLModel::popupSortAsc()
1058 sort( i_popup_parent, i_popup_column, Qt::AscendingOrder );
1061 void PLModel::popupSortDesc()
1063 sort( i_popup_parent, i_popup_column, Qt::DescendingOrder );