#include "qt4.hpp"
#include "playlist_model.hpp"
+#include "dialogs/mediainfo.hpp"
#include <vlc_intf_strings.h>
#include "pixmaps/type_unknown.xpm"
strings[2] = QString( psz_duration );
type = p_item->p_input->i_type;
current = iscurrent;
+
if( current && p_item->p_input->p_meta &&
p_item->p_input->p_meta->psz_arturl &&
!strncmp( p_item->p_input->p_meta->psz_arturl, "file://", 7 ) )
- {
model->sendArt( qfu( p_item->p_input->p_meta->psz_arturl ) );
- }
+ else if( current )
+ model->removeArt();
}
/*************************************************************************
* Playlist model implementation
*************************************************************************/
-PLModel::PLModel( playlist_t *_p_playlist,
+PLModel::PLModel( playlist_t *_p_playlist, intf_thread_t *_p_intf,
playlist_item_t * p_root, int _i_depth, QObject *parent)
: QAbstractItemModel(parent)
{
i_depth = _i_depth;
assert( i_depth == 1 || i_depth == -1 );
+ p_intf = _p_intf;
p_playlist= _p_playlist;
i_items_to_append = 0;
b_need_update = false;
PL_LOCK;
playlist_item_t *p_target =
- playlist_ItemGetById( p_playlist, targetItem->i_id );
- playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId );
+ playlist_ItemGetById( p_playlist, targetItem->i_id,
+ VLC_TRUE );
+ playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId,
+ VLC_TRUE );
if( !p_target || !p_src )
{
PL_UNLOCK;
return false;
}
-
if( p_target->i_children == -1 ) /* A leaf */
{
PLItem *parentItem = targetItem->parent();
assert( parentItem );
playlist_item_t *p_parent =
- playlist_ItemGetById( p_playlist, parentItem->i_id );
+ playlist_ItemGetById( p_playlist, parentItem->i_id,
+ VLC_TRUE );
if( !p_parent )
{
PL_UNLOCK;
newParentItem = targetItem;
}
/* Remove from source */
- PLItem *srcItem = FindByInput( rootItem, p_src->p_input->i_id );
- srcItem->remove( srcItem );
+ PLItem *srcItem = FindById( rootItem, p_src->i_id );
+ // We dropped on the source selector. Ask the dialog to forward
+ // to the main view
+ if( !srcItem )
+ {
+ emit shouldRemove( p_src->i_id );
+ }
+ else
+ srcItem->remove( srcItem );
+
/* Display at new destination */
PLItem *newItem = new PLItem( p_src, newParentItem, this );
newParentItem->insertChild( newItem, i, true );
}
}
return true;
- }
+}
+void PLModel::removeItem( int i_id )
+{
+ PLItem *item = FindById( rootItem,i_id );
+ if( item ) item->remove( item );
+}
void PLModel::addCallbacks()
{
PLItem *item = static_cast<PLItem*>(index.internalPointer());
assert( item );
PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
+ VLC_TRUE);
activateItem( p_item );
PL_UNLOCK;
}
p_parent = p_parent->p_parent;
}
if( p_parent )
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_parent, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_parent, p_item );
}
/****************** Base model mandatory implementations *****************/
PL_LOCK;
if( !nodeItem ) goto end;
- p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
+ p_item = playlist_ItemGetById( p_playlist, p_add->i_item, VLC_TRUE );
if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
if( i_depth == 1 && p_item->p_parent &&
p_item->p_parent->i_id != rootItem->i_id )
/* This function must be entered WITH the playlist lock */
void PLModel::UpdateNodeChildren( PLItem *root )
{
- playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
+ playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id,
+ VLC_TRUE );
UpdateNodeChildren( p_node, root );
}
/* This function must be entered WITH the playlist lock */
void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
{
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
+ VLC_TRUE );
UpdateTreeItem( p_item, item, signal, force );
}
emit artSet( arturl );
}
+void PLModel::removeArt()
+{
+ emit artSet( QString() );
+}
+
/**
* Deletion, here we have to do a ugly slow hack as we retrieve the full
* list of indexes to delete at once: when we delete a node and all of
fullList->removeAll( deleteIndex );
PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
+ VLC_TRUE );
if( !p_item )
{
PL_UNLOCK; return;
}
if( p_item->i_children == -1 )
- playlist_DeleteAllFromInput( p_playlist, item->i_input_id );
+ playlist_DeleteFromInput( p_playlist, item->i_input_id, VLC_TRUE );
else
playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
/* And finally, remove it from the tree */
void PLModel::sort( int column, Qt::SortOrder order )
{
PL_LOCK;
- playlist_item_t *p_root = playlist_ItemGetById( p_playlist, rootItem->i_id );
- int i_mode;
- switch( column )
{
- case 0: i_mode = SORT_TITLE_NODES_FIRST;break;
- case 1: i_mode = SORT_ARTIST;break;
- case 2: i_mode = SORT_DURATION; break;
- default: i_mode = SORT_TITLE_NODES_FIRST; break;
+ playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
+ rootItem->i_id,
+ VLC_TRUE );
+ int i_mode;
+ switch( column )
+ {
+ case 0: i_mode = SORT_TITLE_NODES_FIRST;break;
+ case 1: i_mode = SORT_ARTIST;break;
+ case 2: i_mode = SORT_DURATION; break;
+ default: i_mode = SORT_TITLE_NODES_FIRST; break;
+ }
+ if( p_root )
+ playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
+ order == Qt::AscendingOrder ?
+ ORDER_NORMAL : ORDER_REVERSE );
}
- if( p_root )
- playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
- order == Qt::AscendingOrder ? ORDER_NORMAL :
- ORDER_REVERSE );
PL_UNLOCK
rebuild();
}
{
/** \todo Fire the search with a small delay ? */
PL_LOCK;
- playlist_item_t *p_root = playlist_ItemGetById( p_playlist,rootItem->i_id );
- assert( p_root );
- char *psz_name = search_text.toUtf8().data();
- playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
+ {
+ playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
+ rootItem->i_id,
+ VLC_TRUE );
+ assert( p_root );
+ char *psz_name = search_text.toUtf8().data();
+ playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
+ }
PL_UNLOCK;
rebuild();
}
assert( index.isValid() );
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
- itemId( index ) );
+ itemId( index ), VLC_TRUE );
if( p_item )
{
i_popup_item = p_item->i_id;
void PLModel::popupPlay()
{
PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_popup_item );
- activateItem( p_item );
+ {
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
+ i_popup_item,VLC_TRUE );
+ activateItem( p_item );
+ }
PL_UNLOCK;
}
void PLModel::popupInfo()
{
- fprintf( stderr, "Popup Info is NOT implemented\n" );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
+ i_popup_item,VLC_TRUE );
+ if( p_item )
+ {
+ MediaInfoDialog *mid = new MediaInfoDialog( p_intf );
+ mid->setInput( p_item->p_input );
+ mid->show();
+ }
}
void PLModel::popupStream()