23 #include <QRegularExpression>
27 , mPyFunctionName( function )
28 , mPyFormVarName( pyFormName )
30 static int sLayerCounter = 0;
31 mPyLayerVarName = QStringLiteral(
"_qgis_layer_%1_%2" ).arg(
form->
layer()->
id() ).arg( sLayerCounter++ );
32 const thread_local QRegularExpression reClean( QRegularExpression(
"[^a-zA-Z0-9_]" ) );
33 mPyLayerVarName.replace( reClean, QStringLiteral(
"_" ) );
35 const QString initLayer = QStringLiteral(
"%1 = sip.wrapinstance( %2, qgis.core.QgsVectorLayer )" )
36 .arg( mPyLayerVarName )
44 const QString delLayer = QStringLiteral(
"del %1" ).arg( mPyLayerVarName );
50 QDialogButtonBox *buttonBox =
form()->findChild<QDialogButtonBox *>();
61 const QDateTime dt = QDateTime::currentDateTime();
62 const QString pyFeatureVarName = QStringLiteral(
"_qgis_feature_%1" ).arg( dt.toString( QStringLiteral(
"yyyyMMddhhmmsszzz" ) ) );
63 const QString initFeature = QStringLiteral(
"%1 = sip.wrapinstance( %2, qgis.core.QgsFeature )" )
64 .arg( pyFeatureVarName )
69 const QString expr = QStringLiteral(
"%1( %2, %3, %4)" )
70 .arg( mPyFunctionName,
77 const QString delFeature = QStringLiteral(
"del %1" ).arg( pyFeatureVarName );
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
static bool run(const QString &command, const QString &messageOnError=QString())
Execute a Python statement.