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>
48 QIcon PLModel::icons[ITEM_TYPE_NUMBER];
50 /*************************************************************************
51 * Playlist model implementation
52 *************************************************************************/
55 This model is called two times, for the selector and the standard panel
57 PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
58 intf_thread_t *_p_intf, /* main Qt p_intf */
59 playlist_item_t * p_root,
60 /*playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
61 and THEPL->p_root_category for SelectPL */
62 QObject *parent ) /* Basic Qt parent */
63 : QAbstractItemModel( parent )
66 p_playlist = _p_playlist;
68 i_cached_input_id = -1;
69 i_popup_item = i_popup_parent = -1;
72 rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
74 /* Icons initialization */
75 #define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( x )
76 ADD_ICON( UNKNOWN , type_unknown_xpm );
77 ADD_ICON( FILE, ":/type/file" );
78 ADD_ICON( DIRECTORY, ":/type/directory" );
79 ADD_ICON( DISC, ":/type/disc" );
80 ADD_ICON( CDDA, ":/type/cdda" );
81 ADD_ICON( CARD, ":/type/capture-card" );
82 ADD_ICON( NET, ":/type/net" );
83 ADD_ICON( PLAYLIST, ":/type/playlist" );
84 ADD_ICON( NODE, ":/type/node" );
87 rebuild( p_root, true );
88 CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
89 this, processInputItemUpdate( input_item_t *) );
90 CONNECT( THEMIM, inputChanged( input_thread_t * ),
91 this, processInputItemUpdate( input_thread_t* ) );
92 CONNECT( THEMIM, playlistItemAppended( int, int ),
93 this, processItemAppend( int, int ) );
94 CONNECT( THEMIM, playlistItemRemoved( int ),
95 this, processItemRemoval( int ) );
103 Qt::DropActions PLModel::supportedDropActions() const
105 return Qt::CopyAction; /* Why not Qt::MoveAction */
108 Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
110 Qt::ItemFlags flags = QAbstractItemModel::flags( index );
112 PLItem *item = index.isValid() ? getItem( index ) : rootItem;
117 playlist_item_t *plItem =
118 playlist_ItemGetById( p_playlist, item->i_id );
120 if ( plItem && ( plItem->i_children > -1 ) )
121 flags |= Qt::ItemIsDropEnabled;
126 flags |= Qt::ItemIsDragEnabled;
131 QStringList PLModel::mimeTypes() const
134 types << "vlc/qt-playlist-item";
138 QMimeData *PLModel::mimeData( const QModelIndexList &indexes ) const
140 QMimeData *mimeData = new QMimeData();
141 QByteArray encodedData;
142 QDataStream stream( &encodedData, QIODevice::WriteOnly );
143 QModelIndexList list;
145 foreach( const QModelIndex &index, indexes ) {
146 if( index.isValid() && index.column() == 0 )
152 foreach( const QModelIndex &index, list ) {
153 PLItem *item = getItem( index );
154 stream.writeRawData( (char*) &item, sizeof( PLItem* ) );
156 mimeData->setData( "vlc/qt-playlist-item", encodedData );
161 bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
162 int row, int column, const QModelIndex &parent )
164 if( data->hasFormat( "vlc/qt-playlist-item" ) )
166 if( action == Qt::IgnoreAction )
169 PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
172 playlist_item_t *p_parent =
173 playlist_ItemGetById( p_playlist, parentItem->i_id );
174 if( !p_parent || p_parent->i_children == -1 )
181 playlist_item_t *p_pl = p_playlist->p_local_category;
182 playlist_item_t *p_ml = p_playlist->p_ml_category;
186 ( p_pl && p_parent->p_input == p_pl->p_input ) ||
187 ( p_ml && p_parent->p_input == p_ml->p_input ) )
192 QByteArray encodedData = data->data( "vlc/qt-playlist-item" );
194 dropAppendCopy( encodedData, parentItem );
196 dropMove( encodedData, parentItem, row );
201 void PLModel::dropAppendCopy( QByteArray& data, PLItem *target )
203 QDataStream stream( &data, QIODevice::ReadOnly );
206 playlist_item_t *p_parent =
207 playlist_ItemGetById( p_playlist, target->i_id );
208 while( !stream.atEnd() )
211 stream.readRawData( (char*)&item, sizeof(PLItem*) );
212 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
213 if( !p_item ) continue;
214 input_item_t *p_input = p_item->p_input;
215 playlist_AddExt ( p_playlist,
216 p_input->psz_uri, p_input->psz_name,
217 PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
219 p_input->i_options, p_input->ppsz_options, p_input->optflagc,
220 ( p_parent == p_playlist->p_local_category ||
221 p_parent == p_playlist->p_local_onelevel ),
227 void PLModel::dropMove( QByteArray& data, PLItem *target, int row )
229 QDataStream stream( &data, QIODevice::ReadOnly );
230 QList<PLItem*> model_items;
232 int new_pos = row == -1 ? target->children.size() : row;
233 int model_pos = new_pos;
234 while( !stream.atEnd() )
237 stream.readRawData( (char*)&item, sizeof(PLItem*) );
239 /* better not try to move a node into itself: */
240 PLItem *climber = target;
243 if( climber == item ) break;
244 climber = climber->parentItem;
246 if( climber ) continue;
248 if( item->parentItem == target &&
249 target->children.indexOf( item ) < model_pos )
252 ids.append( item->i_id );
253 model_items.append( item );
257 int count = ids.size();
260 playlist_item_t *pp_items[count];
263 for( int i = 0; i < count; i++ )
265 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, ids[i] );
271 pp_items[i] = p_item;
273 playlist_item_t *p_parent =
274 playlist_ItemGetById( p_playlist, target->i_id );
275 playlist_TreeMoveMany( p_playlist, count, pp_items, p_parent,
279 insertChildren( target, model_items, model_pos );
283 /* remove item with its id */
284 void PLModel::removeItem( int i_id )
286 PLItem *item = findById( rootItem, i_id );
290 void PLModel::activateItem( const QModelIndex &index )
292 assert( index.isValid() );
293 PLItem *item = getItem( index );
296 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
297 activateItem( p_item );
301 /* Must be entered with lock */
302 void PLModel::activateItem( playlist_item_t *p_item )
304 if( !p_item ) return;
305 playlist_item_t *p_parent = p_item;
308 if( p_parent->i_id == rootItem->i_id ) break;
309 p_parent = p_parent->p_parent;
312 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
316 /****************** Base model mandatory implementations *****************/
317 QVariant PLModel::data( const QModelIndex &index, int role ) const
319 if( !index.isValid() ) return QVariant();
320 PLItem *item = getItem( index );
321 if( role == Qt::DisplayRole )
323 int metadata = columnToMeta( index.column() );
324 if( metadata == COLUMN_END ) return QVariant();
327 if( metadata == COLUMN_NUMBER )
328 returninfo = QString::number( index.row() + 1 );
331 char *psz = psz_column_meta( item->p_input, metadata );
332 returninfo = qfu( psz );
335 return QVariant( returninfo );
337 else if( role == Qt::DecorationRole && index.column() == 0 )
339 /* Use to segfault here because i_type wasn't always initialized */
340 if( item->p_input->i_type >= 0 )
341 return QVariant( PLModel::icons[item->p_input->i_type] );
343 else if( role == Qt::FontRole )
345 if( isCurrent( index ) )
347 QFont f; f.setBold( true ); return QVariant( f );
353 bool PLModel::isCurrent( const QModelIndex &index ) const
355 if( !currentItem ) return false;
356 return getItem( index )->p_input == currentItem->p_input;
359 int PLModel::itemId( const QModelIndex &index ) const
361 return getItem( index )->i_id;
364 QVariant PLModel::headerData( int section, Qt::Orientation orientation,
367 if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
370 int meta_col = columnToMeta( section );
372 if( meta_col == COLUMN_END ) return QVariant();
374 return QVariant( qfu( psz_column_title( meta_col ) ) );
377 QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
380 PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
382 PLItem *childItem = parentItem->child( row );
384 return createIndex( row, column, childItem );
386 return QModelIndex();
389 /* Return the index of a given item */
390 QModelIndex PLModel::index( PLItem *item, int column ) const
392 if( !item ) return QModelIndex();
393 const PLItem *parent = item->parent();
395 return createIndex( parent->children.lastIndexOf( item ),
397 return QModelIndex();
400 QModelIndex PLModel::parent( const QModelIndex &index ) const
402 if( !index.isValid() ) return QModelIndex();
404 PLItem *childItem = getItem( index );
407 msg_Err( p_playlist, "NULL CHILD" );
408 return QModelIndex();
411 PLItem *parentItem = childItem->parent();
412 if( !parentItem || parentItem == rootItem ) return QModelIndex();
413 if( !parentItem->parentItem )
415 msg_Err( p_playlist, "No parent parent, trying row 0 " );
416 msg_Err( p_playlist, "----- PLEASE REPORT THIS ------" );
417 return createIndex( 0, 0, parentItem );
419 QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
423 int PLModel::columnCount( const QModelIndex &i) const
425 return columnFromMeta( COLUMN_END );
428 int PLModel::rowCount( const QModelIndex &parent ) const
430 PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
431 return parentItem->childCount();
434 QStringList PLModel::selectedURIs()
437 for( int i = 0; i < current_selection.size(); i++ )
439 PLItem *item = getItem( current_selection[i] );
443 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
446 char *psz = input_item_GetURI( p_item->p_input );
449 lst.append( qfu(psz) );
459 /************************* General playlist status ***********************/
461 bool PLModel::hasRandom()
463 return var_GetBool( p_playlist, "random" );
465 bool PLModel::hasRepeat()
467 return var_GetBool( p_playlist, "repeat" );
469 bool PLModel::hasLoop()
471 return var_GetBool( p_playlist, "loop" );
473 void PLModel::setLoop( bool on )
475 var_SetBool( p_playlist, "loop", on ? true:false );
476 config_PutInt( p_playlist, "loop", on ? 1: 0 );
478 void PLModel::setRepeat( bool on )
480 var_SetBool( p_playlist, "repeat", on ? true:false );
481 config_PutInt( p_playlist, "repeat", on ? 1: 0 );
483 void PLModel::setRandom( bool on )
485 var_SetBool( p_playlist, "random", on ? true:false );
486 config_PutInt( p_playlist, "random", on ? 1: 0 );
489 /************************* Lookups *****************************/
491 PLItem *PLModel::findById( PLItem *root, int i_id )
493 return findInner( root, i_id, false );
496 PLItem *PLModel::findByInput( PLItem *root, int i_id )
498 PLItem *result = findInner( root, i_id, true );
502 #define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
503 #define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
505 PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
507 if( !root ) return NULL;
508 if( ( !b_input && i_cached_id == i_id) ||
509 ( b_input && i_cached_input_id ==i_id ) )
511 return b_input ? p_cached_item_bi : p_cached_item;
514 if( !b_input && root->i_id == i_id )
519 else if( b_input && root->p_input->i_id == i_id )
521 ICACHE( i_id, root );
525 QList<PLItem *>::iterator it = root->children.begin();
526 while ( it != root->children.end() )
528 if( !b_input && (*it)->i_id == i_id )
530 CACHE( i_id, (*it) );
531 return p_cached_item;
533 else if( b_input && (*it)->p_input->i_id == i_id )
535 ICACHE( i_id, (*it) );
536 return p_cached_item_bi;
538 if( (*it)->children.size() )
540 PLItem *childFound = findInner( (*it), i_id, b_input );
544 ICACHE( i_id, childFound )
546 CACHE( i_id, childFound )
557 PLItem *PLModel::getItem( QModelIndex index )
559 assert( index.isValid() );
560 return static_cast<PLItem*>( index.internalPointer() );
563 int PLModel::columnToMeta( int _column ) const
568 while( column != _column && meta != COLUMN_END )
577 int PLModel::columnFromMeta( int meta_col ) const
582 while( meta != meta_col && meta != COLUMN_END )
591 bool PLModel::canEdit() const
596 rootItem->p_input == p_playlist->p_local_category->p_input ||
598 p_playlist->p_ml_category &&
599 rootItem->p_input == p_playlist->p_ml_category->p_input
604 /************************* Updates handling *****************************/
606 /**** Events processing ****/
607 void PLModel::processInputItemUpdate( input_thread_t *p_input )
609 if( !p_input ) return;
610 processInputItemUpdate( input_GetItem( p_input ) );
611 if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
613 PLItem *item = findByInput( rootItem, input_GetItem( p_input )->i_id );
615 emit currentChanged( index( item, 0 ) );
622 void PLModel::processInputItemUpdate( input_item_t *p_item )
624 if( !p_item || p_item->i_id <= 0 ) return;
625 PLItem *item = findByInput( rootItem, p_item->i_id );
627 updateTreeItem( item );
630 void PLModel::processItemRemoval( int i_id )
632 if( i_id <= 0 ) return;
636 void PLModel::processItemAppend( int i_item, int i_parent )
638 playlist_item_t *p_item = NULL;
639 PLItem *newItem = NULL;
641 PLItem *nodeItem = findById( rootItem, i_parent );
642 if( !nodeItem ) return;
644 foreach( PLItem *existing, nodeItem->children )
645 if( existing->i_id == i_item ) return;
648 p_item = playlist_ItemGetById( p_playlist, i_item );
649 if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
651 newItem = new PLItem( p_item, nodeItem );
654 beginInsertRows( index( nodeItem, 0 ), nodeItem->childCount(), nodeItem->childCount() );
655 nodeItem->appendChild( newItem );
657 updateTreeItem( newItem );
665 void PLModel::rebuild()
667 rebuild( NULL, false );
670 void PLModel::rebuild( playlist_item_t *p_root, bool b_first )
672 playlist_item_t* p_item;
674 /* Invalidate cache */
675 i_cached_id = i_cached_input_id = -1;
677 if( rootItem ) rootItem->removeChildren();
683 rootItem = new PLItem( p_root );
686 /* Recreate from root */
687 updateChildren( rootItem );
688 if( (p_item = playlist_CurrentPlayingItem(p_playlist)) )
689 currentItem = findByInput( rootItem, p_item->p_input->i_id );
694 /* And signal the view */
697 emit currentChanged( index( currentItem, 0 ) );
700 void PLModel::takeItem( PLItem *item )
703 PLItem *parent = item->parentItem;
705 int i_index = parent->children.indexOf( item );
707 beginRemoveRows( index( parent, 0 ), i_index, i_index );
708 parent->takeChildAt( i_index );
712 void PLModel::insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
715 int count = items.size();
717 beginInsertRows( index( node, 0 ), i_pos, i_pos + count - 1 );
718 for( int i = 0; i < count; i++ )
720 node->children.insert( i_pos + i, items[i] );
721 items[i]->parentItem = node;
726 void PLModel::removeItem( PLItem *item )
730 if( item->i_id == i_cached_id ) i_cached_id = -1;
731 i_cached_input_id = -1;
733 if( currentItem == item || rootItem == item)
736 emit currentChanged( QModelIndex() );
742 if( item->parentItem ) {
743 int i = item->parentItem->children.indexOf( item );
744 beginRemoveRows( index( item->parentItem, 0), i, i );
745 item->parentItem->children.removeAt(i);
753 /* This function must be entered WITH the playlist lock */
754 void PLModel::updateChildren( PLItem *root )
756 playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
757 updateChildren( p_node, root );
760 /* This function must be entered WITH the playlist lock */
761 void PLModel::updateChildren( playlist_item_t *p_node, PLItem *root )
763 playlist_item_t *p_item = playlist_CurrentPlayingItem(p_playlist);
764 for( int i = 0; i < p_node->i_children ; i++ )
766 if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
767 PLItem *newItem = new PLItem( p_node->pp_children[i], root );
768 root->appendChild( newItem );
769 if( p_item && newItem->p_input == p_item->p_input )
771 currentItem = newItem;
772 emit currentChanged( index( currentItem, 0 ) );
774 if( p_node->pp_children[i]->i_children != -1 )
775 updateChildren( p_node->pp_children[i], newItem );
779 /* Function doesn't need playlist-lock, as we don't touch playlist_item_t stuff here*/
780 void PLModel::updateTreeItem( PLItem *item )
783 emit dataChanged( index( item, 0 ) , index( item, columnCount( QModelIndex() ) ) );
786 /************************* Actions ******************************/
789 * Deletion, here we have to do a ugly slow hack as we retrieve the full
790 * list of indexes to delete at once: when we delete a node and all of
791 * its children, we need to update the list.
792 * Todo: investigate whethere we can use ranges to be sure to delete all items?
794 void PLModel::doDelete( QModelIndexList selected )
796 if( !canEdit() ) return;
798 for( int i = selected.size() -1 ; i >= 0; i-- )
800 QModelIndex index = selected[i];
801 if( index.column() != 0 ) continue;
802 PLItem *item = getItem( index );
805 if( item->children.size() )
806 recurseDelete( item->children, &selected );
807 doDeleteItem( item, &selected );
809 if( i > selected.size() ) i = selected.size();
813 void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList )
815 for( int i = children.size() - 1; i >= 0 ; i-- )
817 PLItem *item = children[i];
818 if( item->children.size() )
819 recurseDelete( item->children, fullList );
820 doDeleteItem( item, fullList );
824 void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
826 QModelIndex deleteIndex = index( item, 0 );
827 fullList->removeAll( deleteIndex );
830 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
836 if( p_item->i_children == -1 )
837 playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
839 playlist_NodeDelete( p_playlist, p_item, true, false );
842 /* And finally, remove it from the tree */
846 /******* Volume III: Sorting and searching ********/
847 void PLModel::sort( int column, Qt::SortOrder order )
849 sort( rootItem->i_id, column, order );
852 void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
854 int meta = columnToMeta( column );
855 if( meta == COLUMN_END ) return;
857 PLItem *item = findById( rootItem, i_root_id );
859 QModelIndex qIndex = index( item, 0 );
860 int count = item->children.size();
863 beginRemoveRows( qIndex, 0, count - 1 );
864 item->removeChildren();
870 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
874 playlist_RecursiveNodeSort( p_playlist, p_root,
875 i_column_sorting( meta ),
876 order == Qt::AscendingOrder ?
877 ORDER_NORMAL : ORDER_REVERSE );
882 beginInsertRows( qIndex, 0, count - 1 );
883 updateChildren( item );
889 void PLModel::search( const QString& search_text )
891 /** \todo Fire the search with a small delay ? */
894 playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
897 const char *psz_name = search_text.toUtf8().data();
898 playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
904 /*********** Popup *********/
905 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
907 int i_id = index.isValid() ? itemId( index ) : rootItem->i_id;
910 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
915 i_popup_item = index.isValid() ? p_item->i_id : -1;
916 i_popup_parent = index.isValid() ?
917 ( p_item->p_parent ? p_item->p_parent->i_id : -1 ) :
919 i_popup_column = index.column();
920 /* check whether we are in tree view */
922 playlist_item_t *p_up = p_item;
925 if ( p_up == p_playlist->p_root_category ) tree = true;
926 p_up = p_up->p_parent;
930 current_selection = list;
933 if( i_popup_item > -1 )
935 menu.addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
936 menu.addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
938 menu.addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
939 menu.addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
941 menu.addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
943 QMenu *sort_menu = menu.addMenu( qtr( "Sort by ") +
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( tree && canEdit() )
951 menu.addAction( qtr(I_POP_ADD), this, SLOT( popupAddNode() ) );
952 if( i_popup_item > -1 )
955 menu.addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
957 if( !menu.isEmpty() ) menu.exec( point );
960 void PLModel::popupDel()
962 doDelete( current_selection );
965 void PLModel::popupPlay()
969 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
971 activateItem( p_item );
976 void PLModel::popupInfo()
979 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
983 input_item_t* p_input = p_item->p_input;
984 vlc_gc_incref( p_input );
986 MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
987 vlc_gc_decref( p_input );
988 mid->setParent( PlaylistDialog::getInstance( p_intf ),
995 void PLModel::popupStream()
997 QStringList mrls = selectedURIs();
998 if( !mrls.isEmpty() )
999 THEDP->streamingDialog( NULL, mrls[0], false );
1003 void PLModel::popupSave()
1005 QStringList mrls = selectedURIs();
1006 if( !mrls.isEmpty() )
1007 THEDP->streamingDialog( NULL, mrls[0] );
1011 #include <QFileInfo>
1012 #include <QDesktopServices>
1013 void PLModel::popupExplore()
1016 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
1020 input_item_t *p_input = p_item->p_input;
1021 char *psz_meta = input_item_GetURI( p_input );
1025 const char *psz_access;
1026 const char *psz_demux;
1028 input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
1030 if( EMPTY_STR( psz_access ) ||
1031 !strncasecmp( psz_access, "file", 4 ) ||
1032 !strncasecmp( psz_access, "dire", 4 ) )
1034 QFileInfo info( qfu( psz_meta ) );
1035 QDesktopServices::openUrl(
1036 QUrl::fromLocalFile( info.absolutePath() ) );
1045 #include <QInputDialog>
1046 void PLModel::popupAddNode()
1049 QString name = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
1050 qtr( I_POP_ADD ), qtr( "Enter name for new node:" ),
1051 QLineEdit::Normal, QString(), &ok);
1052 if( !ok || name.isEmpty() ) return;
1054 playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
1058 playlist_NodeCreate( p_playlist, qtu( name ), p_item, 0, NULL );
1063 void PLModel::popupSortAsc()
1065 sort( i_popup_parent, i_popup_column, Qt::AscendingOrder );
1068 void PLModel::popupSortDesc()
1070 sort( i_popup_parent, i_popup_column, Qt::DescendingOrder );