<font color='black' size='2' face='arial'><font face="arial">Cool :]</font>
<div><span style="font-size: 10pt;"><font face="arial">My name is </font></span><span style="font-family: Helvetica, Arial, sans-serif; font-size: 10pt;">Gal VInograd</span>
<div style="font-family: arial;"><br>
<br>

<div style="font-family:arial,helvetica;font-size:10pt;color:black">-----Original Message-----<br>
From: Jean-Baptiste Kempf <jb@videolan.org><br>
To: Mailing list for VLC media player developers <vlc-devel@videolan.org><br>
Sent: Sat, Oct 12, 2013 11:43 pm<br>
Subject: Re: [vlc-devel] [PATCH] Adding "save to playlist" menu item in submenu Recents.<br>
<br>




<div id="AOLMsgPart_0_051b2d2a-4887-4449-8e58-b0541a11fb0d" style="margin: 0px;font-family: Tahoma, Verdana, Arial, Sans-Serif;font-size: 12px;color: #000;background-color: #fff;">

<pre style="font-size: 9pt;"><tt>Patch OK.

Can we have a name and not just a nickname for author?

Le 12/10/2013 23:24, bl3nder a écrit :
> adding RecentsMRL::toPlaylist()
> refactoring functions to eliminate repeating code
> refactoring public DialogProvider::saveAPlaylist() to private 
DialogProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node)
> and making new DialogProvider::savePlayingToPlaylist() and 
DialogProvider::saveRecentsToPlaylist()
>
> this commit includes fixes related to Jean-Baptiste Kempf code review.
>   - fixing whitespace problem
>   - RecentsMRL::toPlaylist null handling
> ---
>   modules/gui/qt4/dialogs_provider.cpp |   25 ++++++++++++++++++++++---
>   modules/gui/qt4/dialogs_provider.hpp |    4 +++-
>   modules/gui/qt4/menus.cpp            |    3 ++-
>   modules/gui/qt4/recents.cpp          |   17 +++++++++++++++++
>   modules/gui/qt4/recents.hpp          |    2 +-
>   5 files changed, 45 insertions(+), 6 deletions(-)
>
> diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
> index 524f476..cc68160 100644
> --- a/modules/gui/qt4/dialogs_provider.cpp
> +++ b/modules/gui/qt4/dialogs_provider.cpp
> @@ -580,7 +580,7 @@ void DialogsProvider::openAPlaylist()
>       }
>   }
>
> -void DialogsProvider::saveAPlaylist()
> +void DialogsProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t 
*p_node)
>   {
>       static const struct
>       {
> @@ -646,12 +646,31 @@ void DialogsProvider::saveAPlaylist()
>
>       if ( psz_selected_module )
>       {
> -        playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
> -                         THEPL->p_playing, psz_selected_module );
> +        playlist_Export( p_playlist, qtu( toNativeSeparators( file ) ),
> +                         p_node, psz_selected_module );
>           getSettings()->setValue( "last-playlist-ext", psz_last_playlist_ext 
);
>       }
>   }
>
> +void DialogsProvider::savePlayingToPlaylist()
> +{
> +    saveAPlaylist(THEPL, THEPL->p_playing);
> +}
> +
> +void DialogsProvider::saveRecentsToPlaylist()
> +{
> +    playlist_item_t *p_node_recents = RecentsMRL::getInstance(p_intf)->toPlaylist(0);
> +
> +    if (p_node_recents == NULL)
> +    {
> +        msg_Warn(p_intf, "cannot create playlist from recents");
> +        return;
> +    }
> +
> +    saveAPlaylist(THEPL, p_node_recents);
> +    playlist_NodeDelete(THEPL, p_node_recents, true, false);
> +}
> +
>   /****************************************************************************
>    * Sout emulation
>    ****************************************************************************/
> diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
> index ef23c4b..00bd37c 100644
> --- a/modules/gui/qt4/dialogs_provider.hpp
> +++ b/modules/gui/qt4/dialogs_provider.hpp
> @@ -111,6 +111,7 @@ private:
>
>       void openDialog( int );
>       void addFromSimple( bool, bool );
> +    void saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node);
>
>   public slots:
>       void playMRL( const QString & );
> @@ -161,7 +162,8 @@ public slots:
>       void openAndTranscodingDialogs();
>
>       void openAPlaylist();
> -    void saveAPlaylist();
> +    void savePlayingToPlaylist();
> +    void saveRecentsToPlaylist();
>
>       void loadSubtitlesFile();
>
> diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
> index 6e10bcb..cace7e8 100644
> --- a/modules/gui/qt4/menus.cpp
> +++ b/modules/gui/qt4/menus.cpp
> @@ -374,7 +374,7 @@ QMenu *VLCMenuBar::FileMenu( intf_thread_t *p_intf, 
QWidget *parent, MainInterfa
>       }
>       menu->addSeparator();
>
> -    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
> +    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( savePlayingToPlaylist() 
),
>           "Ctrl+Y" );
>
>   #ifdef ENABLE_SOUT
> @@ -1624,6 +1624,7 @@ void VLCMenuBar::updateRecents( intf_thread_t *p_intf )
>
>               recentsMenu->addSeparator();
>               recentsMenu->addAction( qtr("&Clear"), rmrl, SLOT( clear() ) );
> +            addDPStaticEntry( recentsMenu, qtr("&Save To Playlist"), "", 
SLOT( saveRecentsToPlaylist() ), "" );
>               recentsMenu->setEnabled( true );
>           }
>       }
> diff --git a/modules/gui/qt4/recents.cpp b/modules/gui/qt4/recents.cpp
> index 75839e8..316b6ee 100755
> --- a/modules/gui/qt4/recents.cpp
> +++ b/modules/gui/qt4/recents.cpp
> @@ -149,3 +149,20 @@ void RecentsMRL::save()
>       getSettings()->setValue( "RecentsMRL/list", *stack );
>   }
>
> +playlist_item_t *RecentsMRL::toPlaylist(int length)
> +{
> +    playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently 
Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG, NULL);
> +
> +    if ( p_node_recent == NULL )  return NULL;
> +
> +    if (length == 0 || stack->count() < length)
> +        length = stack->count();
> +
> +    for (int i = 0; i < length; i++)
> +    {
> +        input_item_t *p_input = input_item_New(qtu(stack->at(i)), NULL);
> +        playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, 
PLAYLIST_END, false);
> +    }
> +
> +    return p_node_recent;
> +}
> diff --git a/modules/gui/qt4/recents.hpp b/modules/gui/qt4/recents.hpp
> index 30bd7c9..ebcf747 100644
> --- a/modules/gui/qt4/recents.hpp
> +++ b/modules/gui/qt4/recents.hpp
> @@ -52,7 +52,7 @@ public:
>
>       void addRecent( const QString & );
>       QStringList recents();
> -
> +    playlist_item_t *toPlaylist(int length);
>       QSignalMapper *signalMapper;
>
>   private:
>


-- 
Jean-Baptiste Kempf
<a href="http://www.jbkempf.com/" target="_blank">http://www.jbkempf.com/</a> - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
<a href="https://mailman.videolan.org/listinfo/vlc-devel" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a>
</tt></pre>
</div>
 <!-- end of AOLMsgPart_0_051b2d2a-4887-4449-8e58-b0541a11fb0d -->



</div>
</div>
</div>
</font>