Commit 88ca3f38 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

skins: use playlist item ID for append (as for delete)

parent ce385e27
......@@ -63,7 +63,7 @@ bool CmdItemUpdate::checkRemove( CmdGeneric *pQueuedCommand ) const
void CmdPlaytreeAppend::execute()
{
VlcProc::instance( getIntf() )->getPlaytreeVar().onAppend( m_pAdd );
VlcProc::instance( getIntf() )->getPlaytreeVar().onAppend( m_id );
}
void CmdPlaytreeDelete::execute()
......
......@@ -69,24 +69,15 @@ private:
class CmdPlaytreeAppend: public CmdGeneric
{
public:
CmdPlaytreeAppend( intf_thread_t *pIntf, playlist_add_t *p_add ):
CmdGeneric( pIntf ), m_pAdd( NULL )
{
if( p_add )
{
m_pAdd = new playlist_add_t;
*m_pAdd = *p_add;
}
}
virtual ~CmdPlaytreeAppend()
{
delete m_pAdd;
}
CmdPlaytreeAppend( intf_thread_t *pIntf, int i_id ):
CmdGeneric( pIntf ), m_id( i_id )
{ }
virtual ~CmdPlaytreeAppend() { }
virtual void execute();
virtual std::string getType() const { return "playtree append"; }
private:
playlist_add_t * m_pAdd;
int m_id;
};
/// Command to notify the playtree of an item deletion
......
......@@ -266,7 +266,7 @@ int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
CmdPlaytreeAppend *pCmdTree =
new CmdPlaytreeAppend( pThis->getIntf(), p_add );
new CmdPlaytreeAppend( pThis->getIntf(), p_add->i_item );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
......
......@@ -205,40 +205,43 @@ void Playtree::onDelete( int i_id )
}
}
void Playtree::onAppend( playlist_add_t *p_add )
void Playtree::onAppend( int i_id )
{
Iterator it_node = findById( p_add->i_node );
playlist_item_t *pItem;
playlist_Lock( m_pPlaylist );
pItem = playlist_ItemGetById( m_pPlaylist, i_id );
if( !pItem || !pItem->p_parent )
{
playlist_Unlock( m_pPlaylist );
return;
}
Iterator it_node = findById( pItem->p_parent->i_id );
if( it_node != m_children.end() )
{
playlist_Lock( m_pPlaylist );
playlist_item_t *pItem =
playlist_ItemGetById( m_pPlaylist, p_add->i_item );
if( !pItem )
{
playlist_Unlock( m_pPlaylist );
return;
}
playlist_Unlock( m_pPlaylist );
return;
}
int pos;
for( pos = 0; pos < pItem->p_parent->i_children; pos++ )
if( pItem->p_parent->pp_children[pos] == pItem ) break;
int pos;
for( pos = 0; pos < pItem->p_parent->i_children; pos++ )
if( pItem->p_parent->pp_children[pos] == pItem ) break;
UString *pName = getTitle( pItem->p_input );
playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );
UString *pName = getTitle( pItem->p_input );
playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );
Iterator it = it_node->add(
p_add->i_item, UStringPtr( pName ), false, pItem == current,
false, pItem->i_flags & PLAYLIST_RO_FLAG, pos );
Iterator it = it_node->add(
i_id, UStringPtr( pName ), false, pItem == current,
false, pItem->i_flags & PLAYLIST_RO_FLAG, pos );
m_allItems[pItem->i_id] = &*it;
m_allItems[i_id] = &*it;
playlist_Unlock( m_pPlaylist );
playlist_Unlock( m_pPlaylist );
tree_update descr(
tree_update::ItemInserted,
IteratorVisible( it, this ) );
notify( &descr );
}
tree_update descr( tree_update::ItemInserted,
IteratorVisible( it, this ) );
notify( &descr );
}
void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
......
......@@ -53,7 +53,7 @@ public:
void onUpdateCurrent( bool b_active );
/// Function called to notify playlist item append
void onAppend( playlist_add_t * );
void onAppend( int );
/// Function called to notify playlist item delete
void onDelete( int );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment