@@ -1163,45 +1163,43 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
1163
1163
}
1164
1164
} );
1165
1165
1166
- // attributes to select
1167
- QgsFieldComboBox *attributeFieldCombo = new QgsFieldComboBox ();
1168
- attributeFieldCombo->setLayer ( mLayer );
1169
- connect ( attributeFieldCombo, &QgsFieldComboBox::fieldChanged, this , [ = ]( QString attributeName )
1170
- {
1171
- qmlCode->insertPlainText ( QStringLiteral ( " feature.attribute(\" %1\" )" ).arg ( attributeName ) );
1172
- } );
1173
-
1174
1166
QgsFieldExpressionWidget *expressionWidget = new QgsFieldExpressionWidget;
1175
1167
expressionWidget->setLayer ( mLayer );
1176
- expressionWidget->setExpressionDialogTitle ( tr ( " Expression" ) );
1168
+ QToolButton *addExpressionButton = new QToolButton ();
1169
+ addExpressionButton->setIcon ( QgsApplication::getThemeIcon ( " /symbologyAdd.svg" ) );
1177
1170
1178
- connect ( expressionWidget, static_cast < void ( QgsFieldExpressionWidget::* )( const QString & ) > ( &QgsFieldExpressionWidget::fieldChanged ) , this , [ = ]( const QString & expressionText )
1171
+ connect ( addExpressionButton, &QAbstractButton::clicked , this , [ = ]
1179
1172
{
1180
- qmlCode->insertPlainText ( QStringLiteral ( " expression(%1)" ).arg ( expressionText ) );
1181
- QgsLogger::warning ( QStringLiteral ( " Do it..." ) );
1182
- // expression needs to be added here...
1173
+ qmlCode->insertPlainText ( QStringLiteral ( " expression.evaluate(\" (%1)\" )" ).arg ( expressionWidget->currentText ()) );
1183
1174
} );
1184
1175
1176
+
1185
1177
QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper ( mLayer , nullptr , this );
1186
1178
qmlWrapper->setQmlCode ( qmlCode->toPlainText () );
1187
1179
connect ( qmlCode, &QPlainTextEdit::textChanged, this , [ = ]
1188
1180
{
1189
1181
qmlWrapper->setQmlCode ( qmlCode->toPlainText () );
1190
1182
qmlWrapper->reinitWidget ();
1183
+ QgsFeature f;
1184
+ mLayer ->getFeatures ().nextFeature (f);
1185
+ qmlWrapper->setFeature ( f );
1191
1186
} );
1192
1187
1193
1188
layout->addRow ( tr ( " Title" ), title );
1194
- QGroupBox *qmlCodeBox = new QGroupBox ( tr ( " QML Code " ) );
1189
+ QScrollArea *qmlCodeBox = new QScrollArea ( );
1195
1190
qmlCodeBox->setLayout ( new QGridLayout );
1196
1191
qmlCodeBox->layout ()->addWidget ( qmlObjectTemplate );
1197
- qmlCodeBox->layout ()->addWidget ( attributeFieldCombo );
1198
- qmlCodeBox->layout ()->addWidget ( expressionWidget );
1192
+ QGroupBox *expressionWidgetBox = new QGroupBox ();
1193
+ qmlCodeBox->layout ()->addWidget ( expressionWidgetBox );
1194
+ expressionWidgetBox->setLayout ( new QGridLayout );
1195
+ expressionWidgetBox->layout ()->addWidget ( expressionWidget );
1196
+ expressionWidgetBox->layout ()->addWidget ( addExpressionButton );
1199
1197
qmlCodeBox->layout ()->addWidget ( qmlCode );
1200
1198
layout->addRow ( qmlCodeBox );
1201
- QGroupBox *qmlPreviewBox = new QGroupBox ( tr ( " Preview " ) );
1199
+ QScrollArea *qmlPreviewBox = new QScrollArea ( );
1202
1200
qmlPreviewBox->setLayout ( new QGridLayout );
1203
1201
qmlPreviewBox->setMinimumWidth ( 400 );
1204
- qmlPreviewBox->layout ()->addWidget (qmlWrapper->widget ());
1202
+ qmlPreviewBox->layout ()->addWidget ( qmlWrapper->widget () );
1205
1203
qmlLayout->addWidget ( qmlPreviewBox );
1206
1204
1207
1205
QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
0 commit comments