[vlc-commits] Qt: openItem was almost always used to pass options
Jean-Baptiste Kempf
git at videolan.org
Sun May 18 23:21:21 CEST 2014
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun May 18 17:58:28 2014 +0200| [c4d99d3b17b5ae84b052327ed1a4dceb01539915] | committer: 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
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c4d99d3b17b5ae84b052327ed1a4dceb01539915
---
.../gui/qt4/components/playlist/playlist_model.cpp | 14 ++-------
modules/gui/qt4/dialogs/open.cpp | 19 +----------
modules/gui/qt4/dialogs_provider.cpp | 21 +------------
modules/gui/qt4/recents.cpp | 33 +++++++++++++++-----
modules/gui/qt4/recents.hpp | 5 +--
5 files changed, 33 insertions(+), 59 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index ed53406..27751e9 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -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;
diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp
index 0e53735..ff9aa4b 100644
--- a/modules/gui/qt4/dialogs/open.cpp
+++ b/modules/gui/qt4/dialogs/open.cpp
@@ -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 );
}
}
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 89620c0..097ce39 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -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") );
}
}
diff --git a/modules/gui/qt4/recents.cpp b/modules/gui/qt4/recents.cpp
index 03eb9a8..2df3b85 100755
--- a/modules/gui/qt4/recents.cpp
+++ b/modules/gui/qt4/recents.cpp
@@ -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 );
diff --git a/modules/gui/qt4/recents.hpp b/modules/gui/qt4/recents.hpp
index 530fd22..036b164 100644
--- a/modules/gui/qt4/recents.hpp
+++ b/modules/gui/qt4/recents.hpp
@@ -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>
More information about the vlc-commits
mailing list