Skip to content

Commit 977a6b2

Browse files
committed
完善property生成
1 parent 771c1f5 commit 977a6b2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

components/QtGroup/PropertyMaker/cpp/propertymaker.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Manage::Manage()
2323
propertyMaker_[ "READ" ] = [](const QString &type, const QString &functionName, const QString &valueName, const QString &, const bool &withThreadSafe, const QString &className)->QPair< QString, QString >
2424
{
2525
QString statementTemplate =
26-
"public: Q_SLOT inline %TYPE% %FUNCTION_NAME%() const;\n";
26+
"public: inline %TYPE% %FUNCTION_NAME%() const;\n";
2727

2828
QString accomplishCode =
2929
"inline %TYPE% %CLASS_NAME%::%FUNCTION_NAME%() const\n"
@@ -51,7 +51,7 @@ Manage::Manage()
5151
propertyMaker_[ "WRITE" ] = [](const QString &type, const QString &functionName, const QString &valueName, const QString &notifyFunctionName, const bool &withThreadSafe, const QString &className)->QPair< QString, QString >
5252
{
5353
QString statementTemplate =
54-
"public: Q_SLOT inline void %FUNCTION_NAME%(const %TYPE% &newValue);\n";
54+
"public: inline void %FUNCTION_NAME%(const %TYPE% &newValue);\n";
5555

5656
QString accomplishCode =
5757
"inline void %CLASS_NAME%::%FUNCTION_NAME%(const %TYPE% &newValue)\n"
@@ -62,7 +62,7 @@ Manage::Manage()
6262
statementTemplate.replace( "%VALUE_NAME%", valueName );
6363
statementTemplate.replace( "%CLASS_NAME%", className );
6464

65-
accomplishCode.replace( "%EQUALITY_JUDGMENT%", ( type == "qreal" ) ? ( "qAbs( newValue - %VALUE_NAME%_ ) < 0.000001" ) : ( "newValue == %VALUE_NAME%_" ) );
65+
accomplishCode.replace( "%EQUALITY_JUDGMENT%", ( ( type == "float" ) || ( type == "double" ) || ( type == "qreal" ) ) ? ( "qAbs( newValue - %VALUE_NAME%_ ) < 0.000001" ) : ( "newValue == %VALUE_NAME%_" ) );
6666
accomplishCode.replace( "%COPY_BUFFER%", ( withThreadSafe ) ? ( "const auto result = %VALUE_NAME%_; " ) : ( "" ) );
6767
accomplishCode.replace( "%BUFFER_NAME%", ( withThreadSafe ) ? ( "result" ) : ( "%VALUE_NAME%_" ) );
6868

@@ -159,7 +159,11 @@ QVariantMap Manage::make(const QString &source, const bool &withThreadSafe, cons
159159
flag = true;
160160
}
161161

162-
if ( type == "qreal" )
162+
if ( type == "float" )
163+
{
164+
statementCode += QString( "private: %1 %2_ = 0.0f;\n" ).arg( type ).arg( valueName );
165+
}
166+
else if ( ( type == "double" ) || ( type == "qreal" ) )
163167
{
164168
statementCode += QString( "private: %1 %2_ = 0.0;\n" ).arg( type ).arg( valueName );
165169
}

0 commit comments

Comments
 (0)