Commit aca7ce70 authored by jpd's avatar jpd
Browse files

Qt4: remove PlaylistEventManager

parent 6a25ed7c
......@@ -148,54 +148,3 @@ void PlaylistWidget::closeEvent( QCloseEvent *event )
event->ignore();
}
}
PlaylistEventManager::PlaylistEventManager( playlist_t *_pl )
: pl( _pl )
{
var_AddCallback( pl, "playlist-item-append", itemAddedCb, this );
var_AddCallback( pl, "playlist-item-deleted", itemRemovedCb, this );
}
PlaylistEventManager::~PlaylistEventManager()
{
var_DelCallback( pl, "playlist-item-append", itemAddedCb, this );
var_DelCallback( pl, "playlist-item-deleted", itemRemovedCb, this );
}
int PlaylistEventManager::itemAddedCb
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{
PlaylistEventManager *p_this = static_cast<PlaylistEventManager*>(data);
p_this->trigger( cur, ItemAddedEv );
return VLC_SUCCESS;
}
int PlaylistEventManager::itemRemovedCb
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{
PlaylistEventManager *p_this = static_cast<PlaylistEventManager*>(data);
p_this->trigger( cur, ItemRemovedEv );
return VLC_SUCCESS;
}
void PlaylistEventManager::trigger( vlc_value_t val, int type )
{
if( type == ItemAddedEv )
{
playlist_add_t *p_add = static_cast<playlist_add_t*>( val.p_address );
QApplication::postEvent( this, new PLEMEvent( type, p_add->i_item, p_add->i_node ) );
}
else
{
QApplication::postEvent( this, new PLEMEvent( type, val.i_int, 0 ) );
}
}
void PlaylistEventManager::customEvent( QEvent *e )
{
PLEMEvent *ev = static_cast<PLEMEvent*>(e);
if( (int) ev->type() == ItemAddedEv )
emit itemAdded( ev->item, ev->parent );
else
emit itemRemoved( ev->item );
}
......@@ -81,34 +81,4 @@ enum PLEventType {
ItemRemovedEv
};
class PLEMEvent : public QEvent
{
public:
PLEMEvent( int t, int i, int p )
: QEvent( (QEvent::Type)t ), item(i), parent(p) {}
int item;
int parent;
};
class PlaylistEventManager : public QObject
{
Q_OBJECT;
public:
PlaylistEventManager( playlist_t* );
~PlaylistEventManager();
signals:
void itemAdded( int i_item, int i_parent );
void itemRemoved( int i_id );
private:
static int itemAddedCb ( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int itemRemovedCb ( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
void trigger( vlc_value_t, int );
void customEvent( QEvent* );
playlist_t *pl;
};
#endif
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