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

Yikai Lu luyikei.qmltu at gmail.com
Thu Mar 10 16:44:02 CET 2016


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() ); } );
 }
 
 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 );
-- 
1.9.1



More information about the Vlmc-devel mailing list