Commit c4d99d3b authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: openItem was almost always used to pass options

So, create a method using QStringList and not input_item.
This should be cleaner in the calling sites, and avoid
calling input_item_new from Qt code
parent 2d8ef3b2
......@@ -889,7 +889,6 @@ bool PLModel::action( QAction *action, const QModelIndexList &indexes )
{
QModelIndex index;
actionsContainerType a = action->data().value<actionsContainerType>();
input_item_t *p_input;
switch ( a.action )
{
......@@ -950,17 +949,8 @@ bool PLModel::action( QAction *action, const QModelIndexList &indexes )
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 );
}
Open::openInput( p_intf, p_input, uri, false );
QStringList options = a.options.split( " :" );
Open::openInput( p_intf, uri, &options, false );
}
return true;
......
......@@ -377,28 +377,11 @@ void OpenDialog::enqueue( bool b_enqueue )
{
bool b_start = !i && !b_enqueue;
input_item_t *p_input_item;
p_input_item = input_item_New( qtu( itemsMRL[i] ), NULL );
/* Take options from the UI, not from what we stored */
QStringList optionsList = getOptions().split( " :" );
/* Insert options */
for( int j = 0; j < optionsList.count(); j++ )
{
QString qs = colon_unescape( optionsList[j] );
if( !qs.isEmpty() )
{
input_item_AddOption( p_input_item, 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 */
Open::openInput( p_intf, p_input_item, itemsMRL[i], b_start, b_pl );
Open::openInput( p_intf, itemsMRL[i], &optionsList, b_start, b_pl );
}
}
......
......@@ -700,26 +700,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
{
options += soutoption.split( " :");
/* Create Input */
input_item_t *p_input;
p_input = input_item_New( qtu( mrl ), _("Streaming") );
/* Add normal Options */
for( int j = 0; j < options.count(); j++ )
{
QString qs = colon_unescape( options[j] );
if( !qs.isEmpty() )
{
input_item_AddOption( p_input, qtu( qs ),
VLC_INPUT_OPTION_TRUSTED );
msg_Dbg( p_intf, "Adding option: %s", qtu( qs ) );
}
}
/* Switch between enqueuing and starting the item */
Open::openInput( p_intf, p_input, mrl, true, true );
vlc_gc_decref( p_input );
Open::openInput( p_intf, mrl, &options, true, true, _("Streaming") );
}
}
......
......@@ -26,6 +26,7 @@
#include "recents.hpp"
#include "dialogs_provider.hpp"
#include "menus.hpp"
#include "util/qt_dirs.hpp"
#include <QStringList>
#include <QRegExp>
......@@ -82,8 +83,6 @@ void RecentsMRL::addRecent( const QString &mrl )
if ( !isActive || ( filter && filter->indexIn( mrl ) >= 0 ) )
return;
msg_Dbg( p_intf, "Adding a new MRL to recent ones: %s", qtu( mrl ) );
#ifdef _WIN32
/* Add to the Windows 7 default list in taskbar */
char* path = make_path( qtu( mrl ) );
......@@ -184,14 +183,34 @@ void Open::openMRL( intf_thread_t *p_intf,
}
int Open::openInput( intf_thread_t* p_intf,
input_item_t *p_item,
const QString &mrl,
bool b_start,
bool b_playlist)
const QString &mrl,
const QStringList *options,
bool b_start,
bool b_playlist,
const char *title)
{
int i_ret = playlist_AddInput( THEPL, p_item,
const char **ppsz_options = NULL;
int i_options = 0;
if( options != NULL && options->count() > 0 )
{
ppsz_options = (const char **)malloc( options->count() );
if( ppsz_options ) {
for( int j = 0; j < options->count(); j++ ) {
QString option = colon_unescape( options->at(j) );
if( !option.isEmpty() ) {
ppsz_options[j] = qtu(option);
i_options++;
}
}
}
}
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 );
......
......@@ -44,10 +44,11 @@ public:
bool b_playlist = true);
int static openInput( intf_thread_t*,
input_item_t *,
const QString &,
const QStringList *options,
bool b_start = true,
bool b_playlist = true);
bool b_playlist = true,
const char* title = NULL);
};
class RecentsMRL : public QObject, public Singleton<RecentsMRL>
......
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