[vlmc-devel] [PATCH] Simplify projectNameChanged signal/slots.

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Mar 11 11:19:04 CET 2016


Hi,

On 03/10/2016 04:44 PM, Yikai Lu wrote:
> Since we can use Qt5 and C++11 syntax, I make the code simpler.
>
> Implicit convertion from QVariant to QString on "connect" looks like impossible,
> therefore using lambda
>
> My previous commit message is bad.
> ---
>   src/Project/Project.cpp | 8 +-------
>   src/Project/Project.h   | 1 -
>   2 files changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
> index dee00e9..bc01269 100644
> --- a/src/Project/Project.cpp
> +++ b/src/Project/Project.cpp
> @@ -216,7 +216,7 @@ Project::initSettings()
>                                       QT_TRANSLATE_NOOP( "PreferenceWidget", "Project name" ),
>                                       QT_TRANSLATE_NOOP( "PreferenceWidget", "The project name" ),
>                                       SettingValue::NotEmpty );
> -    connect( pName, SIGNAL( changed( QVariant ) ), this, SLOT( projectNameChanged( QVariant ) ) );
> +    connect( pName, &SettingValue::changed, [=]( const QVariant& var ){ emit projectNameChanged( var.toString() ); } );

Please do not use automatic capture, especially since the this pointer 
is the only thing captured here.

>   }
>
>   void
> @@ -315,12 +315,6 @@ Project::libraryCleanChanged(bool val)
>   }
>
>   void
> -Project::projectNameChanged(const QVariant &projectName)
> -{
> -    emit projectNameChanged( projectName.toString() );
> -}
> -
> -void
>   Project::autoSaveRequired()
>   {
>       if ( m_projectFile == NULL )
> diff --git a/src/Project/Project.h b/src/Project/Project.h
> index 17062d3..e87495e 100644
> --- a/src/Project/Project.h
> +++ b/src/Project/Project.h
> @@ -84,7 +84,6 @@ class Project : public QObject
>       public slots:
>           void                cleanChanged( bool val );
>           void                libraryCleanChanged( bool val );
> -        void                projectNameChanged( const QVariant& projectName); // Proxy slot for projectNameChanged(QString)
>           void                autoSaveRequired();
>           void                autoSaveEnabledChanged( const QVariant& enabled );
>           void                autoSaveIntervalChanged( const QVariant& interval );
>

All good otherwise, thanks!


More information about the Vlmc-devel mailing list