Esempio n. 1
0
void OpenDialog::finish( bool b_enqueue = false )
{
    toggleVisible();

    if( i_action_flag == SELECT )
    {
        accept();
        return;
    }

    /* Sort alphabetically */
    itemsMRL.sort();

    /* Go through the item list */
    for( int i = 0; i < itemsMRL.size(); i++ )
    {
        bool b_start = !i && !b_enqueue;

        input_item_t *p_input;
        p_input = input_item_New( qtu( itemsMRL[i] ), NULL );

        /* Insert options only for the first element.
           We don't know how to edit that anyway. */
        if( i == 0 )
        {
            /* Take options from the UI, not from what we stored */
            QStringList optionsList = ui.advancedLineInput->text().split( " :" );

            /* Insert options */
            for( int j = 0; j < optionsList.size(); j++ )
            {
                QString qs = colon_unescape( optionsList[j] );
                if( !qs.isEmpty() )
                {
                    input_item_AddOption( p_input, qtu( qs ),
                                          VLC_INPUT_OPTION_TRUSTED );
#ifdef DEBUG_QT
                    msg_Warn( p_intf, "Input option: %s", qtu( qs ) );
#endif
                }
            }
        }

        /* Switch between enqueuing and starting the item */
        /* FIXME: playlist_AddInput() can fail */
        playlist_AddInput( THEPL, p_input,
                PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
                PLAYLIST_END, b_pl ? true : false, pl_Unlocked );
        vlc_gc_decref( p_input );

        /* Do not add the current MRL if playlist_AddInput fail */
        RecentsMRL::getInstance( p_intf )->addRecent( itemsMRL[i] );
    }
}
Esempio n. 2
0
int Open::openMRLwithOptions( intf_thread_t* p_intf,
                     const QString &mrl,
                     QStringList *options,
                     bool b_start,
                     bool b_playlist,
                     const char *title)
{
    /* Options */
    const char **ppsz_options = NULL;
    int i_options = 0;

    if( options != NULL && options->count() > 0 )
    {
        ppsz_options = new const char *[options->count()];
        for( int j = 0; j < options->count(); j++ ) {
            QString option = colon_unescape( options->at(j) );
            if( !option.isEmpty() ) {
                ppsz_options[i_options] = strdup(qtu(option));
                i_options++;
            }
        }
    }

    /* Add to playlist */
    int i_ret = playlist_AddExt( THEPL,
                  qtu(mrl), title,
                  PLAYLIST_APPEND | (b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE),
                  PLAYLIST_END,
                  -1,
                  i_options, ppsz_options, VLC_INPUT_OPTION_TRUSTED,
                  b_playlist,
                  pl_Unlocked );

    /* Add to recent items, only if played */
    if( i_ret == VLC_SUCCESS && b_start && b_playlist )
        RecentsMRL::getInstance( p_intf )->addRecent( mrl );

    /* Free options */
    if ( ppsz_options != NULL )
    {
        for ( int i = 0; i < i_options; ++i )
            free( (char*)ppsz_options[i] );
        delete[] ppsz_options;
    }
    return i_ret;
}
Esempio n. 3
0
bool MLModel::action( QAction *action, const QModelIndexList &indexes )
{
    actionsContainerType a = action->data().value<actionsContainerType>();
    input_item_t *p_input;

    switch ( a.action )
    {

    case ACTION_PLAY:
        if ( ! indexes.empty() && indexes.first().isValid() )
        {
            activateItem( indexes.first() );
            return true;
        }
        break;

    case ACTION_ADDTOPLAYLIST:
        foreach( const QModelIndex &index, indexes )
        {
            if( !index.isValid() ) return false;
            AddItemToPlaylist( itemId( index, MLMEDIA_ID ), false, p_ml, true );
        }
        return true;

    case ACTION_REMOVE:
        doDelete( indexes );
        return true;

    case ACTION_SORT:
        break;

    case ACTION_CLEAR:
        removeAll();
        return true;

    case ACTION_ENQUEUEFILE:
        foreach( const QString &uri, a.uris )
            playlist_Add( THEPL, uri.toAscii().constData(),
                          NULL, PLAYLIST_APPEND | PLAYLIST_PREPARSE,
                          PLAYLIST_END, false, pl_Unlocked );
        return true;

    case ACTION_ENQUEUEDIR:
        if( a.uris.isEmpty() ) return false;
        p_input = input_item_New( a.uris.first().toAscii().constData(), NULL );
        if( unlikely( p_input == NULL ) ) return false;

        /* FIXME: playlist_AddInput() can fail */
        playlist_AddInput( THEPL, p_input,
                           PLAYLIST_APPEND,
                           PLAYLIST_END, true, pl_Unlocked );
        vlc_gc_decref( p_input );
        return true;

    case ACTION_ENQUEUEGENERIC:
        foreach( const QString &uri, a.uris )
        {
            p_input = input_item_New( qtu( uri ), NULL );
            /* Insert options */
            foreach( const QString &option, a.options.split( " :" ) )
            {
                QString temp = colon_unescape( option );
                if( !temp.isEmpty() )
                    input_item_AddOption( p_input, qtu( temp ),
                                          VLC_INPUT_OPTION_TRUSTED );
            }

            /* FIXME: playlist_AddInput() can fail */
            playlist_AddInput( THEPL, p_input,
                    PLAYLIST_APPEND | PLAYLIST_PREPARSE,
                    PLAYLIST_END, false, pl_Unlocked );
            vlc_gc_decref( p_input );
        }
        return true;

    default:
        break;
    }
    return false;
}