Example #1
0
bool MLModel::event( QEvent *event )
{
    if ( event->type() == MLEvent::MediaAdded_Type )
    {
        event->accept();
        MLEvent *e = static_cast<MLEvent *>(event);
        vlc_array_t* p_result = vlc_array_new();
        if ( ml_FindMedia( e->p_ml, p_result, ML_ID, e->ml_media_id ) == VLC_SUCCESS )
        {
            insertResultArray( p_result );
            ml_DestroyResultArray( p_result );
        }
        vlc_array_destroy( p_result );
        return true;
    }
    else if( event->type() == MLEvent::MediaRemoved_Type )
    {
        event->accept();
        MLEvent *e = static_cast<MLEvent *>(event);
        removeRow( getIndexByMLID( e->ml_media_id ).row() );
        return true;
    }
    else if( event->type() == MLEvent::MediaUpdated_Type )
    {
        event->accept();
        /* Never implemented... */
        return true;
    }

    return VLCModel::event( event );
}
/**
 * @brief Definition of the result item model for the result tree
 * @param parent the parent Qt object
 */
MLModel::MLModel( intf_thread_t* _p_intf, QObject *parent )
        :VLCModel( _p_intf, parent )
{
    p_ml = ml_Get( p_intf );
    vlc_array_t *p_result_array = vlc_array_new();
    ml_Find( p_ml, p_result_array, ML_MEDIA );
    insertResultArray( p_result_array );

    var_AddCallback( p_ml, "media-added", mediaAdded, this );
    var_AddCallback( p_ml, "media-deleted", mediaDeleted, this );
    var_AddCallback( p_ml, "media-meta-change", mediaUpdated, this );
}