Commit 874efde6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Playlist simplification in leaf-to-parent management

parent 65d1e784
...@@ -109,9 +109,8 @@ TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t) ...@@ -109,9 +109,8 @@ TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t)
* - "playlist-item-deleted": It will contain the playlist_item_t->i_id of a * - "playlist-item-deleted": It will contain the playlist_item_t->i_id of a
* deleted playlist_item_t. * deleted playlist_item_t.
* *
* - "leaf-to-parent": Set when an item gets subitems and is transformed to a * - "leaf-to-parent": It will contain the playlist_item_t->i_id of an item that is transformed
* node. It will contain a pointer to the input_item_t bound to the transformed * into a node.
* playlist item.
* *
* The playlist contains rate-variable which is propagated to current input if available * The playlist contains rate-variable which is propagated to current input if available
* also rate-slower/rate-faster is in use * also rate-slower/rate-faster is in use
......
...@@ -79,8 +79,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -79,8 +79,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
int i_savedViewMode = getSettings()->value( "Playlist/view-mode", TREE_VIEW ).toInt(); int i_savedViewMode = getSettings()->value( "Playlist/view-mode", TREE_VIEW ).toInt();
showView( i_savedViewMode ); showView( i_savedViewMode );
DCONNECT( THEMIM, leafBecameParent( input_item_t *), DCONNECT( THEMIM, leafBecameParent( int ),
this, browseInto( input_item_t * ) ); this, browseInto( int ) );
CONNECT( model, currentChanged( const QModelIndex& ), CONNECT( model, currentChanged( const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
...@@ -451,20 +451,11 @@ void StandardPLPanel::activate( const QModelIndex &index ) ...@@ -451,20 +451,11 @@ void StandardPLPanel::activate( const QModelIndex &index )
} }
} }
void StandardPLPanel::browseInto( input_item_t *p_input ) void StandardPLPanel::browseInto( int i_id )
{ {
if( p_input->i_id != lastActivatedId ) return; if( i_id != lastActivatedId ) return;
playlist_Lock( THEPL ); QModelIndex index = model->index( i_id, 0 );
playlist_item_t *p_item = playlist_ItemGetByInput( THEPL, p_input );
if( !p_item )
{
playlist_Unlock( THEPL );
return;
}
QModelIndex index = model->index( p_item->i_id, 0 );
playlist_Unlock( THEPL ); playlist_Unlock( THEPL );
if( currentView == treeView ) if( currentView == treeView )
......
...@@ -111,7 +111,7 @@ private slots: ...@@ -111,7 +111,7 @@ private slots:
void activate( const QModelIndex & ); void activate( const QModelIndex & );
void browseInto(); void browseInto();
void browseInto( input_item_t * ); void browseInto( int );
void gotoPlayingItem(); void gotoPlayingItem();
......
...@@ -1027,8 +1027,8 @@ void MainInputManager::customEvent( QEvent *event ) ...@@ -1027,8 +1027,8 @@ void MainInputManager::customEvent( QEvent *event )
notifyRepeatLoop(); notifyRepeatLoop();
return; return;
case LeafToParent_Type: case LeafToParent_Type:
imEv = static_cast<IMEvent*>( event ); plEv = static_cast<PLEvent*>( event );
emit leafBecameParent( imEv->p_item ); emit leafBecameParent( plEv->i_item );
return; return;
default: default:
if( type != ItemChanged_Type ) return; if( type != ItemChanged_Type ) return;
...@@ -1186,8 +1186,8 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var, ...@@ -1186,8 +1186,8 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var,
VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval );
MainInputManager *mim = (MainInputManager*)param; MainInputManager *mim = (MainInputManager*)param;
IMEvent *event = new IMEvent( LeafToParent_Type, PLEvent *event = new PLEvent( LeafToParent_Type, newval.i_int );
static_cast<input_item_t*>( newval.p_address ) );
QApplication::postEvent( mim, event ); QApplication::postEvent( mim, event );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -107,9 +107,13 @@ enum PLEventTypes ...@@ -107,9 +107,13 @@ enum PLEventTypes
class PLEvent : public QEvent class PLEvent : public QEvent
{ {
public: public:
PLEvent( PLEventTypes t, int i, int p ) PLEvent( int t, int i, int p = 0 )
: QEvent( (QEvent::Type)t ), i_item(i), i_parent(p) {} : QEvent( (QEvent::Type)(t) ), i_item(i), i_parent(p) {}
/* Needed for "playlist-item*" and "leaf-to-parent" callbacks
* !! Can be a input_item_t->i_id or a playlist_item_t->i_id */
int i_item; int i_item;
// Needed for "playlist-item-append" callback, notably
int i_parent; int i_parent;
}; };
...@@ -290,7 +294,7 @@ signals: ...@@ -290,7 +294,7 @@ signals:
void playlistItemRemoved( int itemId ); void playlistItemRemoved( int itemId );
void randomChanged( bool ); void randomChanged( bool );
void repeatLoopChanged( int ); void repeatLoopChanged( int );
void leafBecameParent( input_item_t * ); void leafBecameParent( int );
}; };
#endif #endif
...@@ -126,7 +126,7 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event, ...@@ -126,7 +126,7 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
pos, pos,
b_flat ); b_flat );
if( !b_flat ) var_SetAddress( p_playlist, "leaf-to-parent", p_input ); if( !b_flat ) var_SetAddress( p_playlist, "leaf-to-parent", p_item->i_id );
//control playback only if it was the current playing item that got subitems //control playback only if it was the current playing item that got subitems
if( b_current ) if( b_current )
......
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